overlay

package
v0.0.0-...-ecfc0d7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2024 License: Apache-2.0 Imports: 7 Imported by: 3

Documentation

Index

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

type NetworkStarted struct {
	Func     func(Network) bool
	Priority int32
}

NetworkStarted is called right after network starts listening and handling messages.

type NetworkStopped

type NetworkStopped struct {
	Func     func(Network) bool
	Priority int32
}

NetworkStopped is called right after network stops listening and handling messages. It can be used to do some clean up, etc.

type NetworkWillStart

type NetworkWillStart struct {
	Func     func(Network) bool
	Priority int32
}

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

type NetworkWillStop struct {
	Func     func(Network) bool
	Priority int32
}

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

func NewOverlay(localNode *node.LocalNode) (*Overlay, error)

NewOverlay creates a new overlay network

func (*Overlay) AddRouter

func (ovl *Overlay) AddRouter(routingType pbmsg.RoutingType, router routing.Router) error

AddRouter adds a router for a routingType, and returns error if router has already benn added for the type

func (*Overlay) GetLocalNode

func (ovl *Overlay) GetLocalNode() *node.LocalNode

GetLocalNode returns the local node

func (*Overlay) GetRouter

func (ovl *Overlay) GetRouter(routingType pbmsg.RoutingType) (routing.Router, error)

GetRouter gets a router for a routingType, and returns error if router of the type has not benn added yet

func (*Overlay) GetRouters

func (ovl *Overlay) GetRouters() []routing.Router

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

func (ovl *Overlay) StartRouters() error

StartRouters starts all routers added to overlay network

func (*Overlay) StopRouters

func (ovl *Overlay) StopRouters(err error)

StopRouters stops all routers added to overlay network

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL