worker

package
v0.0.0-...-eaf2c59 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultJobWorkerMaxJobActive  = 32
	DefaultJobWorkerConcurrency   = 4
	DefaultJobWorkerPollInterval  = 100 * time.Millisecond
	DefaultJobWorkerPollThreshold = 0.3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type JobClient

type JobClient interface {
	NewCompleteJobCommand() commands.CompleteJobCommandStep1
	NewFailJobCommand() commands.FailJobCommandStep1
}

type JobHandler

type JobHandler func(client JobClient, job entities.Job)

type JobWorker

type JobWorker interface {
	// Initiate graceful shutdown and awaits termination
	Close()
	// Await termination of worker
	AwaitClose()
}

type JobWorkerBuilder

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

func (*JobWorkerBuilder) Concurrency

func (builder *JobWorkerBuilder) Concurrency(concurrency int) JobWorkerBuilderStep3

func (*JobWorkerBuilder) FetchVariables

func (builder *JobWorkerBuilder) FetchVariables(fetchVariables ...string) JobWorkerBuilderStep3

func (*JobWorkerBuilder) Handler

func (builder *JobWorkerBuilder) Handler(handler JobHandler) JobWorkerBuilderStep3

func (*JobWorkerBuilder) JobType

func (builder *JobWorkerBuilder) JobType(jobType string) JobWorkerBuilderStep2

func (*JobWorkerBuilder) MaxJobsActive

func (builder *JobWorkerBuilder) MaxJobsActive(maxJobsActive int) JobWorkerBuilderStep3

func (*JobWorkerBuilder) Name

func (builder *JobWorkerBuilder) Name(name string) JobWorkerBuilderStep3

func (*JobWorkerBuilder) Open

func (builder *JobWorkerBuilder) Open() JobWorker

func (*JobWorkerBuilder) PollInterval

func (builder *JobWorkerBuilder) PollInterval(pollInterval time.Duration) JobWorkerBuilderStep3

func (*JobWorkerBuilder) PollThreshold

func (builder *JobWorkerBuilder) PollThreshold(pollThreshold float64) JobWorkerBuilderStep3

func (*JobWorkerBuilder) Timeout

func (builder *JobWorkerBuilder) Timeout(timeout time.Duration) JobWorkerBuilderStep3

type JobWorkerBuilderStep1

type JobWorkerBuilderStep1 interface {
	// Set the type of jobs to work on
	JobType(string) JobWorkerBuilderStep2
}

func NewJobWorkerBuilder

func NewJobWorkerBuilder(gatewayClient pb.GatewayClient, jobClient JobClient, requestTimeout time.Duration) JobWorkerBuilderStep1

type JobWorkerBuilderStep2

type JobWorkerBuilderStep2 interface {
	// Set the handler to process jobs. The worker should complete or fail the job. The handler implementation
	// must be thread-safe.
	Handler(JobHandler) JobWorkerBuilderStep3
}

type JobWorkerBuilderStep3

type JobWorkerBuilderStep3 interface {
	// Set the name of the worker owner
	Name(string) JobWorkerBuilderStep3
	// Set the duration no other worker should work on job activated by this worker
	Timeout(time.Duration) JobWorkerBuilderStep3
	// Set the maximum number of jobs which will be activated for this worker at the
	// same time.
	MaxJobsActive(int) JobWorkerBuilderStep3
	// Set the maximum number of concurrent spawned goroutines to complete jobs
	Concurrency(int) JobWorkerBuilderStep3
	// Set the maximal interval between polling for new jobs
	PollInterval(time.Duration) JobWorkerBuilderStep3
	// Set the threshold of buffered activated jobs before polling for new jobs, i.e. threshold * MaxJobsActive(int)
	PollThreshold(float64) JobWorkerBuilderStep3
	// Set list of variable names which should be fetched on job activation
	FetchVariables(...string) JobWorkerBuilderStep3
	// Open the job worker and start polling and handling jobs
	Open() JobWorker
}

Jump to

Keyboard shortcuts

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