Documentation ¶
Overview ¶
Package zyre provides reliable group messaging over local area networks.
For more informations, see https://zeromq.org.
Index ¶
- Constants
- func Send(socket zmq.Socket, msg *ZreMsg) error
- func SetEvasive(evasive time.Duration)
- func SetExpired(expired time.Duration)
- type Beacon
- type BeaconMsg
- type Cmd
- type ConnData
- type Connection
- type Event
- type Group
- type IPv4Conn
- type IPv6Conn
- type Peer
- type Signal
- type ZreMsg
- type Zyre
- func (zyre *Zyre) Events() chan *Event
- func (zyre *Zyre) Join(group string)
- func (zyre *Zyre) Leave(group string)
- func (zyre *Zyre) Name() string
- func (zyre *Zyre) Peers() []string
- func (zyre *Zyre) SetHeader(name string, format string, args ...interface{}) *Zyre
- func (zyre *Zyre) SetInterface(iface string) *Zyre
- func (zyre *Zyre) SetInterval(interval time.Duration) *Zyre
- func (zyre *Zyre) SetName(name string) *Zyre
- func (zyre *Zyre) SetPort(port int) *Zyre
- func (zyre *Zyre) SetVerbose() *Zyre
- func (zyre *Zyre) Shout(group string, payload []byte)
- func (zyre *Zyre) Shouts(group string, format string, args ...interface{})
- func (zyre *Zyre) Start() error
- func (zyre *Zyre) Stop()
- func (zyre *Zyre) UUID() string
- func (zyre *Zyre) Whisper(peer string, payload []byte)
- func (zyre *Zyre) Whispers(peer string, format string, args ...interface{})
Constants ¶
const ( // Signature of the message Signature uint16 = 0xAAA0 | 1 // Version number Version byte = 2 )
const ( HelloID uint8 = 1 WhisperID uint8 = 2 ShoutID uint8 = 3 JoinID uint8 = 4 LeaveID uint8 = 5 PingID uint8 = 6 PingOkID uint8 = 7 )
Message IDs
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Beacon ¶
type Beacon struct { Signals chan *Signal Cmds chan *Cmd Replies chan *Cmd // contains filtered or unexported fields }
Beacon defines main structure of the application
type BeaconMsg ¶
BeaconMsg frame has this format:
Z R E 3 bytes version 1 byte 0x01 | 0x03 UUID 16 bytes port 2 bytes in network order
type ConnData ¶
type ConnData struct {
// contains filtered or unexported fields
}
ConnData common data for ipv4 and ipv6
type Connection ¶
type Connection interface { Close() error Addr() string JoinGroup(ifi *net.Interface) error ReadFrom(buff []byte) (n int, src net.IP, err error) WriteTo(buff []byte) error }
Connection defines a common interface for ipv4 and ipv6
type Event ¶
type Event struct { Type string // Event type PeerUUID string // Sender UUID as string PeerName string // Sender public name as string PeerAddr string // Sender ipaddress as string, for an ENTER event Headers map[string]string // Headers, for an ENTER event Group string // Group name for a SHOUT event Msg []byte // Message payload for SHOUT or WHISPER }
Event zyre event
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group group known to this node
type IPv4Conn ¶
type IPv4Conn struct { ConnData // contains filtered or unexported fields }
IPv4Conn IPv4 connection
type IPv6Conn ¶
type IPv6Conn struct { ConnData // contains filtered or unexported fields }
IPv6Conn IPv6 connection
type Peer ¶
type Peer struct { Identity string // Identity UUID Name string // Peer's public name Headers map[string]string // Peer headers // contains filtered or unexported fields }
Peer one of our peers in a ZRE network
func (*Peer) Connect ¶
Connect peer mailbox Configures mailbox and connects to peer's router endpoint
func (*Peer) Disconnect ¶
func (p *Peer) Disconnect()
Disconnect peer mailbox No more messages will be sent to peer until connected again
func (*Peer) MessagesLost ¶
MessagesLost check if messages were lost from peer, returns true if they were FIXME not same implementation as zyre or pyre
type ZreMsg ¶
type ZreMsg struct { Endpoint string // Sender connect endpoint Groups []string // List of groups sender is in Status byte // Sender groups status value Name string // Sender public name Headers map[string]string // Sender header properties Content []byte // Wrapped message content Group string // Name of Group // contains filtered or unexported fields }
ZreMsg work with ZRE messages
type Zyre ¶
type Zyre struct {
// contains filtered or unexported fields
}
Zyre structure
func NewZyre ¶
NewZyre creates a new Zyre node. Note that until you start the node it is silent and invisible to other nodes on the network. The node name is provided to other nodes during discovery.
func (*Zyre) Events ¶
Events returns a channel of events. The events may be a control event (ENTER, EXIT, JOIN, LEAVE) or data (WHISPER, SHOUT).
func (*Zyre) Join ¶
Join a named group; after joining a group you can send messages to the group and all Zyre nodes in that group will receive them.
func (*Zyre) Name ¶
Name returns our node name, after successful initialization. By default is taken from the UUID and shortened.
func (*Zyre) SetHeader ¶
SetHeader sets node header; these are provided to other nodes during discovery and come in each ENTER message.
func (*Zyre) SetInterface ¶
SetInterface sets network interface for UDP beacons. If you do not set this, CZMQ will choose an interface for you. On boxes with several interfaces you should specify which one you want to use, or strange things can happen.
func (*Zyre) SetInterval ¶
SetInterval sets UDP beacon discovery interval. Default is instant beacon exploration followed by pinging every 1000 msecs.
func (*Zyre) SetPort ¶
SetPort sets UDP beacon discovery port; defaults to 5670, this call overrides that so you can create independent clusters on the same network, for e.zyre. development vs. production. Has no effect after zyre.Start(). FIXME make sure it has no effect after zyre.Start()
func (*Zyre) SetVerbose ¶
SetVerbose sets verbose mode; this tells the node to log all traffic as well as all major events.
func (*Zyre) Start ¶
Start node, after setting header values. When you start a node it begins discovery and connection. Returns nil if OK, error if it wasn't possible to start the node.
func (*Zyre) Stop ¶
func (zyre *Zyre) Stop()
Stop node; this signals to other peers that this node will go away. This is polite; however you can also just destroy the node without stopping it.