stringforwarder

package
v0.0.0-...-2608902 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2016 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StringForwarder

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

StringForwarder is a goroutine-safe type that pipes messages from the its Forward() method, sending them to callback. The send is non-blocking and will discard messages if the last message has not finished processing. The number of discarded messages is tracked and returned when the forwarder is stopped.

func New

func New(callback func(string)) *StringForwarder

New returns a new StringForwarder that sends messages to the callback, function, dropping messages if the receiver is not ready.

func (*StringForwarder) Forward

func (f *StringForwarder) Forward(msg string)

Forward makes a non-blocking send of the message to the callback function. If the message is not received, it will increment the count of discarded messages. Forward is safe to call from multiple goroutines at once. Note that if this StringForwarder was created with a nil callback, all messages will be discarded.

func (*StringForwarder) Stop

func (f *StringForwarder) Stop() uint64

Stop cleans up the goroutine running behind StringForwarder and returns the count of discarded messages. Stop is thread-safe and may be called multiple times - after the first time, it simply returns the current discard count.

Jump to

Keyboard shortcuts

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