Documentation ¶
Index ¶
- type Network
- type NetworkStarted
- type NetworkStopped
- type NetworkWillStart
- type NetworkWillStop
- type Overlay
- func (ovl *Overlay) AddRouter(routingType pbmsg.RoutingType, router routing.Router) error
- func (ovl *Overlay) GetLocalNode() *node.LocalNode
- func (ovl *Overlay) GetRouter(routingType pbmsg.RoutingType) (routing.Router, error)
- func (ovl *Overlay) GetRouters() []routing.Router
- func (ovl *Overlay) SendMessage(msg *pbmsg.Message, routingType pbmsg.RoutingType, hasReply bool, ...) (<-chan *node.RemoteMessage, bool, error)
- func (ovl *Overlay) SendMessageAsync(msg *pbmsg.Message, routingType pbmsg.RoutingType) (bool, error)
- func (ovl *Overlay) SendMessageSync(msg *pbmsg.Message, routingType pbmsg.RoutingType, replyTimeout time.Duration) (*pbmsg.Message, bool, error)
- func (ovl *Overlay) SetRouter(routingType pbmsg.RoutingType, router routing.Router)
- func (ovl *Overlay) StartRouters() error
- func (ovl *Overlay) StopRouters(err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Network ¶
type Network interface { Start(isCreate bool) error Stop(error) Join(seedNodeAddr string) error GetLocalNode() *node.LocalNode GetRouters() []routing.Router ApplyMiddleware(interface{}) error SendMessageAsync(msg *pbmsg.Message, routingType pbmsg.RoutingType) (success bool, err error) SendMessageSync(msg *pbmsg.Message, routingType pbmsg.RoutingType, replyTimeout time.Duration) (reply *pbmsg.Message, success bool, err error) }
Network is the overlay network interface
type NetworkStarted ¶
NetworkStarted is called right after network starts listening and handling messages.
type NetworkStopped ¶
NetworkStopped is called right after network stops listening and handling messages. It can be used to do some clean up, etc.
type NetworkWillStart ¶
NetworkWillStart is called right before network starts listening and handling messages. It can be used to do additional network setup like NAT traversal.
type NetworkWillStop ¶
NetworkWillStop is called right before network stops listening and handling messages.
type Overlay ¶
type Overlay struct { LocalNode *node.LocalNode LocalMsgChan chan *node.RemoteMessage common.LifeCycle // contains filtered or unexported fields }
Overlay is an abstract overlay network
func NewOverlay ¶
NewOverlay creates a new overlay network
func (*Overlay) AddRouter ¶
AddRouter adds a router for a routingType, and returns error if router has already benn added for the type
func (*Overlay) GetLocalNode ¶
GetLocalNode returns the local node
func (*Overlay) GetRouter ¶
GetRouter gets a router for a routingType, and returns error if router of the type has not benn added yet
func (*Overlay) GetRouters ¶
GetRouters gets a list of routers added
func (*Overlay) SendMessage ¶
func (ovl *Overlay) SendMessage(msg *pbmsg.Message, routingType pbmsg.RoutingType, hasReply bool, replyTimeout time.Duration) (<-chan *node.RemoteMessage, bool, error)
SendMessage sends msg to the best next hop, returns reply chan (nil if if hasReply is false), if send success (which is true if successfully send message to at least one next hop), and aggregated errors during message sending.
func (*Overlay) SendMessageAsync ¶
func (ovl *Overlay) SendMessageAsync(msg *pbmsg.Message, routingType pbmsg.RoutingType) (bool, error)
SendMessageAsync sends msg to the best next hop, returns if send success (which is true if successfully send message to at least one next hop), and aggretated error during message sending
func (*Overlay) SendMessageSync ¶
func (ovl *Overlay) SendMessageSync(msg *pbmsg.Message, routingType pbmsg.RoutingType, replyTimeout time.Duration) (*pbmsg.Message, bool, error)
SendMessageSync sends msg to the best next hop, returns reply message, if send success (which is true if successfully send message to at least one next hop), and aggregated error during message sending, will also returns error if haven't receive reply within replyTimeout. Will use default reply timeout if replyTimeout = 0.
func (*Overlay) SetRouter ¶
func (ovl *Overlay) SetRouter(routingType pbmsg.RoutingType, router routing.Router)
SetRouter sets a router for a routingType regardless of whether a router has been set up for this type or not
func (*Overlay) StartRouters ¶
StartRouters starts all routers added to overlay network
func (*Overlay) StopRouters ¶
StopRouters stops all routers added to overlay network