Documentation
¶
Overview ¶
Package worker contains background workers that run alongside the HTTP server.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StartAll ¶
func StartAll(ctx context.Context, db *gorm.DB, cfg *config.Config, teamsSvc *services.TeamsService, hooks enterprise.Hooks)
StartAll starts all background workers. teamsSvc is constructed once in serve.go and shared with the API router. hooks.Retention is a no-op in the OSS build; the enterprise build provides a real enforcer that purges data according to configured retention policies.
Types ¶
type EscalationWorker ¶
type EscalationWorker struct {
// contains filtered or unexported fields
}
EscalationWorker polls active escalation states every 30 seconds and:
- Sends Slack DMs to on-call users at the appropriate tier.
- Advances to the next tier when the current tier's timeout expires.
- Marks escalations completed when the last tier is exhausted.
It also implements services.EscalationNotifier so it can be passed directly into NewEscalationEngine as the notification sink.
func NewEscalationWorker ¶
func NewEscalationWorker(chatService services.ChatService) *EscalationWorker
NewEscalationWorker creates a new EscalationWorker. chatService may be nil; in that case SendEscalationDM is a no-op. Call SetEngine before Run to wire the escalation engine.
func (*EscalationWorker) Run ¶
func (w *EscalationWorker) Run(ctx context.Context)
Run starts the evaluation loop and blocks until ctx is cancelled. Designed to be launched as a goroutine from worker.StartAll.
func (*EscalationWorker) SendEscalationDM ¶
func (w *EscalationWorker) SendEscalationDM(userID string, alert *models.Alert, tierIndex int) error
SendEscalationDM implements services.EscalationNotifier. Sends a Slack DM to userID with alert details and an Acknowledge button. If chatService is nil, the call is a no-op (Slack not configured). alert may be nil for incident-sourced escalations.
func (*EscalationWorker) SetEngine ¶
func (w *EscalationWorker) SetEngine(engine services.EscalationEngine)
SetEngine wires the escalation engine into the worker. Must be called before Run. This two-step construction breaks the circular dependency: EscalationEngine needs an EscalationNotifier (the worker), and the worker needs an EscalationEngine.
type HolidayWorker ¶
type HolidayWorker struct {
// contains filtered or unexported fields
}
HolidayWorker refreshes public holiday data daily for all schedules that have holiday country codes configured.
func NewHolidayWorker ¶
func NewHolidayWorker(svc *services.HolidayService) *HolidayWorker
NewHolidayWorker creates a new HolidayWorker.
func (*HolidayWorker) Run ¶
func (w *HolidayWorker) Run(ctx context.Context)
Run starts the daily holiday sync loop. It runs an initial sync on startup, then repeats every 24 hours at approximately midnight UTC.
type ShiftNotifier ¶
type ShiftNotifier struct {
// contains filtered or unexported fields
}
ShiftNotifier watches all on-call schedules and sends Slack DMs when a shift handoff occurs. It uses an in-memory dedup map so each (layer, boundary) pair is notified at most once per process lifetime.
func NewShiftNotifier ¶
func NewShiftNotifier( repo repository.ScheduleRepository, evaluator services.ScheduleEvaluator, chatService services.ChatService, ) *ShiftNotifier
NewShiftNotifier creates a new ShiftNotifier. If chatService is nil the worker runs but all send operations are no-ops.
func (*ShiftNotifier) Run ¶
func (n *ShiftNotifier) Run(ctx context.Context)
Run starts the notification loop and blocks until ctx is cancelled. Designed to be launched as a goroutine from main.
type TelemetryWorker ¶
type TelemetryWorker struct {
// contains filtered or unexported fields
}
TelemetryWorker runs two background tasks:
- Daily heartbeat to PostHog with anonymous aggregate stats
- Every-6h poll of static.fluidify.ai/regen/announcements.json, cached for the API
func NewTelemetryWorker ¶
func NewTelemetryWorker(db *gorm.DB, cfg *config.Config, repo repository.SystemSettingsRepository) *TelemetryWorker
func (*TelemetryWorker) GetCachedAnnouncements ¶
func (tw *TelemetryWorker) GetCachedAnnouncements() []byte
GetCachedAnnouncements returns the last successfully fetched announcements JSON. Falls back to an empty list when nothing has been fetched yet.
func (*TelemetryWorker) Run ¶
func (tw *TelemetryWorker) Run(ctx context.Context)