transport

package
v0.0.0-...-81f3bb6 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GrpcMaxSize = 256 << 20
)

Variables

This section is empty.

Functions

func StopServer

func StopServer()

StopServer stop the server

Types

type GrpcRaftNode

type GrpcRaftNode struct {
	sync.Mutex
	// contains filtered or unexported fields
}

GrpcRaftNode struct implements the gRPC server interface.

func (*GrpcRaftNode) AddPeer

func (w *GrpcRaftNode) AddPeer(id uint64, rc protos.RaftContext)

func (*GrpcRaftNode) Disconnect

func (w *GrpcRaftNode) Disconnect()

func (*GrpcRaftNode) Echo

func (rn *GrpcRaftNode) Echo(ctx context.Context, in *protos.Payload) (*protos.Payload, error)

Hello rpc call is used to check connection with other workers after mon tcp server for this instance starts.

func (*GrpcRaftNode) GetPeer

func (rn *GrpcRaftNode) GetPeer(pid uint64) (string, bool)

Never returns ("", true)

func (*GrpcRaftNode) JoinCluster

func (rn *GrpcRaftNode) JoinCluster(ctx context.Context, rc *protos.RaftContext) (*protos.Payload, error)

func (*GrpcRaftNode) RaftMessage

func (rn *GrpcRaftNode) RaftMessage(ctx context.Context, query *protos.Payload) (*protos.Payload, error)

func (*GrpcRaftNode) RemovePeer

func (w *GrpcRaftNode) RemovePeer(id uint64)

func (*GrpcRaftNode) Send

func (w *GrpcRaftNode) Send(m raftpb.Message)

func (*GrpcRaftNode) SetPeer

func (rn *GrpcRaftNode) SetPeer(pid uint64, addr string, poolOrNil *pool)

addr must not be empty.

func (*GrpcRaftNode) Start

func (w *GrpcRaftNode) Start(grpc *grpc.Server)

type Raft

type Raft interface {
	Process(ctx context.Context, m raftpb.Message) error
	IsIDRemoved(id uint64) bool
	ReportUnreachable(id uint64)
	ReportSnapshot(id uint64, status raft.SnapshotStatus)
}

Raft is used to call functions in draft

type Transport

type Transport interface {
	Start(grpcSrv *grpc.Server)
	Send(m raftpb.Message)
	Disconnect()
	AddPeer(id uint64, rc protos.RaftContext)
	RemovePeer(id uint64)
}

Transport is network interface for raft

func InitRaftTransport

func InitRaftTransport(id uint64, raft Raft, addr map[uint64]string) Transport

InitRaftTransport init global variable

Jump to

Keyboard shortcuts

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