peer

package
v0.0.0-...-3a733ff Latest Latest
Warning

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

Go to latest
Published: May 24, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecCallback

type ExecCallback struct {
	Cmd    commandpb.Command
	Result []byte
}

type ExecPacket

type ExecPacket struct {
	Cmd      commandpb.Command
	IsSpec   bool
	Meta     []byte
	Callback bool
	NoExec   bool
}

type LocalConfig

type LocalConfig struct {
	*pb.PeerConfig
	Peers      []pb.PeerID
	PeerAddrs  map[pb.PeerID]string
	ListenAddr string
	ID         pb.PeerID
	Logger     logger.Logger
	RandSeed   int64
}

LocalConfig contains configurations for constructing a Peer.

type Peer

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

Peer is a member of a Raft consensus group. Its primary roles are to: 1. route incoming Raft messages 2. periodically tick the Raft RawNode 3. serve as a scheduler for Raft proposal pipeline events

func New

func New(
	cfg *LocalConfig,
	t transport.Transport,
	n Protocol,
) *Peer

New creates a new Peer.

func (*Peer) HandleCommand

func (p *Peer) HandleCommand(
	ctx context.Context,
	pkt *transpb.ClientPacket,
) (*transpb.ClientPacket, error)

func (*Peer) HandleMessage

func (p *Peer) HandleMessage(m *transpb.TransMsg)

HandleMessage implements transport.MessageHandler.

func (*Peer) Run

func (p *Peer) Run()

Run starts the Peer's processing loop.

func (*Peer) Stop

func (p *Peer) Stop()

Stop stops all processing and releases all resources held by Peer.

type Protocol

type Protocol interface {
	Step(peerpb.Message)
	Tick()
	Request(*commandpb.Command)
	Callback(ExecCallback)

	MakeReady() Ready
	ClearMsgs()
	ClearExecutedCommands()

	AsyncCallback()
}

type Ready

type Ready struct {
	Messages        []pb.Message
	OrderedCommands []ExecPacket
}

type TickingTimer

type TickingTimer interface {
	Tick()
	Reset()
	Stop()
	Instrument(func())
	IsSet() bool
}

func MakeTickingTimer

func MakeTickingTimer(timeout int, onTimeout func()) TickingTimer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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