go-micro: github.com/micro/go-micro/util/ring Index | Files

package ring

import "github.com/micro/go-micro/util/ring"

Package ring provides a simple ring buffer for storing local data

Index

Package Files

buffer.go

type Buffer Uses

type Buffer struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

Buffer is ring buffer

func New Uses

func New(i int) *Buffer

New returns a new buffer of the given size

func (*Buffer) Get Uses

func (b *Buffer) Get(n int) []*Entry

Get returns the last n entries

func (*Buffer) Put Uses

func (b *Buffer) Put(v interface{})

Put adds a new value to ring buffer

func (*Buffer) Since Uses

func (b *Buffer) Since(t time.Time) []*Entry

Return the entries since a specific time

func (*Buffer) Size Uses

func (b *Buffer) Size() int

Size returns the size of the ring buffer

func (*Buffer) Stream Uses

func (b *Buffer) Stream() (<-chan *Entry, chan bool)

Stream logs from the buffer Close the channel when you want to stop

type Entry Uses

type Entry struct {
    Value     interface{}
    Timestamp time.Time
}

Entry is ring buffer data entry

type Stream Uses

type Stream struct {
    // Id of the stream
    Id  string
    // Buffered entries
    Entries chan *Entry
    // Stop channel
    Stop chan bool
}

Stream is used to stream the buffer

Package ring imports 3 packages (graph) and is imported by 12 packages. Updated 2019-12-18. Refresh now. Tools for package owners.