pool

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 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

func WithAsyncProduct

func WithAsyncProduct(product string) 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 added in v0.1.5

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

func WithConsumerProduct

func WithConsumerProduct(product string) 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