dispatcher

package
v2.1.6 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDispatcherClosed = errors.New("dispatcher has been closed")

Functions

This section is empty.

Types

type Dispatcher

type Dispatcher[T any] struct {
	// contains filtered or unexported fields
}

func NewDispatcher

func NewDispatcher[T any](ctx context.Context, dispatchFunc func([]T), batchSize int) *Dispatcher[T]

NewDispatcher creates a generic dispatcher that can receive values from multiple goroutines in a thread-safe manner and process each element serially using the dispatchFunc

func (*Dispatcher[T]) Close

func (d *Dispatcher[T]) Close()

Close closes the dispatcher

func (*Dispatcher[T]) CloseAndWait

func (d *Dispatcher[T]) CloseAndWait()

CloseAndWait closes the dispatcher and waits for all pending elements to be processed

func (*Dispatcher[T]) Len

func (d *Dispatcher[T]) Len() uint64

Len returns the number of elements in the dispatcher's buffer

func (*Dispatcher[T]) ReadCount

func (d *Dispatcher[T]) ReadCount() uint64

ReadCount returns the number of elements read from the dispatcher's buffer

func (*Dispatcher[T]) Write

func (d *Dispatcher[T]) Write(values ...T) error

Write writes values to the dispatcher

func (*Dispatcher[T]) WriteCount

func (d *Dispatcher[T]) WriteCount() uint64

WriteCount returns the number of elements written to the dispatcher

Jump to

Keyboard shortcuts

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