asyncworker

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: Apache-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 AsyncWorkers

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

func NewAsyncWorkers

func NewAsyncWorkers(name string) *AsyncWorkers

func (*AsyncWorkers) AddWork

func (aws *AsyncWorkers) AddWork(workName string, work *Work) error

func (*AsyncWorkers) Start

func (aws *AsyncWorkers) Start(stopCh <-chan struct{}) error

type Work

type Work struct {
	// Fn is the function to handle the work,
	// its first param must be of type context.Context,
	// it's allowed to have any number of other parameters of any type,
	// and can have only one return value with error type,
	// its prototype likes func(ctx context.Context, i int, s string, ...) error
	Fn interface{}
	// Params are parameters of the fn
	Params []interface{}
	// DeliverAt is the time at which the work is delivered
	DeliveredAt time.Time
}

work contains details to handle by workers

Jump to

Keyboard shortcuts

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