Documentation ¶
Index ¶
- type Client
- func (cl *Client) Apply(ctx context.Context, leaderRaftAddr string, req *cmd.ApplyRequest) (*cmd.ApplyResponse, error)
- func (cl *Client) Close()
- func (cl *Client) Join(ctx context.Context, leaderRaftAddr string, req *cmd.JoinPeerRequest) (*cmd.JoinPeerResponse, error)
- func (cl *Client) Notify(ctx context.Context, remoteAddr string, req *cmd.NotifyPeerRequest) (*cmd.NotifyPeerResponse, error)
- func (cl *Client) Query(ctx context.Context, leaderRaftAddr string, req *cmd.QueryRequest) (*cmd.QueryResponse, error)
- func (cl *Client) Remove(ctx context.Context, leaderRaftAddr string, req *cmd.RemovePeerRequest) (*cmd.RemovePeerResponse, error)
- type Server
- func (s *Server) Apply(ctx context.Context, req *cmd.ApplyRequest) (*cmd.ApplyResponse, error)
- func (s *Server) Close()
- func (s *Server) JoinPeer(_ context.Context, req *cmd.JoinPeerRequest) (*cmd.JoinPeerResponse, error)
- func (s *Server) Leader() string
- func (s *Server) NotifyPeer(_ context.Context, req *cmd.NotifyPeerRequest) (*cmd.NotifyPeerResponse, error)
- func (s *Server) Open() error
- func (s *Server) Query(ctx context.Context, req *cmd.QueryRequest) (*cmd.QueryResponse, error)
- func (s *Server) RemovePeer(_ context.Context, req *cmd.RemovePeerRequest) (*cmd.RemovePeerResponse, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is used for communication with remote nodes in a RAFT cluster It wraps the gRPC client to our gRPC server that is running on the raft port on each node
func NewClient ¶
func NewClient(r rpcAddressResolver, rpcMessageMaxSize int, sentryEnabled bool, logger *logrus.Logger) *Client
NewClient returns a Client using the rpcAddressResolver to resolve raft nodes and configured with rpcMessageMaxSize
func (*Client) Apply ¶
func (cl *Client) Apply(ctx context.Context, leaderRaftAddr string, req *cmd.ApplyRequest) (*cmd.ApplyResponse, error)
Apply will contact the node at leaderRaftAddr and send req to be applied in the RAFT store Returns the server response to the apply request Returns an error if an RPC connection to leaderRaftAddr can't be established Returns an error if the apply command fails
func (*Client) Join ¶
func (cl *Client) Join(ctx context.Context, leaderRaftAddr string, req *cmd.JoinPeerRequest) (*cmd.JoinPeerResponse, error)
Join will contact the node at leaderRaftAddr and try to join this node to the cluster leaded by leaderRaftAddress using req Returns the server response to the join request Returns an error if an RPC connection to leaderRaftAddr can't be established Returns an error if joining the node fails
func (*Client) Notify ¶
func (cl *Client) Notify(ctx context.Context, remoteAddr string, req *cmd.NotifyPeerRequest) (*cmd.NotifyPeerResponse, error)
Notify will contact the node at remoteAddr using the configured resolver and notify it of it's readiness to join a cluster using req Returns the server response to the notify request Returns an error if remoteAddr is not resolvable Returns an error if remoteAddr after resolve is not dial-able Returns an error if notifying the node fails. Note that Notify will not return an error if the node has notified itself already or if the remote node is already bootstrapped If the remote node is already bootstrapped/running a cluster, nodes should call Join instead Once a remote node has reached the sufficient amount of ready nodes (bootstrap_expect) it will initiate a cluster bootstrap process
func (*Client) Query ¶
func (cl *Client) Query(ctx context.Context, leaderRaftAddr string, req *cmd.QueryRequest) (*cmd.QueryResponse, error)
Query will contact the node at leaderRaftAddr and send req to read data in the RAFT store Returns the server response to the query request Returns an error if an RPC connection to leaderRaftAddr can't be established Returns an error if the query command fails
func (*Client) Remove ¶
func (cl *Client) Remove(ctx context.Context, leaderRaftAddr string, req *cmd.RemovePeerRequest) (*cmd.RemovePeerResponse, error)
Remove will contact the node at leaderRaftAddr and remove the client node from the RAFT cluster using req Returns the server response to the remove request Returns an error if an RPC connection to leaderRaftAddr can't be established
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(raftPeers raftPeers, raftFSM raftFSM, listenAddress string, log *logrus.Logger, grpcMessageMaxSize int, sentryEnabled bool) *Server
NewServer returns the Server implementing the RPC interface for RAFT peers management and execute/query commands. The server must subsequently be started with Open(). The server will be configure the gRPC service with grpcMessageMaxSize.
func (*Server) Apply ¶
func (s *Server) Apply(ctx context.Context, req *cmd.ApplyRequest) (*cmd.ApplyResponse, error)
Apply will update the RAFT FSM representation to apply req. Returns the FSM version of that change. Returns an error and the current raft leader if applying fails.
func (*Server) Close ¶
func (s *Server) Close()
Close closes the server and free any used ressources.
func (*Server) JoinPeer ¶
func (s *Server) JoinPeer(_ context.Context, req *cmd.JoinPeerRequest) (*cmd.JoinPeerResponse, error)
JoinPeer will notify the RAFT cluster that a new peer is joining the cluster. Returns an error and the current raft leader if joining fails.
func (*Server) NotifyPeer ¶
func (s *Server) NotifyPeer(_ context.Context, req *cmd.NotifyPeerRequest) (*cmd.NotifyPeerResponse, error)
NotifyPeer will notify the RAFT cluster that a peer has notified that it is ready to be joined. Returns an error if notifying fails.
func (*Server) Open ¶
Open starts the server and registers it as the cluster service server. Returns asynchronously once the server has started. Returns an error if the configured listenAddress is invalid. Returns an error if the configured listenAddress is un-usable to listen on.
func (*Server) Query ¶
func (s *Server) Query(ctx context.Context, req *cmd.QueryRequest) (*cmd.QueryResponse, error)
Query will read the RAFT FSM schema representation using req. Returns the result of the query. Returns an error if querying fails.
func (*Server) RemovePeer ¶
func (s *Server) RemovePeer(_ context.Context, req *cmd.RemovePeerRequest) (*cmd.RemovePeerResponse, error)
RemovePeer will notify the RAFT cluster that a peer is removed from the cluster. Returns an error and the current raft leader if removal fails.