Documentation ¶
Overview ¶
Package timer produces events that start scheduler jobs on pre-defined dates and/or intervals.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventProducer ¶
type EventProducer struct { Context context.Context Waiters map[string]*schedule.Ticker EventChan chan *jobs.JobTriggerEvent StopChan chan bool TestChan chan *jobs.JobTriggerEvent }
EventProducer gathers all Tickers in a pool and provides a single entry point to communicate with them, typically to stop them.
func NewEventProducer ¶
func NewEventProducer(rootCtx context.Context) *EventProducer
NewEventProducer creates a pool of ScheduleWaiters that will send events based on pre-defined scheduling.
func (*EventProducer) Start ¶
func (e *EventProducer) Start() error
Start loads all TimersOnly Jobs from the job repository and registers them in this EventProducer pool.
func (*EventProducer) StartOrUpdateJob ¶
func (e *EventProducer) StartOrUpdateJob(job *jobs.Job)
StartOrUpdateJob creates a ScheduleWaiter and registers it in the EventProducer pool. If a waiter already exists for the same job ID it will be stopped and replaced with a new one.
func (*EventProducer) StopAll ¶
func (e *EventProducer) StopAll()
StopAll ranges all waiters from the EventProducer, calls Stop() and remove them from the Waiter pool.
func (*EventProducer) StopWaiter ¶
func (e *EventProducer) StopWaiter(jobId string)
StopWaiter stops a waiter given its ID and remove it from the Waiter pool. If no waiter with this ID is registered, it returns silently.
type JobsEventsSubscriber ¶
type JobsEventsSubscriber struct {
Producer *EventProducer
}
JobsEventsSubscriber provides an entry point to add, update or remove Scheduler Jobs.
func (*JobsEventsSubscriber) Handle ¶
func (e *JobsEventsSubscriber) Handle(ctx context.Context, msg *jobs.JobChangeEvent) error
Handle passes JobChangeEvents to the registered event producer.