work

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_CONCURRENCY = 1
View Source
const MAX_FAILS = 4

Variables

View Source
var (
	DefaultTickerDuration = 5 * time.Millisecond
	TickerDurationOnError = 10 * time.Millisecond

	ErrDuplicateHandler = errors.New("handler with provided name already mapped")
)
View Source
var ErrJobNotFoundInCronSch = errors.New("handler with provided name already mapped")

Functions

This section is empty.

Types

type Handler

type Handler func(map[string]interface{}) error

type JobParams

type JobParams struct {
	Name    string
	Handler string
	Args    map[string]interface{}
}

type WorkerPoolAdapter

type WorkerPoolAdapter struct {
	// contains filtered or unexported fields
}

func NewWorkerAdapter

func NewWorkerAdapter(timeZoneArg string, useCronParserWithSeconds bool) (*WorkerPoolAdapter, error)

func (*WorkerPoolAdapter) Perform

func (adapter *WorkerPoolAdapter) Perform(job JobParams) error

Perform sends a new job to the queue to be executed as soon as a worker is available

func (*WorkerPoolAdapter) PerformIn added in v0.3.5

func (adapter *WorkerPoolAdapter) PerformIn(secondsInFuture int, job JobParams) error

PerformIn sends a job to the 'scheduled' queue to be executed as soon as 'secondsInFuture' has elapsed

func (*WorkerPoolAdapter) PeriodicallyPerform

func (adapter *WorkerPoolAdapter) PeriodicallyPerform(cronExpression string, job JobParams) error

PeriodicallyPerform adds a job to the queue periodically (to be executed), based on the 'cronExpression' expression provided.

NOTE: All enqueued jobs are unique by name. if a duplicate is added, an error is logged when the internal cron scheduler tries to add it the job to the job queue.

func (*WorkerPoolAdapter) Register

func (adapter *WorkerPoolAdapter) Register(name string, handler Handler) error

Register binds a name to a handler.

func (*WorkerPoolAdapter) RemovePeriodicJob

func (adapter *WorkerPoolAdapter) RemovePeriodicJob(jobName string)

func (*WorkerPoolAdapter) Start

func (adapter *WorkerPoolAdapter) Start() error

Start starts the cron scheduler & worker pool

func (*WorkerPoolAdapter) Stop

func (adapter *WorkerPoolAdapter) Stop() error

Stop stops the cron scheduler & worker pool

func (*WorkerPoolAdapter) UpdateJobScheduleByTag added in v0.3.2

func (adapter *WorkerPoolAdapter) UpdateJobScheduleByTag(tag, cronExpression string) error

Jump to

Keyboard shortcuts

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