Documentation ¶
Index ¶
- Constants
- type Buffer
- func (b *Buffer) Add(m *rfc5424.Message) error
- func (b *Buffer) Close()
- func (b *Buffer) Read() []*rfc5424.Message
- func (b *Buffer) ReadAndSubscribe(msgc chan<- *rfc5424.Message, donec <-chan struct{}) []*rfc5424.Message
- func (b *Buffer) Subscribe(msgc chan<- *rfc5424.Message, donec <-chan struct{})
Constants ¶
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 ¶
Add adds an element to the Buffer. If the Buffer is already full, it removes an existing message.
func (*Buffer) Read ¶
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 ¶
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.