middleware

package
v0.10.1-collection-patch Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2020 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection interface {
	Send(msg interface{}) error
	Receive() (interface{}, error)
}

Connection represents an interface to read from & write to a connection.

type Middleware

type Middleware interface {
	// Start will start the middleware.
	Start(overlay Overlay) error

	// Stop will end the execution of the middleware and wait for it to end.
	Stop()

	// Send sends the message to the set of target ids
	// If there is only one target NodeID, then a direct 1-1 connection is used by calling middleware.sendDirect
	// Otherwise, middleware.Publish is used, which uses the PubSub method of communication.
	//
	// Deprecated: Send exists for historical compatibility, and should not be used on new
	// developments. It is planned to be cleaned up in near future. Proper utilization of Dispatch or
	// Publish are recommended instead.
	Send(channelID string, msg *message.Message, targetIDs ...flow.Identifier) error

	// Dispatch sends msg on a 1-1 direct connection to the target ID. It models a guaranteed delivery asynchronous
	// direct one-to-one connection on the underlying network. No intermediate node on the overlay is utilized
	// as the router.
	//
	// Dispatch should be used whenever guaranteed delivery to a specific target is required. Otherwise, Publish is
	// a more efficient candidate.
	SendDirect(msg *message.Message, targetID flow.Identifier) error

	// Publish publishes msg on the channel. It models a distributed broadcast where the message is meant for all or
	// a many nodes subscribing to the channel ID. It does not guarantee the delivery though, and operates on a best
	// effort.
	Publish(msg *message.Message, channelID string) error

	// Subscribe will subscribe the middleware for a topic with the fully qualified channel ID name
	Subscribe(channelID string) error

	// Unsubscribe will unsubscribe the middleware for a topic with the fully qualified channel ID name
	Unsubscribe(channelID string) error

	// Ping pings the target node and returns the ping RTT or an error
	Ping(targetID flow.Identifier) (time.Duration, error)

	// UpdateAllowList fetches the most recent identity of the nodes from overlay
	// and updates the underlying libp2p node.
	UpdateAllowList() error
}

Middleware represents the middleware layer, which manages the connections to our direct neighbours on the network. It handles the creation & teardown of connections, as well as reading & writing to/from the connections.

type Overlay

type Overlay interface {
	// Topology returns the identities of a uniform subset of nodes in protocol state
	Topology() (map[flow.Identifier]flow.Identity, error)
	// Identity returns a map of all identifier to flow identity
	Identity() (map[flow.Identifier]flow.Identity, error)
	Receive(nodeID flow.Identifier, msg *message.Message) error
}

Overlay represents the interface that middleware uses to interact with the overlay network layer.

Jump to

Keyboard shortcuts

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