async

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFull chan full.
	ErrFull = errors.New("async: chan full")
)

Functions

This section is empty.

Types

type Option

type Option func(*options)

Option TaskDispatcher option

func Buffer

func Buffer(n int) Option

Buffer specifies the buffer of TaskDispatcher

func Worker

func Worker(n int) Option

Worker specifies the worker of TaskDispatcher

type TaskDispatcher

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

TaskDispatcher async consume data from chan.

func New

func New(name string, opts ...Option) *TaskDispatcher

New new a TaskDispatcher struct.

func (*TaskDispatcher) Close

func (c *TaskDispatcher) Close() error

Close 必须显示调用, 防止丢 task

func (*TaskDispatcher) Dispatch

func (c *TaskDispatcher) Dispatch(ctx context.Context, taskFn func(ctx context.Context)) (err error)

Dispatch 分发调度 save a callback func.

Jump to

Keyboard shortcuts

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