buffer

package
v0.0.0-...-1d4c075 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2016 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCapacity = 10000

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

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

Buffer is a linked list that holds rfc5424.Messages. The Buffer's entire contents can be read at once. Reading elements out of the buffer does not clear them; messages merely get removed from the buffer when they are replaced by new messages.

A Buffer also offers the ability to subscribe to new incoming messages.

func NewBuffer

func NewBuffer() *Buffer

NewBuffer returns an empty allocated Buffer with DefaultCapacity.

func (*Buffer) Add

func (b *Buffer) Add(m *rfc5424.Message) error

Add adds an element to the Buffer. If the Buffer is already full, it removes an existing message.

func (*Buffer) Close

func (b *Buffer) Close()

func (*Buffer) Read

func (b *Buffer) Read() []*rfc5424.Message

Read returns a copied slice with the contents of the Buffer. It does not modify the underlying buffer in any way. You are free to modify the returned slice without affecting Buffer, though modifying the individual elements in the result will also modify those elements in the Buffer.

func (*Buffer) ReadAndSubscribe

func (b *Buffer) ReadAndSubscribe(msgc chan<- *rfc5424.Message, donec <-chan struct{}) []*rfc5424.Message

ReadAndSubscribe returns all buffered messages just like Read, and also returns a channel that will stream new messages as they arrive.

func (*Buffer) Subscribe

func (b *Buffer) Subscribe(msgc chan<- *rfc5424.Message, donec <-chan struct{})

Subscribe returns a channel that sends all future messages added to the Buffer. The returned channel is buffered, and any attempts to send new messages to the channel will drop messages if the channel is full.

The caller closes the donec channel to stop receiving messages.

Jump to

Keyboard shortcuts

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