Documentation
¶
Index ¶
- Constants
- Variables
- func FanInOut(ctx context.Context, goroutines int, buffer int, in chan interface{}, ...)
- func GetGoroutinesCount(variables, maxGoroutines int) int
- func GetMessageOrTimeout(timeout time.Duration, msg chan []byte, def []byte) []byte
- func MergeChannels(input ...<-chan interface{}) <-chan interface{}
- func RecoverWrapper(ctx context.Context, next ExecuteFunc) (err error)
- func RunAsyncMultipleWorkers(ctx context.Context, goroutines int, buffer int, ...) <-chan interface{}
- func RunSyncMultipleWorkers(ctx context.Context, goroutines int, fn func(ctx context.Context))
- type Aggregator
- type ExecuteFunc
- type Pool
- type Worker
- type WorkersPool
- func (w *WorkersPool[K]) Execute(fn func(ctx context.Context) error)
- func (w *WorkersPool[K]) Get(id string) (*Worker, bool)
- func (w *WorkersPool[K]) PersistentWorker(ctx context.Context, ch chan K, handler func(context.Context, K) error) error
- func (w *WorkersPool[K]) Remove(id string)
- func (w *WorkersPool[K]) Size() uint64
- func (w *WorkersPool[K]) Stop()
- func (w *WorkersPool[K]) TemporalWorker(ctx context.Context, idleTimeout time.Duration, timeout func(), ch chan K, ...) error
- func (w *WorkersPool[K]) Wait() error
Constants ¶
View Source
const (
DefaultCounterCheck = 10 * time.Millisecond
)
Variables ¶
View Source
var ErrFunctionTimeout = errors.New("function timeout")
View Source
var ErrNilFunction = errors.New("function to execute is nil")
View Source
var ErrPanic = errors.New("error panic")
Functions ¶
func GetGoroutinesCount ¶
func GetMessageOrTimeout ¶
GetMessageOrTimeout get message or timeout
func MergeChannels ¶
func MergeChannels(input ...<-chan interface{}) <-chan interface{}
MergeChannels merge multiple channels into one
func RecoverWrapper ¶
func RecoverWrapper(ctx context.Context, next ExecuteFunc) (err error)
Types ¶
type Aggregator ¶
type Aggregator struct {
// contains filtered or unexported fields
}
func NewAggregator ¶
func (*Aggregator) Add ¶
func (w *Aggregator) Add(req any)
func (*Aggregator) Close ¶
func (w *Aggregator) Close()
func (*Aggregator) Count ¶
func (w *Aggregator) Count() int
func (*Aggregator) Flusher ¶
func (w *Aggregator) Flusher() error
func (*Aggregator) Process ¶
func (w *Aggregator) Process() error
type ExecuteFunc ¶
func FunctionWithTimeout ¶
func FunctionWithTimeout( timeout time.Duration, fn ExecuteFunc, ) ExecuteFunc
FunctionWithTimeout function which return result after timeout (be careful not release resources without using context)
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool of workers
type WorkersPool ¶
type WorkersPool[K any] struct { // contains filtered or unexported fields }
func NewWorkersPool ¶
func NewWorkersPool[K any]( ctx context.Context, ) *WorkersPool[K]
func (*WorkersPool[K]) Execute ¶
func (w *WorkersPool[K]) Execute(fn func(ctx context.Context) error)
func (*WorkersPool[K]) PersistentWorker ¶
func (*WorkersPool[K]) Remove ¶
func (w *WorkersPool[K]) Remove(id string)
func (*WorkersPool[K]) Size ¶
func (w *WorkersPool[K]) Size() uint64
func (*WorkersPool[K]) Stop ¶
func (w *WorkersPool[K]) Stop()
func (*WorkersPool[K]) TemporalWorker ¶
func (*WorkersPool[K]) Wait ¶
func (w *WorkersPool[K]) Wait() error
Click to show internal directories.
Click to hide internal directories.