Documentation ¶
Overview ¶
Package gyre is Golang port of Zyre, an open-source framework for proximity-based peer-to-peer applications. Gyre does local area discovery and clustering. A Gyre node broadcasts UDP beacons, and connects to peers that it finds. This class wraps a Gyre node with a message-based API.
Index ¶
- func SetEvasive(evasive time.Duration)
- func SetExpired(expired time.Duration)
- func SetLoopInterval(interval time.Duration)
- type Event
- type EventType
- type Gyre
- func (g *Gyre) Addr() (string, error)
- func (g *Gyre) Dump() error
- func (g *Gyre) Events() chan *Event
- func (g *Gyre) GossipBind(endpoint string) error
- func (g *Gyre) GossipConnect(endpoint string) error
- func (g *Gyre) GossipPort() (string, error)
- func (g *Gyre) Header(key string) (string, bool)
- func (g *Gyre) Headers() (map[string]string, error)
- func (g *Gyre) Join(group string) error
- func (g *Gyre) Leave(group string) error
- func (g *Gyre) Name() string
- func (g *Gyre) SetEndpoint(endpoint string) error
- func (g *Gyre) SetHeader(name string, format string, args ...interface{}) error
- func (g *Gyre) SetInterface(iface string) error
- func (g *Gyre) SetInterval(interval time.Duration) error
- func (g *Gyre) SetName(name string) error
- func (g *Gyre) SetPort(port int) error
- func (g *Gyre) SetVerbose() error
- func (g *Gyre) Shout(group string, payload []byte) error
- func (g *Gyre) Shouts(group string, format string, args ...interface{}) error
- func (g *Gyre) Start() error
- func (g *Gyre) Stop() error
- func (g *Gyre) UUID() string
- func (g *Gyre) Whisper(peer string, payload []byte) error
- func (g *Gyre) Whispers(peer string, format string, args ...interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetLoopInterval ¶
SetLoopInterval sets interval of checking health of other peers
Types ¶
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event represents an event which contains information about the sender and the group it belongs.
type Gyre ¶
type Gyre struct {
// contains filtered or unexported fields
}
Gyre structure
func New ¶
New creates a new Gyre node. Note that until you start the node it is silent and invisible to other nodes on the network.
func (*Gyre) Addr ¶
Addr returns our address. Note that it will return empty string if called before Start() method.
func (*Gyre) Events ¶
Events returns a channel of events. The events may be a control event (ENTER, EXIT, JOIN, LEAVE) or data (WHISPER, SHOUT).
func (*Gyre) GossipBind ¶
GossipBind Sets up gossip discovery of other nodes. At least one node in the cluster must bind to a well-known gossip endpoint, so other nodes can connect to it. Note that gossip endpoints are completely distinct from Gyre node endpoints, and should not overlap (they can use the same transport).
func (*Gyre) GossipConnect ¶
GossipConnect Sets up gossip discovery of other nodes. A node may connect to multiple other nodes, for redundancy paths.
func (*Gyre) GossipPort ¶
GossipPort returns the port number that gossip engine is bound to
func (*Gyre) Join ¶
Join a named group; after joining a group you can send messages to the group and all Gyre nodes in that group will receive them.
func (*Gyre) Name ¶
Name returns our node name, after successful initialization. By default is taken from the UUID and shortened.
func (*Gyre) SetEndpoint ¶
SetEndpoint sets the endpoint. By default, Gyre binds to an ephemeral TCP port and broadcasts the local host name using UDP beaconing. When you call this method, Gyre will use gossip discovery instead of UDP beaconing. You MUST set-up the gossip service separately using GossipBind() and GossipConnect(). Note that the endpoint MUST be valid for both bind and connect operations. You can use inproc://, ipc://, or tcp:// transports (for tcp://, use an IP address that is meaningful to remote as well as local nodes).
func (*Gyre) SetHeader ¶
SetHeader sets node header; these are provided to other nodes during discovery and come in each ENTER message.
func (*Gyre) SetInterface ¶
SetInterface sets network interface to use for beacons and interconnects. If you do not set this, Gyre will choose an interface for you. On boxes with multiple interfaces you really should specify which one you want to use, or strange things can happen.
func (*Gyre) SetInterval ¶
SetInterval sets ZRE discovery interval. Default is instant beacon exploration followed by pinging every 1,000 msecs.
func (*Gyre) SetName ¶
SetName sets node name; this is provided to other nodes during discovery. If you do not set this, the UUID is used as a basis.
func (*Gyre) SetPort ¶
SetPort sets ZRE discovery port; defaults to 5670, this call overrides that so you can create independent clusters on the same network, for e.g development vs production.
func (*Gyre) SetVerbose ¶
SetVerbose sets verbose mode; this tells the node to log all traffic as well as all major events.
func (*Gyre) Start ¶
Start starts a node, after setting header values. When you start a node it begins discovery and connection. Returns nil if OK, and error if it wasn't possible to start the node.
func (*Gyre) Stop ¶
Stop stops a 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.
Directories ¶
Path | Synopsis |
---|---|
Package beacon implements a peer-to-peer discovery service for local networks.
|
Package beacon implements a peer-to-peer discovery service for local networks. |
cmd
|
|
monitor
Monitors ZRE network traffic Usage: monitor [Options] Examples: monitor -group GROUP_NAME Options: Usage of monitor: -group="*": The group we are going to join.
|
Monitors ZRE network traffic Usage: monitor [Options] Examples: monitor -group GROUP_NAME Options: Usage of monitor: -group="*": The group we are going to join. |
Examples directory contains example applications written with Gyre framework.
|
Examples directory contains example applications written with Gyre framework. |
chat
Chat example is a simple chat application to demonstrate the Gyre API.
|
Chat example is a simple chat application to demonstrate the Gyre API. |
chat-gossip
Chat example is a simple chat application to demonstrate the Gyre API.
|
Chat example is a simple chat application to demonstrate the Gyre API. |
ping
Ping other peers in a ZRE network Usage: ping [Options] Examples: ping -group GRP Options: Usage of ping: -group="GLOBAL": The group we are going to join -verbose=false: Set verbose flag
|
Ping other peers in a ZRE network Usage: ping [Options] Examples: ping -group GRP Options: Usage of ping: -group="GLOBAL": The group we are going to join -verbose=false: Set verbose flag |
Package shm provides a neat way of storing key-val data.
|
Package shm provides a neat way of storing key-val data. |
zre
|
|
msg
Package msg is 100% generated.
|
Package msg is 100% generated. |