Documentation
¶
Index ¶
- Constants
- type FIFO
- func (st *FIFO) Dequeue() (interface{}, error)
- func (st *FIFO) DequeueOrWaitForNextElement() (interface{}, error)
- func (st *FIFO) DequeueOrWaitForNextElementContext(ctx context.Context) (interface{}, error)
- func (st *FIFO) Enqueue(value interface{}) error
- func (st *FIFO) Get(index int) (interface{}, error)
- func (st *FIFO) GetCap() int
- func (st *FIFO) GetLen() 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() (interface{}, error)
- func (st *FixedFIFO) DequeueOrWaitForNextElement() (interface{}, error)
- func (st *FixedFIFO) DequeueOrWaitForNextElementContext(ctx context.Context) (interface{}, error)
- func (st *FixedFIFO) Enqueue(value interface{}) error
- func (st *FixedFIFO) GetCap() int
- func (st *FixedFIFO) GetLen() 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 = 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) DequeueOrWaitForNextElement ¶
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) DequeueOrWaitForNextElementContext ¶
DequeueOrWaitForNextElementContext dequeues an element (if exist) or waits until the next element gets enqueued and returns it. Multiple calls to DequeueOrWaitForNextElementContext() would enqueue multiple "listeners" for future enqueued elements. When the passed context expires this function exits and returns the context' error
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
}
Fixed capacity FIFO (First In First Out) concurrent queue
func NewFixedFIFO ¶
func (*FixedFIFO) Dequeue ¶
Dequeue dequeues an element. Returns error if: queue is locked, queue is empty or internal channel is closed.
func (*FixedFIFO) DequeueOrWaitForNextElement ¶
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) DequeueOrWaitForNextElementContext ¶
DequeueOrWaitForNextElementContext dequeues an element (if exist) or waits until the next element gets enqueued and returns it. Multiple calls to DequeueOrWaitForNextElementContext() would enqueue multiple "listeners" for future enqueued elements. When the passed context expires this function exits and returns the context' error
func (*FixedFIFO) Enqueue ¶
Enqueue enqueues an element. Returns error if queue is locked or it is at full capacity.
type Queue ¶
type Queue interface {
// Enqueue element
Enqueue(interface{}) error
// Dequeue element
Dequeue() (interface{}, 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() (interface{}, error)
// DequeueOrWaitForNextElementContext dequeues an element (if exist) or waits until the next element gets enqueued and returns it.
// Multiple calls to DequeueOrWaitForNextElementContext() would enqueue multiple "listeners" for future enqueued elements.
// When the passed context expires this function exits and returns the context' error
DequeueOrWaitForNextElementContext(context.Context) (interface{}, 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

