overlay

package
v0.0.0-...-38a8f93 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2021 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LocalNode

type LocalNode interface {
	// AddTrader is called when a new local virtual node joins the overlay.
	AddTrader(guid []byte)
	// GUID returns the node's GUID.
	GUID() string
}

LocalNode exposes the overlay to the application node.

type Overlay

type Overlay interface {
	// Create/Bootstrap the overlay in the current node.
	Create(ctx context.Context, thisNode LocalNode) error

	// Join an overlay given a participant node IP and the respective port where its overlay daemon is listening.
	Join(ctx context.Context, overlayNodeIP string, overlayNodePort int, thisNode LocalNode) error

	// Get a list of remote nodes using a given key.
	Lookup(ctx context.Context, key []byte) ([]*OverlayNode, error)

	// Get a list of the neighbors nodes of the given node.
	Neighbors(ctx context.Context, nodeID []byte) ([]*OverlayNode, error)

	// Unique identifier for the physical node where the overlay is running.
	// The overlay can have virtual nodes here we only want return always one ID that is unique in all nodes.
	NodeID(ctx context.Context) ([]byte, error)

	// Leave the overlay.
	Leave(ctx context.Context) error
}

Overlay represents an API for a distributed overlay of nodes that allows us to create a new instance of the overlay, join it, leave it, lookup for nodes by a given key and get the neighbors of a specific node.

type OverlayClient

type OverlayClient struct {
	// contains filtered or unexported fields
}

OverlayClient is the base intermediate structure that interacts with the specific overlay implementations.

func NewOverlayClient

func NewOverlayClient(specificOverlay Overlay, localNode LocalNode) *OverlayClient

func (*OverlayClient) Create

func (o *OverlayClient) Create(ctx context.Context, appNode LocalNode) error

func (*OverlayClient) Join

func (o *OverlayClient) Join(ctx context.Context, overlayNodeIP string, overlayNodePort int, appNode LocalNode) error

func (*OverlayClient) Leave

func (o *OverlayClient) Leave(ctx context.Context) error

func (*OverlayClient) Lookup

func (o *OverlayClient) Lookup(ctx context.Context, key []byte) ([]*OverlayNode, error)

func (*OverlayClient) Neighbors

func (o *OverlayClient) Neighbors(ctx context.Context, nodeID []byte) ([]*OverlayNode, error)

func (*OverlayClient) NodeID

func (o *OverlayClient) NodeID(ctx context.Context) ([]byte, error)

type OverlayNode

type OverlayNode struct {
	// contains filtered or unexported fields
}

Represents a generic overlay node.

func NewOverlayNode

func NewOverlayNode(nodeIP string, port int, guid []byte) *OverlayNode

NewOverlayNode creates a new overlay node.

func (*OverlayNode) GUID

func (o *OverlayNode) GUID() []byte

Node identifier

func (*OverlayNode) IP

func (o *OverlayNode) IP() string

IP of the node

func (*OverlayNode) Port

func (o *OverlayNode) Port() int

Port of the overlay daemon

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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