Documentation ¶
Overview ¶
Package relay is an implementation of relay mechanism. Proxy contains info about nodes which can relaying messages. Relay contains info about nodes of which messages current node have to relay.
Usage:
package relay relay := NewRelay() relay.AddClient(node) if relay.NeedToRelay(node.Address()) { //relay message } relay.RemoveClient(node) //----------------------------------- proxy := NewProxy() proxy.AddProxyNode(node.Address()) if proxy.ProxyNodesCount > 0 { address := proxy.GetNextProxyAddress //send message to next proxy } proxy.RemoveProxyNode(node.Address)
Index ¶
Constants ¶
View Source
const ( // Unknown unknown relay state. Unknown = State(iota + 1) // Started is relay type means relaying started. Started // Stopped is relay type means relaying stopped. Stopped // Error is relay type means error state change. Error // NoAuth - this error returns if node tries to send relay request but not authenticated. NoAuth )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Proxy ¶
type Proxy interface { // AddProxyNode add an address to proxy list. AddProxyNode(address string) // RemoveProxyNode removes proxy address from proxy list. RemoveProxyNode(address string) // GetNextProxyAddress returns a next address to send from proxy list. GetNextProxyAddress() string // ProxyNodesCount return added proxy count. ProxyNodesCount() int }
Proxy contains proxy addresses.
type Relay ¶
type Relay interface { // AddClient add client to relay list. AddClient(node *node.Node) error // RemoveClient removes client from relay list. RemoveClient(node *node.Node) error // ClientsCount - clients count. ClientsCount() int // NeedToRelay returns true if origin node is proxy for target node. NeedToRelay(targetAddress string) bool }
Relay Interface for relaying
Click to show internal directories.
Click to hide internal directories.