dispatcher

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 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 Done added in v0.6.0

func Done(d chan bool) bool

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{}) chan bool

func (Dispatcher) DoAndStop added in v0.6.1

func (d Dispatcher) DoAndStop()

func (Dispatcher) Stop

func (d Dispatcher) Stop()

type Task

type Task struct {
	Payload    interface{}
	Dispatcher *Dispatcher
	// contains filtered or unexported fields
}

type Worker

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

func NewWorker

func NewWorker(id int, workerPool chan chan Task, wl Workload, gwait *sync.WaitGroup) Worker

func (*Worker) Start

func (w *Worker) Start()

Start starts reading from tasks channel

func (*Worker) Stop

func (w *Worker) Stop()

Stop stops the wl invocation cycle (it will finish the current wl).

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