Documentation
¶
Index ¶
Constants ¶
View Source
const ( DefaultExpiration = 5 * time.Second EvictionInterval = 1 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CooldownQueue ¶
type CooldownQueue[T any] struct { // contains filtered or unexported fields }
CooldownQueue is a queue that lets clients put events into it with a cooldown
When a client puts an event into a queue, it waits for a cooldown period before the event is forwarded to the consumer. If and event for the same key is put into the queue again before the cooldown period is over, the event is overridden and the cooldown period is reset.
func NewCooldownQueue ¶
func NewCooldownQueue[T any](cooldown time.Duration, evictionInterval time.Duration) *CooldownQueue[T]
NewCooldownQueue returns a new Cooldown Queue
func (*CooldownQueue[T]) Closed ¶
func (q *CooldownQueue[T]) Closed() bool
func (*CooldownQueue[T]) Enqueue ¶
func (q *CooldownQueue[T]) Enqueue(e T, key string)
Enqueue enqueues an event in the Cooldown Queue
func (*CooldownQueue[T]) ResultChan ¶
func (q *CooldownQueue[T]) ResultChan() <-chan T
ResultChan returns a read-only channel for consuming events.
func (*CooldownQueue[T]) Stop ¶
func (q *CooldownQueue[T]) Stop()
Click to show internal directories.
Click to hide internal directories.