ring_buffer

package
v0.0.0-...-c1642f7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MessageBuffer

type MessageBuffer struct {
	// contains filtered or unexported fields
}

MessageBuffer wraps ring.Ring for creating ring buffer

func NewMessageBuffer

func NewMessageBuffer(n int) *MessageBuffer

NewMessageBuffer creates new instance of MessageBuffer with n buffer length

func (*MessageBuffer) AddCell

func (mb *MessageBuffer) AddCell(r *RingCell)

AddCell writes value to the ring item after Current it may rewrite existing ring item value

func (*MessageBuffer) EraseCell

func (mb *MessageBuffer) EraseCell()

EraseCell deletes value from current ring item and sets Current to previous

func (*MessageBuffer) GetCurrent

func (mb *MessageBuffer) GetCurrent() (*RingCell, *ring.Ring, bool)

GetCurrent gets current ring cell Value, pointer to current cell and bool that indicates if Value was not nil

func (*MessageBuffer) GetNewestCell

func (mb *MessageBuffer) GetNewestCell() (*RingCell, *ring.Ring, bool)

GetNewestCell returns newest (by timestamp) ring value, pointer to current ring item and true if (non-nil) value was found; returns false otherwise; mostly for debug purposes

func (*MessageBuffer) GetOldestCell

func (mb *MessageBuffer) GetOldestCell() (*RingCell, *ring.Ring, bool)

GetOldestCell returns newest (by timestamp) ring value, pointer to current ring item and true if value was found; returns false otherwise; mostly for debug purposes

func (*MessageBuffer) SetCurrent

func (mb *MessageBuffer) SetCurrent(r *ring.Ring)

SetCurrent sets ring current position

type RingCell

type RingCell struct {
	LogParams types.LogParams
	Message   string
	// contains filtered or unexported fields
}

RingCell is a type of value stored in MessageBuffer

func NewCell

func NewCell(lp types.LogParams, m string) *RingCell

NewCell creates new value for ring buffer item

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL