Documentation ¶
Overview ¶
Package containers provides helper containers for qruntime.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PriorityQueue ¶
type PriorityQueue[T comparable] struct { // contains filtered or unexported fields }
PriorityQueue keeps a priority queue of items with backoff (release after).
PriorityQueue deduplicates by item (T).
func (*PriorityQueue[T]) Len ¶
func (queue *PriorityQueue[T]) Len() int
Len returns the number of items in the queue.
func (*PriorityQueue[T]) Peek ¶
func (queue *PriorityQueue[T]) Peek(now time.Time) (item optional.Optional[T], nextDelay time.Duration)
Peek returns the top item from the queue if it is ready to be released at now.
If Peek returns optional.None, it also returns delay to get the next item from the queue. If there are no items in the queue, Peek returns optional.None and zero delay.
func (*PriorityQueue[T]) Pop ¶
func (queue *PriorityQueue[T]) Pop()
Pop removes the top item from the queue.
Pop should only be called if Peek returned optional.Some.
func (*PriorityQueue[T]) Push ¶
func (queue *PriorityQueue[T]) Push(item T, releaseAfter time.Time) bool
Push item to the queue with releaseAfter time.
If the item is not in the queue, it will be added. If the item is in the queue, and releaseAfter is greater than the existing releaseAfter, it will be re-added in the new position.
Push returns true if the item was added, and false if the existing item in the queue was updated (or skipped).
type SliceSet ¶
type SliceSet[T comparable] struct { // contains filtered or unexported fields }
SliceSet is a set implementation based on slices (for small number of items).