Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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) 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.