dispatcher

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidPayload = errors.New("invalid payload")

Functions

func SetLogger

func SetLogger(l *zap.SugaredLogger)

func WaitUntilTrue

func WaitUntilTrue(ctx context.Context, between time.Duration, f func() bool) error

Types

type Dispatcher

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

func Start

func Start(workers int, wl Workload) Dispatcher

func (*Dispatcher) Dispatch

func (d *Dispatcher) Dispatch(payload interface{})

func (Dispatcher) Stop

func (d Dispatcher) Stop()

type Task

type Task struct {
	Payload    interface{}
	Dispatcher *Dispatcher
}

type Worker

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

func NewWorker

func NewWorker(id int, workerPool chan chan Task, wl Workload) Worker

func (*Worker) Start

func (w *Worker) Start()

Start starts reading from tasks channel

func (*Worker) Stop

func (w *Worker) Stop()

Stop stops the workload invocation cycle (it will finish the current workload)

type Workload

type Workload interface {
	Do(Task) error
}

Jump to

Keyboard shortcuts

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