Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrClosed = fmt.Errorf("closed")
ErrClosed is used to indicate the ringbuffer has been closed.
Functions ¶
Types ¶
type LogBuffer ¶
type LogBuffer struct {
// contains filtered or unexported fields
}
LogBuffer is uses to cache the container's logs with ringBuffer.
func (*LogBuffer) WriteLogMessage ¶
func (bl *LogBuffer) WriteLogMessage(msg *logger.LogMessage) error
WriteLogMessage will write the LogMessage to the ringBuffer.
type RingBuffer ¶
type RingBuffer struct {
// contains filtered or unexported fields
}
RingBuffer implements a fixed-size buffer which will drop oldest data if full.
func NewRingBuffer ¶
func NewRingBuffer(maxBytes int64) *RingBuffer
NewRingBuffer creates new RingBuffer.
func (*RingBuffer) Drain ¶
func (rb *RingBuffer) Drain() []*logger.LogMessage
Drain returns all the data in the buffer.
NOTE: it can be used after closed to make sure the data have been consumed.
func (*RingBuffer) Pop ¶
func (rb *RingBuffer) Pop() (*logger.LogMessage, error)
Pop pops the value in the buffer.
NOTE: it returns ErrClosed if the buffer has been closed.
func (*RingBuffer) Push ¶
func (rb *RingBuffer) Push(val *logger.LogMessage) error
Push pushes value into buffer and return whether it covers the oldest data or not.
Click to show internal directories.
Click to hide internal directories.