node

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2019 License: MIT Imports: 14 Imported by: 4

Documentation

Overview

Package node contains node logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CalculateNextEpoch

type CalculateNextEpoch func(count uint64, epoch int64) int64

CalculateNextEpoch is a function used to calculate the next `SendEpoch` for a given message.

type Mode

type Mode int

Mode represents the synchronization mode.

const (
	InteractiveMode Mode = iota + 1
	BatchMode
)

type Node

type Node struct {
	ID state.PeerID
	// contains filtered or unexported fields
}

Node represents an MVDS node, it runs all the logic like sending and receiving protocol messages.

func NewEphemeralNode added in v0.0.21

func NewEphemeralNode(
	id state.PeerID,
	t transport.Transport,
	nextEpoch CalculateNextEpoch,
	currentEpoch int64,
	mode Mode,
	logger *zap.Logger,
) *Node

func NewNode

func NewNode(
	ms store.MessageStore,
	st transport.Transport,
	ss state.SyncState,
	nextEpoch CalculateNextEpoch,
	currentEpoch int64,
	id state.PeerID,
	mode Mode,
	pp peers.Persistence,
	md dependency.Tracker,
	resolution ResolutionMode,
	logger *zap.Logger,
) *Node

NewNode returns a new node.

func NewPersistentNode added in v0.0.21

func NewPersistentNode(
	db *sql.DB,
	st transport.Transport,
	id state.PeerID,
	mode Mode,
	resolution ResolutionMode,
	nextEpoch CalculateNextEpoch,
	logger *zap.Logger,
) (*Node, error)

func (*Node) AddPeer

func (n *Node) AddPeer(group state.GroupID, id state.PeerID) error

AddPeer adds a peer to a specific group making it a recipient of messages.

func (*Node) AppendEphemeralMessage added in v0.0.25

func (n *Node) AppendEphemeralMessage(groupID state.GroupID, data []byte) (state.MessageID, error)

AppendEphemeralMessage sends a message to a given group that has the `no_ack_required` flag set to `true`.

func (*Node) AppendMessage

func (n *Node) AppendMessage(groupID state.GroupID, data []byte) (state.MessageID, error)

AppendMessage sends a message to a given group.

func (*Node) AppendMessageWithMetadata added in v0.0.25

func (n *Node) AppendMessageWithMetadata(groupID state.GroupID, data []byte, metadata *protobuf.Metadata) (state.MessageID, error)

AppendMessageWithMetadata sends a message to a given group with metadata.

func (*Node) CurrentEpoch added in v0.0.21

func (n *Node) CurrentEpoch() int64

func (*Node) IsPeerInGroup

func (n *Node) IsPeerInGroup(g state.GroupID, p state.PeerID) (bool, error)

IsPeerInGroup checks whether a peer is in the specified group.

func (*Node) RequestMessage

func (n *Node) RequestMessage(group state.GroupID, id state.MessageID) error

RequestMessage adds a REQUEST record to the next payload for a given message ID.

func (*Node) Start

func (n *Node) Start(duration time.Duration)

Start listens for new messages received by the node and sends out those required every epoch.

func (*Node) Stop

func (n *Node) Stop()

Stop message reading and epoch processing

func (*Node) Subscribe added in v0.0.20

func (n *Node) Subscribe() chan protobuf.Message

Subscribe subscribes to incoming messages.

func (*Node) Unsubscribe added in v0.0.20

func (n *Node) Unsubscribe()

Unsubscribe closes the listening channels

type ResolutionMode added in v0.0.25

type ResolutionMode int

ResolutionMode defines how message dependencies should be resolved.

const (
	// EventualMode is non-blocking and will return messages before dependencies are resolved.
	EventualMode ResolutionMode = iota + 1
	// ConsistentMode blocks and does not return messages until dependencies have been resolved.
	ConsistentMode
)

Directories

Path Synopsis
Package internal is a generated GoMock package.
Package internal is a generated GoMock package.

Jump to

Keyboard shortcuts

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