Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PriorityQueue ¶
type PriorityQueue struct {
// contains filtered or unexported fields
}
PriorityQueue is a priority queue of events that implements heap.Interface. Events are ordered based on their timestamp value, the oldest event having the higher priority.
This implementation is loosely based on the priority queue example in "container/heap".
func NewPriorityQueue ¶
func NewPriorityQueue(n int) *PriorityQueue
NewPriorityQueue creates a new PriorityQueue with initial capacity n.
func (PriorityQueue) Len ¶
func (pq PriorityQueue) Len() int
Len is the number of events in the queue.
func (*PriorityQueue) Pop ¶
func (pq *PriorityQueue) Pop() *v1.Event
Pop removes and returns the oldest event in the queue. Pop returns nil if the queue is empty.
func (*PriorityQueue) Push ¶
func (pq *PriorityQueue) Push(e *v1.Event)
Push adds event e to the queue.
type Ring ¶
type Ring struct {
// contains filtered or unexported fields
}
Ring is a ring buffer that stores *v1.Event
func NewRing ¶
NewRing creates a ring buffer. For efficiency, the internal buffer length will be a bitmask of ones + 1. The most significant bit position of this bitmask will be same position of the most significant bit position of 'n'. E.g.:
NewRing(254) -> internal buffer length: 256 NewRing(255) -> internal buffer length: 256 NewRing(256) -> internal buffer length: 512
func (*Ring) LastWrite ¶
LastWrite returns the last element written. Note: If Write(*v1.Event) is being executed concurrently with Read(uint64) please use LastWriteParallel instead.
func (*Ring) LastWriteParallel ¶
LastWriteParallel returns the last element written.
type RingReader ¶
type RingReader struct {
// contains filtered or unexported fields
}
RingReader is a reader for a Ring container.
func NewRingReader ¶
func NewRingReader(ring *Ring, start uint64) *RingReader
NewRingReader creates a new RingReader that starts reading the ring at the position given by start.
func (*RingReader) Next ¶
func (r *RingReader) Next() *v1.Event
Next reads the event at the current position and increment the read position. When no more event can be read, Next returns nil.
func (*RingReader) NextFollow ¶
func (r *RingReader) NextFollow(ctx context.Context) *v1.Event
NextFollow reads the event at the current position and increment the read position by one. If there are no more event to read, NextFollow blocks until the next event is added to the ring or the context is cancelled.
func (*RingReader) Previous ¶
func (r *RingReader) Previous() *v1.Event
Previous reads the event at the current position and decrement the read position. When no more event can be read, Previous returns nil.