pool

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAsyncConcurrency = 1
	DefaultAsyncChanLength  = 100
)
View Source
const (
	DefaultConsumerQueueLength = 1000
	DefaultConsumerMaxMerge    = 10
	DefaultConsumerMaxDuration = time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AsyncFunc

type AsyncFunc func(context.Context, interface{})

func (AsyncFunc) Handle

func (fn AsyncFunc) Handle(ctx context.Context, arg interface{})

type AsyncHandler

type AsyncHandler interface {
	Handle(context.Context, interface{})
}

type AsyncOption

type AsyncOption func(pool *AsyncPool)

func WithAsyncChanLength

func WithAsyncChanLength(chanLen int) AsyncOption

func WithAsyncComponent

func WithAsyncComponent(component string) AsyncOption

func WithAsyncConcurrency

func WithAsyncConcurrency(concurrency int) AsyncOption

type AsyncPool

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

func NewAsync

func NewAsync(handler AsyncHandler, opts ...AsyncOption) *AsyncPool

func (*AsyncPool) Add

func (pool *AsyncPool) Add(data interface{}) bool

type Consumer

type Consumer interface {
	Handle(context.Context, interface{}, []interface{})
}

type ConsumerFunc

type ConsumerFunc func(context.Context, interface{}, []interface{})

func (ConsumerFunc) Handle

func (fn ConsumerFunc) Handle(ctx context.Context, key interface{}, values []interface{})

type ConsumerOption

type ConsumerOption func(slot *consumerSlot)

func WithConsumerChanLength

func WithConsumerChanLength(chanLen int) ConsumerOption

func WithConsumerComponent

func WithConsumerComponent(component string) ConsumerOption

func WithConsumerMaxDuration

func WithConsumerMaxDuration(dur time.Duration) ConsumerOption

func WithConsumerMaxMerge

func WithConsumerMaxMerge(length int) ConsumerOption

type ConsumerPool

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

func NewConsumer

func NewConsumer(slotSize int, handler Consumer, opts ...ConsumerOption) *ConsumerPool

func (*ConsumerPool) Add

func (pool *ConsumerPool) Add(key interface{}, value interface{}) bool

Jump to

Keyboard shortcuts

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