Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Metrics ¶
type Metrics interface {
// IncPublished is called once per Publish attempt with the outcome
// ("success" | "error") and the recurrence kind of the task.
IncPublished(result string, recurrence string)
// SetLastTickTimestamp is called at the start of every tick with the
// wall-clock time of that tick start as Unix seconds (float).
SetLastTickTimestamp(seconds float64)
}
Metrics records observability events for the hourly tick loop.
func NewPrometheusMetrics ¶
func NewPrometheusMetrics() Metrics
NewPrometheusMetrics returns a Metrics backed by the package-level Prometheus counter and gauge. The counter is pre-initialized in init() so the first call into the metrics surface is just an Inc/Add.
type Tick ¶
type Tick interface {
// Run performs an initial tick synchronously, then enters a 1-hour loop
// that fires on time.NewTicker. Returns nil on clean context cancellation.
Run(ctx context.Context) error
// RunOnce performs a single tick (publish every entry in the inventory)
// and returns. Intended for local smoke-testing via cmd/run-once.
RunOnce(ctx context.Context) error
}
Tick runs the hourly cron loop. Run blocks until ctx is cancelled.
func NewTick ¶
func NewTick( ctx context.Context, scheduleStore store.ScheduleStore, pub publisher.Publisher, clock libtime.CurrentDateTimeGetter, metrics Metrics, ) (Tick, error)
NewTick builds the hourly cron loop. store supplies the recurring-task definitions per tick via its List method; pub sends one CreateCommand per entry per tick; clock is the wall-clock source; metrics records per-publish outcomes and the tick-start timestamp. Returns a wrapped error if time.LoadLocation("Europe/Berlin") fails at struct init.