Documentation ¶
Index ¶
- Variables
- type BoundedQueue
- func (q *BoundedQueue) Capacity() int
- func (q *BoundedQueue) Produce(item interface{}) bool
- func (q *BoundedQueue) SetFilterItemFunc(filter func(item interface{}) bool)
- func (q *BoundedQueue) Size() int
- func (q *BoundedQueue) StartConsumers(num int, consumer func(item interface{}))
- func (q *BoundedQueue) StartLengthReporting(reportPeriod time.Duration)
- func (q *BoundedQueue) Stop()
Constants ¶
This section is empty.
Variables ¶
var ( TotalEventsDroppedCount = prometheus.NewCounterVec( prometheus.CounterOpts{ Name: "lunettes_total_events_dropped_count", Help: "total events dropped so far", }, []string{"name"}, ) )
Functions ¶
This section is empty.
Types ¶
type BoundedQueue ¶
type BoundedQueue struct { IsLockOSThread bool IsDropEventOnFull bool // contains filtered or unexported fields }
func NewBoundedQueue ¶
func NewBoundedQueue(name string, capacity int, onDroppedItem func(item interface{})) *BoundedQueue
NewBoundedQueue constructs the new queue of specified capacity, and with an optional callback for dropped items (e.g. useful to emit metrics).
func (*BoundedQueue) Capacity ¶
func (q *BoundedQueue) Capacity() int
Capacity returns capacity of the queue
func (*BoundedQueue) Produce ¶
func (q *BoundedQueue) Produce(item interface{}) bool
Produce is used by the producer to submit new item to the queue. Returns false in case of queue overflow.
func (*BoundedQueue) SetFilterItemFunc ¶
func (q *BoundedQueue) SetFilterItemFunc(filter func(item interface{}) bool)
func (*BoundedQueue) Size ¶
func (q *BoundedQueue) Size() int
Size returns the current size of the queue
func (*BoundedQueue) StartConsumers ¶
func (q *BoundedQueue) StartConsumers(num int, consumer func(item interface{}))
StartConsumers starts a given number of goroutines consuming items from the queue and passing them into the consumer callback.
func (*BoundedQueue) StartLengthReporting ¶
func (q *BoundedQueue) StartLengthReporting(reportPeriod time.Duration)
StartLengthReporting starts a timer-based gorouting that periodically reports current queue length to a given metrics gauge.
func (*BoundedQueue) Stop ¶
func (q *BoundedQueue) Stop()
Stop stops all consumers, as well as the length reporter if started, and releases the items channel. It blocks until all consumers have stopped.