Documentation ¶
Index ¶
Constants ¶
const ( ZC_IN = iota ZC_OUT = iota )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChannelPair ¶
type ChannelPair struct {
// contains filtered or unexported fields
}
ChannelPair provides a structure that wraps a zeromq zmq.Socket and provides TX, RX and error channels.
This enables a zmq.Socket to be used in a threadsafe manner between goroutines in an idiomatic manner using channels.
This library relies completely on https://github.com/pebbe/zmq4 to provide the interface to zeromq.
See NewChannelPair for more details.
func NewChannelPair ¶
NewChannelPair produces a new ChannelPair. Pass a zmq.Socket, plus the buffering parameters for the channels.
If this call succeeds (i.e. if a nil error is returned), then a ChannelPair is returned, and control of your zmq.Socket is passed irrevocably to this routine. You should forget you ever had the socket. Do not attempt to use it in any way, as its manipulation is now the responsibility of goroutines launched by this routine. Closing the ChannelPair will also close your zmq.Socket.
If this routine errors, it is the caller's responsibility to close the zmq.Socket.
The buffering parameters control the maximum amount of buffered data, in and out. An extra message may be buffered under some circumstances for internal reasons.
func (*ChannelPair) Close ¶
func (cp *ChannelPair) Close() error
Close closes a ChannelPair. This will kill the internal goroutines, and close the main zmq.Socket. It will also close the error channel, so a select() on it will return 'ok' as false. If an error is produced either during the close or has been produced prior to the close, it will be returned.
func (*ChannelPair) Errors ¶
func (cp *ChannelPair) Errors() <-chan error
Errors get the errors channel as a read-only channel.
func (*ChannelPair) RxChan ¶
func (cp *ChannelPair) RxChan() <-chan [][]byte
RxChan gets the RX channel as a read-only channel.
func (*ChannelPair) TxChan ¶
func (cp *ChannelPair) TxChan() chan<- [][]byte
TxChan gets the TX channel as a write-only channel.