cooldownqueue

package
v0.2.253 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

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()

Jump to

Keyboard shortcuts

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