Documentation ¶
Index ¶
- Constants
- type Client
- func (c *Client) Address() *url.URL
- func (c *Client) AppendEntries(ctx context.Context, input raft.AppendEntriesInput) (raft.AppendEntriesOutput, error)
- func (c *Client) Delete(ctx context.Context, input raft.DeleteInput) error
- func (c *Client) Get(ctx context.Context, input raft.GetInput) (raft.GetOutput, error)
- func (c *Client) RequestVote(ctx context.Context, input raft.RequestVoteInput) (raft.RequestVoteOutput, error)
- func (c *Client) Set(ctx context.Context, input raft.SetInput) error
- type Server
- func (s *Server) AppendEntries(writer http.ResponseWriter, req *http.Request)
- func (s *Server) Delete(writer http.ResponseWriter, req *http.Request)
- func (s *Server) Get(writer http.ResponseWriter, req *http.Request)
- func (s *Server) ListenAndServe(addr string) error
- func (s *Server) RequestVote(writer http.ResponseWriter, req *http.Request)
- func (s *Server) Set(writer http.ResponseWriter, req *http.Request)
- type UnexpectedStatusCodeError
Constants ¶
const ( // API is the root of the REST API. API = "/api" // APIV1 is the versiond endpoint, all endpoints should be postfixed to this one. APIV1 = API + "/v1" // APIV1AppendEntries is the endpoint for the 'AppendEntries' operation. APIV1AppendEntries = APIV1 + "/append-entries" // APIV1RequestVote is the endpoint for the 'RequestVote' operation. APIV1RequestVote = APIV1 + "/request-vote" // APIV1KV is the endpoint for performing key value operations. APIV1KV = APIV1 + "/key-value" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements the Raft client interface allowing intra-cluster communication via a REST API.
func NewClient ¶
NewClient returns a new client which will communicate with the node a the given address.
func (*Client) AppendEntries ¶
func (c *Client) AppendEntries(ctx context.Context, input raft.AppendEntriesInput) (raft.AppendEntriesOutput, error)
AppendEntries dispatches an append entries request to the remote node.
func (*Client) RequestVote ¶
func (c *Client) RequestVote(ctx context.Context, input raft.RequestVoteInput) (raft.RequestVoteOutput, error)
RequestVote dispatches a request vote request to the remote node.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server implements the Raft client interface allowing intra-cluster communication via a REST API.
func NewServer ¶
NewServer returns a server which hosts all the required endpoints to allow intra-cluster communication.
func (*Server) AppendEntries ¶
func (s *Server) AppendEntries(writer http.ResponseWriter, req *http.Request)
AppendEntries handles an 'AppendEntries' request.
func (*Server) Delete ¶
func (s *Server) Delete(writer http.ResponseWriter, req *http.Request)
Delete a key/value pair.
func (*Server) Get ¶
func (s *Server) Get(writer http.ResponseWriter, req *http.Request)
Get returns a key/value pair.
func (*Server) ListenAndServe ¶
ListenAndServe starts the server on the given address/port.
func (*Server) RequestVote ¶
func (s *Server) RequestVote(writer http.ResponseWriter, req *http.Request)
RequestVote handles a 'RequestVote' request.
type UnexpectedStatusCodeError ¶
UnexpectedStatusCodeError is returned if a REST request resulted in a non-2xx status code.
func (UnexpectedStatusCodeError) Error ¶
func (e UnexpectedStatusCodeError) Error() string
Error implements the 'error' interface and returns a useful error message indicating what request failed.