Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var MaxEntries *prometheus.GaugeVec
var ReadCalls *prometheus.CounterVec
var ReadEntries *prometheus.HistogramVec
var ReadsBlocked *prometheus.CounterVec
var UsedEntries *prometheus.GaugeVec
var WriteCalls *prometheus.CounterVec
var WriteEntries *prometheus.HistogramVec
var WritesBlocked *prometheus.CounterVec
Functions ¶
func InitMetrics ¶
func InitMetrics(namespace string, constLabels prometheus.Labels, labelNames []string)
Types ¶
type Ring ¶
type Ring struct {
// contains filtered or unexported fields
}
Ring is a classic generic ring buffer on top of a fixed-sized slice. It is thread-safe.
func New ¶
New allocates a new Ring instance, with capacity for count entries. If newf is non-nil, it is called count times to pre-allocate the entries. labels are attached to the prometheus metrics, and desc is added as an extra label. N.B. InitMetrics must be called before the first New call.
func (*Ring) Close ¶
func (r *Ring) Close()
Close closes the ring buffer, and causes all blocked readers/writers to be notified.
func (*Ring) Read ¶
Read copies entries from the internal ring buffer. If block is true, then Read will block until it is able to read at least one entry (or the Ring is closed). Otherwise it will return immediately if there's no entries available for reading. Returns the number of entries read, or -1 if the RingBuf is closed, and a bool indicating if the read blocked.
func (*Ring) Write ¶
Write copies entries to the internal ring buffer. If block is true, then Write will block until it is able to write at least one entry (or the Ring is closed). Otherwise it will return immediately if there's on space left for writing. Returns the number of entries written, or -1 if the RingBuf is closed, and a bool indicating if the write blocked.