dispatch

package
v0.11.4 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultNumWorkers = 1

DefaultNumWorkers is the default number of workers

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatch

type Dispatch struct {
	WorkerPool chan chan scheduler.Jobber

	NumWorkers int
	// contains filtered or unexported fields
}

Dispatch is a dispatcher that executes jobs

func NewDispatch

func NewDispatch(workerFactory WorkerFactorier, options ...OptionsFunc) *Dispatch

New creates a new dispatcher

func (*Dispatch) Enqueue

func (d *Dispatch) Enqueue(job scheduler.Jobber)

Enqueue enqueues a job to be executed by a worker

func (*Dispatch) Options

func (d *Dispatch) Options(opts ...OptionsFunc)

Options configure the stevedore command

func (*Dispatch) Start

func (d *Dispatch) Start(ctx context.Context, opts ...OptionsFunc) (err error)

Start prepares dispatcher to start workers and dispatch jobs

type MockDispatch

type MockDispatch struct {
	mock.Mock
}

MockDispatch is a mock of Dispatch interface

func NewMockDispatch

func NewMockDispatch() *MockDispatch

NewMockDispatch provides a mock of Dispatch interface

func (*MockDispatch) Enqueue

func (m *MockDispatch) Enqueue(job scheduler.Jobber)

Enqueue provides a mock function with given fields: _a0, _a1

func (*MockDispatch) Start

func (m *MockDispatch) Start(ctx context.Context, opts ...OptionsFunc) error

type OptionsFunc

type OptionsFunc func(*Dispatch)

OptionsFunc is a function used to configure the dispatcher

func WithNumWorkers

func WithNumWorkers(n int) OptionsFunc

type WorkerFactorier

type WorkerFactorier interface {
	New(chan chan scheduler.Jobber) scheduler.Workerer
}

WorkerFactorier interface defines a worker factory

Jump to

Keyboard shortcuts

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