timer

package
v5.0.0-...-3817779 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2025 License: AGPL-3.0 Imports: 9 Imported by: 0

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) Handle

func (e *EventProducer) Handle(ctx context.Context, msg *jobs.JobChangeEvent) error

Handle passes JobChangeEvents to the registered event producer.

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.

Directories

Path Synopsis
Package service provides a gRPC service that triggers scheduler events based on ISO 8601 patterns.
Package service provides a gRPC service that triggers scheduler events based on ISO 8601 patterns.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL