Documentation ¶
Index ¶
- Constants
- type FIFO
- func (st *FIFO) Dequeue() (event.NormalizedEvent, error)
- func (st *FIFO) DequeueOrWaitForNextElement() (event.NormalizedEvent, error)
- func (st *FIFO) Enqueue(value event.NormalizedEvent) error
- func (st *FIFO) Get(index int) (interface{}, error)
- func (st *FIFO) GetCap() int
- func (st *FIFO) GetLen() (v int)
- func (st *FIFO) IsLocked() bool
- func (st *FIFO) Lock()
- func (st *FIFO) Remove(index int) error
- func (st *FIFO) Unlock()
- type FixedFIFO
- func (st *FixedFIFO) Dequeue() (event.NormalizedEvent, error)
- func (st *FixedFIFO) DequeueOrWaitForNextElement() (event.NormalizedEvent, error)
- func (st *FixedFIFO) Enqueue(value event.NormalizedEvent) error
- func (st *FixedFIFO) GetCap() int
- func (st *FixedFIFO) GetLen() (v int)
- func (st *FixedFIFO) IsLocked() bool
- func (st *FixedFIFO) Lock()
- func (st *FixedFIFO) Unlock()
- type Queue
- type QueueError
Constants ¶
const ( QueueErrorCodeEmptyQueue = "empty-queue" QueueErrorCodeLockedQueue = "locked-queue" QueueErrorCodeIndexOutOfBounds = "index-out-of-bounds" QueueErrorCodeFullCapacity = "full-capacity" QueueErrorCodeInternalChannelClosed = "internal-channel-closed" )
const (
// WaitForNextElementChanCapacity specifies waitchan capacity
WaitForNextElementChanCapacity = 1000
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FIFO ¶
type FIFO struct {
// contains filtered or unexported fields
}
FIFO (First In First Out) concurrent queue
func (*FIFO) Dequeue ¶
func (st *FIFO) Dequeue() (event.NormalizedEvent, error)
Dequeue dequeues an element. Returns error if queue is locked or empty.
func (*FIFO) DequeueOrWaitForNextElement ¶
func (st *FIFO) DequeueOrWaitForNextElement() (event.NormalizedEvent, error)
DequeueOrWaitForNextElement dequeues an element (if exist) or waits until the next element gets enqueued and returns it. Multiple calls to DequeueOrWaitForNextElement() would enqueue multiple "listeners" for future enqueued elements.
func (*FIFO) Enqueue ¶
func (st *FIFO) Enqueue(value event.NormalizedEvent) error
Enqueue enqueues an element. Returns error if queue is locked.
func (*FIFO) Lock ¶
func (st *FIFO) Lock()
Lock // Locks the queue. No enqueue/dequeue operations will be allowed after this point.
type FixedFIFO ¶
type FixedFIFO struct {
// contains filtered or unexported fields
}
FixedFIFO is a fixed capacity FIFO (First In First Out) concurrent queue
func (*FixedFIFO) Dequeue ¶
func (st *FixedFIFO) Dequeue() (event.NormalizedEvent, error)
Dequeue dequeues an element. Returns error if: queue is locked, queue is empty or internal channel is closed.
func (*FixedFIFO) DequeueOrWaitForNextElement ¶
func (st *FixedFIFO) DequeueOrWaitForNextElement() (event.NormalizedEvent, error)
DequeueOrWaitForNextElement dequeues an element (if exist) or waits until the next element gets enqueued and returns it. Multiple calls to DequeueOrWaitForNextElement() would enqueue multiple "listeners" for future enqueued elements.
func (*FixedFIFO) Enqueue ¶
func (st *FixedFIFO) Enqueue(value event.NormalizedEvent) error
Enqueue enqueues an element. Returns error if queue is locked or it is at full capacity.
type Queue ¶
type Queue interface { // Enqueue element Enqueue(event.NormalizedEvent) error // Dequeue element Dequeue() (event.NormalizedEvent, error) // DequeueOrWaitForNextElement dequeues an element (if exist) or waits until the next element gets enqueued and returns it. // Multiple calls to DequeueOrWaitForNextElement() would enqueue multiple "listeners" for future enqueued elements. DequeueOrWaitForNextElement() (event.NormalizedEvent, error) // Get number of enqueued elements GetLen() int // Get queue's capacity GetCap() int // Lock the queue. No enqueue/dequeue/remove/get operations will be allowed after this point. Lock() // Unlock the queue. Unlock() // Return true whether the queue is locked IsLocked() bool }
Queue interface with basic && common queue functions
type QueueError ¶
type QueueError struct {
// contains filtered or unexported fields
}
func NewQueueError ¶
func NewQueueError(code string, message string) *QueueError
func (*QueueError) Code ¶
func (st *QueueError) Code() string
func (*QueueError) Error ¶
func (st *QueueError) Error() string