timer

package
v3.0.0-rc1+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2021 License: AGPL-3.0 Imports: 8 Imported by: 9

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

Handle passes JobChangeEvents to the registered event producer.

Directories

Path Synopsis
Package grpc provides a gRPC service that triggers scheduler events based on ISO 8601 patterns.
Package grpc 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