raftsupport

package
v2.4.10 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SnapRespHeaderLength = 4
)

Variables

View Source
var (
	ErrExceedSizeLimit = errors.New("raftsupport: error limit exceeded")
)

Functions

This section is empty.

Types

type AergoRaftTransport

type AergoRaftTransport struct {

	// copied from original transport
	ServerStats *stats.ServerStats
	LeaderStats *stats.LeaderStats
	// contains filtered or unexported fields
}

AergoRaftTransport is wrapper of p2p module

func NewAergoRaftTransport

func NewAergoRaftTransport(logger *log.Logger, nt p2pcommon.NetworkTransport, pm p2pcommon.PeerManager, mf p2pcommon.MoFactory, consAcc consensus.ConsensusAccessor, cluster interface{}) *AergoRaftTransport

func (*AergoRaftTransport) ActivePeers

func (t *AergoRaftTransport) ActivePeers() int

func (*AergoRaftTransport) ActiveSince

func (t *AergoRaftTransport) ActiveSince(id rtypes.ID) time.Time

func (*AergoRaftTransport) AddPeer

func (t *AergoRaftTransport) AddPeer(id rtypes.ID, peerID types.PeerID, urls []string)

func (*AergoRaftTransport) AddRemote

func (t *AergoRaftTransport) AddRemote(id rtypes.ID, urls []string)

func (*AergoRaftTransport) Handler

func (t *AergoRaftTransport) Handler() http.Handler

func (*AergoRaftTransport) NewSnapshotReceiver

func (t *AergoRaftTransport) NewSnapshotReceiver(peer p2pcommon.RemotePeer, rwc io.ReadWriteCloser) SnapshotReceiver

func (*AergoRaftTransport) NewSnapshotSender

func (t *AergoRaftTransport) NewSnapshotSender(peer p2pcommon.RemotePeer) SnapshotSender

func (*AergoRaftTransport) OnPeerConnect

func (t *AergoRaftTransport) OnPeerConnect(pid types.PeerID)

func (*AergoRaftTransport) OnPeerDisconnect

func (t *AergoRaftTransport) OnPeerDisconnect(peer p2pcommon.RemotePeer)

func (*AergoRaftTransport) OnRaftSnapshot

func (t *AergoRaftTransport) OnRaftSnapshot(s network.Stream)

func (*AergoRaftTransport) RemoveAllPeers

func (t *AergoRaftTransport) RemoveAllPeers()

func (*AergoRaftTransport) RemovePeer

func (t *AergoRaftTransport) RemovePeer(id rtypes.ID)

func (*AergoRaftTransport) Send

func (t *AergoRaftTransport) Send(msgs []raftpb.Message)

Send must send message to target peer or report unreachable if sending peer is failed.

func (*AergoRaftTransport) SendSnapshot

func (t *AergoRaftTransport) SendSnapshot(m snap.Message)

func (*AergoRaftTransport) Start

func (t *AergoRaftTransport) Start() error

func (*AergoRaftTransport) Stop

func (t *AergoRaftTransport) Stop()

func (*AergoRaftTransport) UpdatePeer

func (t *AergoRaftTransport) UpdatePeer(id rtypes.ID, urls []string)

type ClusterInfoReceiver

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

ClusterInfoReceiver is send p2p getClusterInfo to connected peers and Receive p2p responses one of peers return successful response The first version will be simplified version. it send and Receive one by one.

func (*ClusterInfoReceiver) ReceiveResp

func (br *ClusterInfoReceiver) ReceiveResp(msg p2pcommon.Message, msgBody p2pcommon.MessageBody) (ret bool)

ReceiveResp must be called just in read go routine

func (*ClusterInfoReceiver) StartGet

func (br *ClusterInfoReceiver) StartGet()

type ConcurrentClusterInfoReceiver

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

ClusterInfoReceiver is send p2p getClusterInfo to connected peers and Receive p2p responses one of peers return successful response The first version will be simplified version. it send and Receive one by one.

func (*ConcurrentClusterInfoReceiver) ReceiveResp

func (r *ConcurrentClusterInfoReceiver) ReceiveResp(msg p2pcommon.Message, msgBody p2pcommon.MessageBody) (ret bool)

ReceiveResp must be called just in read go routine

func (*ConcurrentClusterInfoReceiver) StartGet

func (r *ConcurrentClusterInfoReceiver) StartGet()

type RaftMsgDecoder

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

func (*RaftMsgDecoder) Decode

func (dec *RaftMsgDecoder) Decode() (raftpb.Message, error)

func (*RaftMsgDecoder) DecodeLimit

func (dec *RaftMsgDecoder) DecodeLimit(numBytes uint64) (raftpb.Message, error)

type RaftMsgEncoder

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

RaftMsgEncoder is encode raftpb.Message itt result will be same as rafthttp.messageEncoder

func (*RaftMsgEncoder) Encode

func (enc *RaftMsgEncoder) Encode(m *raftpb.Message) error

type RaftMsgMarshaller

type RaftMsgMarshaller struct {
	*raftpb.Message
}

func (RaftMsgMarshaller) MarshalZerologObject

func (m RaftMsgMarshaller) MarshalZerologObject(e *zerolog.Event)

type SnapshotIOFactory

type SnapshotIOFactory interface {
	NewSnapshotSender(peer p2pcommon.RemotePeer) SnapshotSender
	NewSnapshotReceiver(peer p2pcommon.RemotePeer, rwc io.ReadWriteCloser) SnapshotReceiver
}

SnapshotIOFactory create SnapshotSender or SnapshotReceiver for a peer

type SnapshotReceiver

type SnapshotReceiver interface {
	Receive()
}

type SnapshotSender

type SnapshotSender interface {
	// Send send snapshot data to target peer and always return the result to snapMsg (i.e. call Message.CloseWithErr() )
	Send(snapMsg *snap.Message)
}

Jump to

Keyboard shortcuts

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