timer

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2018 License: AGPL-3.0 Imports: 12 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]*ScheduleWaiter
	EventChan chan *jobs.JobTriggerEvent
	StopChan  chan bool
}

EventProducer gathers all ScheduleWaiters 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.

type ScheduleWaiter

type ScheduleWaiter struct {
	*jobs.Schedule
	// contains filtered or unexported fields
}

ScheduleWaiter provides an easy way to execute a job at given times (like a cron job).

func NewScheduleWaiter

func NewScheduleWaiter(jobId string, schedule *jobs.Schedule, tickerChannel chan *jobs.JobTriggerEvent) *ScheduleWaiter

NewScheduleWaiter creates a new waiter that sends start events for this job on the given schedule

func (*ScheduleWaiter) ParseSchedule

func (w *ScheduleWaiter) ParseSchedule() error

ParseSchedule parses the given Iso 8601 string and stores corresponding values in the waiter to ease processing.

func (*ScheduleWaiter) Start

func (w *ScheduleWaiter) Start()

Start starts the waiter

func (*ScheduleWaiter) Stop

func (w *ScheduleWaiter) Stop()

Stop simply stops the waiter

func (*ScheduleWaiter) WaitUntilNext

func (w *ScheduleWaiter) WaitUntilNext()

WaitUntilNext implements the intelligence of the waiter.

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