channel

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: May 14, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = stderr.New("channel has closed, do not recevie value anymore.")

ErrClosed returned if Append called after Close()

Functions

This section is empty.

Types

type Channel

type Channel interface {
	// Close will block until all data in channel consumed completely
	Close()
	// T return channel's typeof
	T() string
	// Append value into channel, the value must be format of typeof defined in NewChannel
	Append(value interface{}) error
}

Channel a graceful-close channel

func NewChannel

func NewChannel(typeOf reflect.Type, capactiy uint16, consumer Consumer, opts ...Option) (Channel, error)

NewChannel create a new graceful-close channel instance, data in channel must be typeof; with a single consumer by default.

type Consumer

type Consumer = func(value interface{})

Consumer define a handle how consume data from channel

type Option

type Option func(*config)

Option how setup consumer

func WithWorker

func WithWorker(num uint16) Option

WithWorker setup the number of consumers

Jump to

Keyboard shortcuts

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