Documentation
¶
Overview ¶
Package dispatch owns the run lifecycle: routing repos to executors and serializing runs per repo with debounce, coalescing and timeouts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher owns the per-repo run lifecycle: debounce, mutual exclusion, rerun coalescing, global concurrency and the run timeout.
func NewDispatcher ¶
func NewDispatcher(st store.Store, router *Router, opts Options) *Dispatcher
NewDispatcher wires a Dispatcher; opts.Log and opts.Metrics may be nil.
func (*Dispatcher) Adopt ¶
func (d *Dispatcher) Adopt(run executor.AdoptedRun, executorName string)
Adopt registers an in-flight run discovered at startup. The repo is locked until wait returns; a deferred rerun fires afterwards if events arrived meanwhile.
func (*Dispatcher) Enqueue ¶
func (d *Dispatcher) Enqueue(ev platform.Event)
Enqueue requests a run for the event's repo. Duplicate requests coalesce: one pending run while queued, one deferred rerun while running.
func (*Dispatcher) SetRouter ¶ added in v0.2.0
func (d *Dispatcher) SetRouter(r *Router)
SetRouter atomically swaps the routing rules; subsequent Enqueues use the new rules, in-flight runs are unaffected. Used for SIGHUP reloads.
type Metrics ¶
type Metrics interface {
RunStarted(executorName string)
RunFinished(executorName, result string, seconds float64)
}
Metrics receives run lifecycle notifications. Implemented by the metrics package; nil-safe via the noop default.
type Options ¶
type Options struct {
Debounce time.Duration
RunTimeout time.Duration
MaxConcurrent int
Log *slog.Logger
Metrics Metrics
History Recorder
}
Options configures a Dispatcher.
type Recorder ¶ added in v0.2.0
Recorder receives an entry for every finished run. Implemented by the history package; nil-safe via the noop default.