Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrQueueIsFull is the error returned when an item is offered to the Queue and the queue is full. ErrQueueIsFull = errors.New("sending queue is full") )
Functions ¶
func NewMockStorageExtension ¶
Types ¶
type Consumers ¶
type Consumers[T any] struct { // contains filtered or unexported fields }
func NewQueueConsumers ¶
type ItemsSizer ¶
type ItemsSizer[T itemsCounter] struct{}
ItemsSizer is a Sizer implementation that returns the size of a queue element as the number of items it contains.
func (*ItemsSizer[T]) Sizeof ¶ added in v0.100.0
func (is *ItemsSizer[T]) Sizeof(el T) int64
type MemoryQueueSettings ¶
MemoryQueueSettings defines internal parameters for boundedMemoryQueue creation.
type PersistentQueueSettings ¶
type Queue ¶
type Queue[T any] interface { component.Component // Offer inserts the specified element into this queue if it is possible to do so immediately // without violating capacity restrictions. If success returns no error. // It returns ErrQueueIsFull if no space is currently available. Offer(ctx context.Context, item T) error // Consume applies the provided function on the head of queue. // The call blocks until there is an item available or the queue is stopped. // The function returns true when an item is consumed or false if the queue is stopped. Consume(func(ctx context.Context, item T) error) bool // Size returns the current Size of the queue Size() int // Capacity returns the capacity of the queue. Capacity() int }
Queue defines a producer-consumer exchange which can be backed by e.g. the memory-based ring buffer queue (boundedMemoryQueue) or via a disk-based queue (persistentQueue)
func NewBoundedMemoryQueue ¶
func NewBoundedMemoryQueue[T any](set MemoryQueueSettings[T]) Queue[T]
NewBoundedMemoryQueue constructs the new queue of specified capacity, and with an optional callback for dropped items (e.g. useful to emit metrics).
func NewPersistentQueue ¶
func NewPersistentQueue[T any](set PersistentQueueSettings[T]) Queue[T]
NewPersistentQueue creates a new queue backed by file storage; name and signal must be a unique combination that identifies the queue storage
type RequestSizer ¶
type RequestSizer[T any] struct{}
RequestSizer is a Sizer implementation that returns the size of a queue element as one request.
func (*RequestSizer[T]) Sizeof ¶ added in v0.100.0
func (rs *RequestSizer[T]) Sizeof(T) int64