Documentation
¶
Overview ¶
Package backfill plans and records resumable local partitioned runs.
Index ¶
- Constants
- func AcquireChildLease(dir, generation string) (io.Closer, error)
- func Eligible(status Status, rerun string) bool
- func ParseRange(start, end, zone string) (time.Time, time.Time, error)
- type Attempt
- type Interval
- type LockedWriter
- type Manifest
- type Options
- type Plan
- type Record
- type Run
- type Status
- type Store
- func (s *Store) BeginExecution(generation string) error
- func (s *Store) Create(m Manifest) error
- func (s *Store) Lock() (*flock.Flock, error)
- func (s *Store) Manifest() (Manifest, error)
- func (s *Store) Read(i Interval) (Record, error)
- func (s *Store) Records(ctx context.Context) iter.Seq2[Record, error]
- func (s *Store) Save(r Record) error
- type Summary
Constants ¶
const Version = 1
Variables ¶
This section is empty.
Functions ¶
func AcquireChildLease ¶
AcquireChildLease holds a shared execution lock until Close is called and rejects children from a superseded executor generation.
Types ¶
type LockedWriter ¶
LockedWriter prevents interleaved child output and races in custom writers.
type Options ¶
type Plan ¶
type Plan struct {
Target string `json:"target"`
WorkingDirectory string `json:"working_directory"`
Environment string `json:"environment"`
RunFlags map[string][]string `json:"run_flags"`
Start time.Time `json:"start"`
End time.Time `json:"end"` // exclusive
Timezone string `json:"timezone"`
Partition string `json:"partition"`
}
Plan contains the immutable inputs needed to regenerate a backfill. Intervals are generated lazily; neither planning nor execution retains the whole range.
func (Plan) Count ¶
Count calculates elapsed-time partition counts directly and walks calendar boundaries without creating partition IDs or reading queued records.
type Run ¶
Run executes a single attempt. The run ID has already been persisted before this is called; implementations must wait for the child to exit on cancellation.
type Store ¶
type Store struct{ Dir string }
Store writes independent atomic partition snapshots. The OS lock protects a backfill from concurrent executors and is automatically released after a crash.
func (*Store) BeginExecution ¶
BeginExecution changes the token accepted by child runs while holding an exclusive lock. Child processes hold shared locks for their whole lifetime, so an executor cannot resume while a child orphaned by an abrupt parent exit is still active. A child that had not acquired its lock before the resume sees the changed token and exits before doing any work.
type Summary ¶
type Summary struct {
Total int `json:"total"`
Succeeded int `json:"succeeded"`
Failed int `json:"failed"`
Cancelled int `json:"cancelled"`
Queued int `json:"queued"`
Running int `json:"running"`
Skipped int `json:"skipped"` // not selected in this invocation, including previous successes
}
func Execute ¶
func Execute(ctx context.Context, m Manifest, s *Store, o Options, run Run, observers ...func(Status, Record)) (Summary, error)
Execute keeps at most MaxParallel records in memory. The caller holds the store lock. A stopped or interrupted invocation leaves unstarted partitions queued.