Documentation ¶
Overview ¶
Package pipe provides types to help manage transporter communication channels as well as event types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mock ¶
type Mock struct {
MsgCount int
}
Mock serves as a pipe used to count the number of messages sent to writeMessage.
type Pipe ¶
type Pipe struct { In messageChan Out []messageChan Err chan error Event chan events.Event Stopped bool // has the pipe been stopped? MessageCount int LastMsg message.Msg ExtraState map[string]interface{} // contains filtered or unexported fields }
Pipe provides a set of methods to let transporter nodes communicate with each other.
Pipes contain In, Out, Err, and Event channels. Messages are consumed by a node through the 'in' chan, emitted from the node by the 'out' chan. Pipes come in three flavours, a sourcePipe, which only emits messages and has no listening loop, a sinkPipe which has a listening loop, but doesn't emit any messages, and joinPipe which has a li tening loop that also emits messages.
func NewPipe ¶
NewPipe creates a new Pipe. If the pipe that is passed in is nil, then this pipe will be treaded as a source pipe that just serves to emit messages. Otherwise, the pipe returned will be created and chained from the last member of the Out slice of the parent. This function has side effects, and will add an Out channel to the pipe that is passed in
func (*Pipe) Listen ¶
Listen starts a listening loop that pulls messages from the In chan, applies fn(msg), a `func(message.Msg) error`, and emits them on the Out channel. Errors will be emitted to the Pipe's Err chan, and will terminate the loop. The listening loop can be interrupted by calls to Stop().