job

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2022 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cancellable

type Cancellable interface {
	Cancel() bool
}

type Pending

type Pending interface {
	Pending() bool
}

type RetryBackoff

type RetryBackoff func(i int) time.Duration

func ExponentialRetryBackoff

func ExponentialRetryBackoff(base float64, baseDelay, maxDelay time.Duration) RetryBackoff

type Scheduler

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

Scheduler handles workers and schedules jobs

func NewScheduler

func NewScheduler(logger conflow.Logger, maxWorkers int, maxQueueSize int) *Scheduler

NewScheduler creates a new scheduler instance

func (*Scheduler) ScheduleJob

func (s *Scheduler) ScheduleJob(job conflow.Job) error

ScheduleJob schedules a new job

func (*Scheduler) Start

func (s *Scheduler) Start()

Start creates and starts the workers

func (*Scheduler) Stop

func (s *Scheduler) Stop()

Stop stops all the workers and the dispatcher process

type Semaphore

type Semaphore int64

func (*Semaphore) Cancel

func (s *Semaphore) Cancel() bool

func (*Semaphore) Reset

func (s *Semaphore) Reset()

func (*Semaphore) Run

func (s *Semaphore) Run() bool

type SimpleScheduler

type SimpleScheduler struct{}

func (SimpleScheduler) ScheduleJob

func (s SimpleScheduler) ScheduleJob(job conflow.Job) error

type Tracker

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

Tracker schedules and tracks jobs

func NewTracker

func NewTracker(name conflow.ID, scheduler conflow.JobScheduler, logger conflow.Logger, retryBackoff RetryBackoff) *Tracker

NewTracker creates a new job tracker

func (*Tracker) ActiveJobCount

func (t *Tracker) ActiveJobCount() int

ActiveJobCount returns with the number of active (pending or running) jobs

func (*Tracker) AddPending

func (t *Tracker) AddPending(cnt int)

func (*Tracker) Cancelled

func (t *Tracker) Cancelled(id int)

Cancelled must be called when a process was cancelled

func (*Tracker) Failed

func (t *Tracker) Failed(id int)

func (*Tracker) PendingJobCount

func (t *Tracker) PendingJobCount() int

PendingJobCount returns with the number of pending jobs

func (*Tracker) RemovePending

func (t *Tracker) RemovePending(cnt int)

func (*Tracker) Retry

func (t *Tracker) Retry(id int, limit int, delay time.Duration, reason string, f func()) bool

Retry must be called when a job failed but can be retried. It schedules the job again if there are any retries left If Retry returns false, you are expected to call Failed()

func (*Tracker) RunningJobCount

func (t *Tracker) RunningJobCount() int

RunningJobCount returns with the number of running jobs

func (*Tracker) ScheduleJob

func (t *Tracker) ScheduleJob(job conflow.Job) error

ScheduleJob schedules a new job

func (*Tracker) Stop

func (t *Tracker) Stop() int

Stop cancels all remaining jobs It can be called multiple times It will return with the number of running jobs which couldn't be cancelled

func (*Tracker) Succeeded

func (t *Tracker) Succeeded(id int)

Succeeded must be called when a process finished successfully

type Worker

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

Worker is a goroutine processing jobs

func NewWorker

func NewWorker(logger conflow.Logger, jobQueue chan conflow.Job) Worker

NewWorker creates a new worker instance

func (Worker) Start

func (w Worker) Start()

Start starts the worker goroutine

func (Worker) Stop

func (w Worker) Stop()

Stop stops the worker goroutine

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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