raft

package
v0.0.0-...-5637490 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClusterRouter

func ClusterRouter(schemaHandler schema.Handler) *http.ServeMux

ClusterRouter returns a *mux.Router that will requests starting with "/v1/cluster". The schemaHandler is kept in memory internally to forward request to once parsed.

Types

type JoinNodeRequest

type JoinNodeRequest struct {
	// Node is the ID of the node that will join the cluster.
	// It needs the following format NODE_ID[:NODE_PORT]
	// If NODE_PORT is not specified, default raft interal port will be used
	Node string `json:"node"`
	// Voter is whether or not the node wants to join as a voter in the raft cluster
	Voter bool `json:"voter"`
}

JoinNodeRequest defines the needed parameter for a node to join a raft cluster

func (JoinNodeRequest) Validate

func (r JoinNodeRequest) Validate() error

Validate ensures that r is valid. If an error is returned the request should not be used.

type RaftHandler

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

RaftHandler struct implements all the http endpoints for raft related requests

func (RaftHandler) JoinNode

func (h RaftHandler) JoinNode(w http.ResponseWriter, r *http.Request)

JoinNode parses the received request and body, ensures that they are valid and then forwards the parameters to the scheme handler that will join the node to the cluster. If the request is invalid, returns http.StatusBadRequest If an internal error occurs, returns http.StatusInternalServerError

func (RaftHandler) RemoveNode

func (h RaftHandler) RemoveNode(w http.ResponseWriter, r *http.Request)

RemoveNode parses the received request and body, ensures that they are valid and then forwards the parameters to the scheme handler that will remove the node from the cluster. If the request is invalid, returns http.StatusBadRequest If an internal error occurs, returns http.StatusInternalServerError

func (RaftHandler) StoreSchemaV1

func (h RaftHandler) StoreSchemaV1(w http.ResponseWriter, r *http.Request)

StoreSchemaV1 migrate from v2 (RAFT) to v1 (Non-RAFT)

type RemoveNodeRequest

type RemoveNodeRequest struct {
	// Node is the ID of the node that will be removed from the cluster.
	Node string `json:"node"`
}

RemoveNodeRequest defines the needed parameter for a node to be removed from the raft cluster.

func (RemoveNodeRequest) Validate

func (r RemoveNodeRequest) Validate() error

Validate ensures that r is valid. If an error is returned the request should not be used.

Jump to

Keyboard shortcuts

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