network

package
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2020 License: AGPL-3.0 Imports: 4 Imported by: 47

Documentation

Overview

(c) 2019 Dapper Labs - ALL RIGHTS RESERVED

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllPeerUnreachableError

func AllPeerUnreachableError(errs ...error) bool

AllPeerUnreachableError returns whether all errors are PeerUnreachableError

func IsPeerUnreachableError

func IsPeerUnreachableError(e error) bool

IsPeerUnreachableError returns whether the given error is PeerUnreachableError

func NewPeerUnreachableError

func NewPeerUnreachableError(err error) error

NewPeerUnreachableError creates a PeerUnreachableError instance with an error

Types

type Codec

type Codec interface {
	NewEncoder(w io.Writer) Encoder
	NewDecoder(r io.Reader) Decoder
	Encode(v interface{}) ([]byte, error)
	Decode(data []byte) (interface{}, error)
}

Codec provides factory functions for encoders and decoders.

type Conduit

type Conduit interface {

	// Submit will submit an event to the network layer. The network layer will
	// ensure that the event is delivered to the same engine on the desired target
	// nodes. It's possible that the event traverses other nodes than the target
	// nodes on its path across the network. The network codec needs to be aware
	// of how to encode the given event type, otherwise the send will fail.
	//
	// Note: Submit method is planned for deprecation soon.
	// Alternative methods are recommended, e.g., Publish, Unicast, and Multicast.
	Submit(event interface{}, targetIDs ...flow.Identifier) error

	// Publish submits an event to the network layer for unreliable delivery
	// to subscribers of the given event on the network layer. It uses a
	// publish-subscribe layer and can thus not guarantee that the specified
	// recipients received the event.
	// The event is published on the channel ID of this Conduit and will be received
	// by the nodes specified as part of the targetIDs
	Publish(event interface{}, targetIDs ...flow.Identifier) error

	// Unicast sends the event in a reliable way to the given recipient.
	// It uses 1-1 direct messaging over the underlying network to deliver the event.
	// It returns an error if the unicast fails.
	Unicast(event interface{}, targetID flow.Identifier) error

	// Multicast unreliably sends the specified event over the channelID
	// to the specified number of recipients selected from the specified subset.
	// The recipients are selected randomly from the targetIDs.
	Multicast(event interface{}, num uint, targetIDs ...flow.Identifier) error

	// Close unsubscribes from the channel ID of this conduit. After calling close,
	// the conduit can no longer be used to send a message.
	Close() error
}

Conduit represents the interface for engines to communicate over the peer-to-peer network. Upon registration with the network, each engine is assigned a conduit, which it can use to communicate across the network in a network-agnostic way. In the background, the network layer connects all engines with the same ID over a shared bus, accessible through the conduit.

type Decoder

type Decoder interface {
	Decode() (interface{}, error)
}

Decoder decodes from the underlying reader into the given message.

type Encoder

type Encoder interface {
	Encode(v interface{}) error
}

Encoder encodes the given message into the underlying writer.

type Engine

type Engine interface {

	// SubmitLocal submits an event originating on the local node.
	SubmitLocal(event interface{})

	// Submit submits the given event from the node with the given origin ID
	// for processing in a non-blocking manner. It returns instantly and logs
	// a potential processing error internally when done.
	Submit(originID flow.Identifier, event interface{})

	// ProcessLocal processes an event originating on the local node.
	ProcessLocal(event interface{}) error

	// Process processes the given event from the node with the given origin ID
	// in a blocking manner. It returns the potential processing error when
	// done.
	Process(originID flow.Identifier, event interface{}) error
}

Engine represents an isolated process running across the peer-to-peer network as part of the node business logic. It provides the network layer with the necessary interface to forward events to engines for processing.

type PeerUnreachableError

type PeerUnreachableError struct {
	Err error
}

PeerUnreachableError is the error when submitting events to target fails due to the target peer is unreachable

func (PeerUnreachableError) Error

func (e PeerUnreachableError) Error() string

func (PeerUnreachableError) Unwrap

func (e PeerUnreachableError) Unwrap() error

Unwrap returns the wrapped error value

Directories

Path Synopsis
codec
gossip
libp2p
Package libp2p encapsulates the libp2p library
Package libp2p encapsulates the libp2p library
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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