raftrpc

package
v0.0.0-...-fd5963e Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRPCTransportConfig = RPCTransportConfig{

	RPCName: defaultRPCName,

	SendTimeout: 100 * time.Millisecond,
}

DefaultRPCTransportConfig include default values for the Raft RPC transport.

Functions

This section is empty.

Types

type RPCCommand

type RPCCommand struct {
	// Msg is actual message.
	Msg raft.Msg
}

RPCCommand is a command that is serialized and used to communicate between Raft nodes. Gob requires a known type passed as an argument to serialize/deserialize, which is why we can't just pass the Msg.:

type RPCHandler

type RPCHandler chan raft.Msg

RPCHandler defines methods that conform to Go's RPC requirement.

func (RPCHandler) HandleCommand

func (h RPCHandler) HandleCommand(cmd RPCCommand, ok *bool) error

HandleCommand puts a Msg into incoming message queue.

type RPCTransport

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

RPCTransport is an implementation of the Transport interface based on Go RPC.

func NewRPCTransport

func NewRPCTransport(cfg raft.TransportConfig, rpcCfg RPCTransportConfig) (*RPCTransport, error)

NewRPCTransport creates a new RPCTransport.

func (*RPCTransport) Addr

func (t *RPCTransport) Addr() string

Addr returns the local address of the transport.

func (*RPCTransport) Close

func (t *RPCTransport) Close() error

Close closes all connections.

func (*RPCTransport) Receive

func (t *RPCTransport) Receive() <-chan raft.Msg

Receive returns a channel for receiving incoming message from the network.

func (*RPCTransport) Send

func (t *RPCTransport) Send(m raft.Msg)

Send asynchronously sends message 'm' to the node referred by 'm.GetTo()' through the transport. TODO: (1) Should we send a notification when there is an error? (2) Group transmission?

func (*RPCTransport) StartStandaloneRPCServer

func (t *RPCTransport) StartStandaloneRPCServer()

StartStandaloneRPCServer starts the default RPC server. This should only be called by binaries that don't start an http server using the default mux.

type RPCTransportConfig

type RPCTransportConfig struct {
	// Name for this instance of raft, to allow mutiple raft instances can be
	// run in the same process. May be left blank, in which case a default will
	// be used. All peers of the same raft instance must use the same RPCName.
	// Only used by RPC transport.
	RPCName string

	// Duration before a send operation fails.
	SendTimeout time.Duration
}

RPCTransportConfig specifies options for the RPC transport, in addition to those in the generic TransportConfig.

Jump to

Keyboard shortcuts

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