Documentation ¶
Index ¶
- Constants
- Variables
- func NewNOOPTransport(nhConfig config.NodeHostConfig, requestHandler paxosio.RequestHandler) paxosio.IPaxosRPC
- func NewTCPTransport(nhConfig config.NodeHostConfig, requestHandler paxosio.RequestHandler) paxosio.IPaxosRPC
- type INodeAddressResolver
- type INodeRegistry
- type IPaxosMessageHandler
- type ITransport
- type Marshaler
- type NOOPConnection
- type NOOPTransport
- type Nodes
- func (n *Nodes) AddNode(groupID uint64, nodeID uint64, url string)
- func (n *Nodes) AddRemoteAddress(groupID uint64, nodeID uint64, address string)
- func (n *Nodes) RemoveAllPeers()
- func (n *Nodes) RemoveGroup(groupID uint64)
- func (n *Nodes) RemoveNode(groupID uint64, nodeID uint64)
- func (n *Nodes) Resolve(groupID uint64, nodeID uint64) (string, string, error)
- func (n *Nodes) ReverseResolve(addr string) []paxosio.NodeInfo
- type SendMessageBatchFunc
- type TCPConnection
- type TCPTransport
- type Transport
Constants ¶
const (
// TCPPaxosRPCName is the name of the tcp RPC module.
TCPPaxosRPCName = "go-tcp-transport"
)
Variables ¶
var ( // NOOPPaxosName is the module name for the NOOP transport module. NOOPPaxosName = "noop-test-transport" // ErrRequestedToFail is the error used to indicate that the error is // requested. ErrRequestedToFail = errors.New("requested to returned error") )
var ( // ErrBadMessage is the error returned to indicate the incoming message is // corrupted. ErrBadMessage = errors.New("invalid message") )
Functions ¶
func NewNOOPTransport ¶
func NewNOOPTransport(nhConfig config.NodeHostConfig, requestHandler paxosio.RequestHandler) paxosio.IPaxosRPC
NewNOOPTransport creates a new NOOPTransport instance.
func NewTCPTransport ¶
func NewTCPTransport(nhConfig config.NodeHostConfig, requestHandler paxosio.RequestHandler) paxosio.IPaxosRPC
NewTCPTransport creates and returns a new TCP transport module.
Types ¶
type INodeAddressResolver ¶
type INodeAddressResolver interface { Resolve(uint64, uint64) (string, string, error) ReverseResolve(string) []paxosio.NodeInfo AddRemoteAddress(uint64, uint64, string) }
INodeAddressResolver converts the (cluster id, node id( tuple to network address
type INodeRegistry ¶
type INodeRegistry interface { AddNode(groupID uint64, nodeID uint64, url string) RemoveNode(groupID uint64, nodeID uint64) RemoveGroup(groupID uint64) Resolve(groupID uint64, nodeID uint64) (string, string, error) }
INodeRegistry is the local registry interface used to keep all known nodes in the multi paxos system.
type IPaxosMessageHandler ¶
type IPaxosMessageHandler interface {
HandleMessageBatch(batch paxospb.MessageBatch)
}
IPaxosMessageHandler is the interface required to handle incoming paxos requests.
type ITransport ¶
type ITransport interface { Name() string // SetUnmanagedDeploymentID() // SetDeploymentID(uint64) SetMessageHandler(IPaxosMessageHandler) RemoveMessageHandler() ASyncSend(paxospb.PaxosMsg) bool // ASyncSendSnapshot(paxospb.PaxosMsg) bool Stop() }
ITransport is the interface of the transport layer used for exchanging Paxos messages.
type NOOPConnection ¶
type NOOPConnection struct {
// contains filtered or unexported fields
}
NOOPConnection is the connection used to exchange messages between node hosts.
func (*NOOPConnection) Close ¶
func (c *NOOPConnection) Close()
Close closes the NOOPConnection instance.
func (*NOOPConnection) SendMessageBatch ¶
func (c *NOOPConnection) SendMessageBatch(batch paxospb.MessageBatch) error
SendMessageBatch return ErrRequestedToFail when requested.
type NOOPTransport ¶
type NOOPTransport struct {
// contains filtered or unexported fields
}
NOOPTransport is a transport module for testing purposes. It does not actually has the ability to exchange messages or snapshots between nodehosts.
func (*NOOPTransport) GetConnection ¶
func (g *NOOPTransport) GetConnection(ctx context.Context, target string) (paxosio.IConnection, error)
GetConnection returns a connection.
func (*NOOPTransport) Start ¶
func (g *NOOPTransport) Start() error
Start starts the NOOPTransport instance.
type Nodes ¶
type Nodes struct {
// contains filtered or unexported fields
}
Nodes is used to manage all known node addresses in the multi paxos system. The transport layer uses this address registry to locate nodes.
func (*Nodes) AddRemoteAddress ¶
AddRemoteAddress remembers the specified address obtained from the source of the incoming message.
func (*Nodes) RemoveGroup ¶
RemoveGroup removes all nodes info associated with the specified group
func (*Nodes) RemoveNode ¶
RemoveNode removes a remote from the node registry.
type SendMessageBatchFunc ¶
type SendMessageBatchFunc func(paxospb.MessageBatch) (paxospb.MessageBatch, bool)
SendMessageBatchFunc is a func type that is used to determine whether the specified message batch should be sent. This func is used in test only.
type TCPConnection ¶
type TCPConnection struct {
// contains filtered or unexported fields
}
TCPConnection is the connection used for sending paxos messages to remote nodes.
func NewTCPConnection ¶
func NewTCPConnection(conn net.Conn) *TCPConnection
NewTCPConnection creates and returns a new TCPConnection instance.
func (*TCPConnection) Close ¶
func (c *TCPConnection) Close()
Close closes the TCPConnection instance.
func (*TCPConnection) SendMessageBatch ¶
func (c *TCPConnection) SendMessageBatch(batch paxospb.MessageBatch) error
SendMessageBatch sends a paxos message batch to remote node.
type TCPTransport ¶
type TCPTransport struct {
// contains filtered or unexported fields
}
TCPTransport is a TCP based RPC module for exchanging paxos messages and snapshots between NodeHost instances.
func (*TCPTransport) GetConnection ¶
func (g *TCPTransport) GetConnection(ctx context.Context, target string) (paxosio.IConnection, error)
GetConnection returns a new paxosio.IConnection for sending raft messages.
func (*TCPTransport) Name ¶
func (g *TCPTransport) Name() string
Name returns a human readable name of the TCP transport module.
func (*TCPTransport) Start ¶
func (g *TCPTransport) Start() error
Start starts the TCP transport module.
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport is the transport layer for delivering paxos messages and snapshots.
func NewTransport ¶
func NewTransport(nhConfig config.NodeHostConfig, ctx *server.Context, resolver INodeAddressResolver) *Transport
NewTransport creates a new Transport object.
func (*Transport) GetPaxosRPC ¶
GetPaxosRPC returns the paxos RPC instance
func (*Transport) RemoveMessageHandler ¶
func (t *Transport) RemoveMessageHandler()
RemoveMessageHandler removes the raft message handler.
func (*Transport) SetMessageHandler ¶
func (t *Transport) SetMessageHandler(handler IPaxosMessageHandler)
SetMessageHandler sets the raft message handler.