raftadmin

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotLeader = errors.New("not leader")

Functions

This section is empty.

Types

type AddNonvoterRequest

type AddNonvoterRequest struct {
	ID        string `json:"id"`
	Address   string `json:"address"`
	PrevIndex int64  `json:"prev_index"`
}

type AddVoterRequest

type AddVoterRequest struct {
	ID        string `json:"id"`
	Address   string `json:"address"`
	PrevIndex int64  `json:"prev_index"`
}

type AppliedIndexResponse

type AppliedIndexResponse struct {
	Index uint64 `json:"index"`
}

type ApplyLogRequest

type ApplyLogRequest struct {
	Data       []byte `json:"data"`
	Extensions []byte `json:"extensions"`
}

type AwaitResponse

type AwaitResponse struct {
	Index uint64 `json:"index"`
	Error string `json:"error"`
}

type Client added in v0.11.0

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

func NewClient added in v0.11.0

func NewClient(doer Doer, logger *zap.Logger, scheme string) *Client

func (*Client) AddNonvoter added in v0.11.0

func (c *Client) AddNonvoter(ctx context.Context, target raft.ServerAddress, req *AddNonvoterRequest) (*AwaitResponse, error)

func (*Client) AddVoter added in v0.11.0

func (c *Client) AddVoter(ctx context.Context, target raft.ServerAddress, req *AddVoterRequest) (*AwaitResponse, error)

func (*Client) AppliedIndex added in v0.11.0

func (c *Client) AppliedIndex(ctx context.Context, target raft.ServerAddress) (*AppliedIndexResponse, error)

func (*Client) ApplyLog added in v0.11.0

func (c *Client) ApplyLog(ctx context.Context, target raft.ServerAddress, req *ApplyLogRequest) (*AwaitResponse, error)

func (*Client) Barrier added in v0.11.0

func (c *Client) Barrier(ctx context.Context, target raft.ServerAddress) (*AwaitResponse, error)

func (*Client) DemoteVoter added in v0.11.0

func (c *Client) DemoteVoter(ctx context.Context, target raft.ServerAddress, req *DemoteVoterRequest) (*AwaitResponse, error)

func (*Client) GetConfiguration added in v0.11.0

func (c *Client) GetConfiguration(ctx context.Context, target raft.ServerAddress) (*GetConfigurationResponse, error)

func (*Client) LastContact added in v0.11.0

func (c *Client) LastContact(ctx context.Context, target raft.ServerAddress) (*LastContactResponse, error)

func (*Client) LastIndex added in v0.11.0

func (c *Client) LastIndex(ctx context.Context, target raft.ServerAddress) (*LastIndexResponse, error)

func (*Client) Leader added in v0.11.0

func (c *Client) Leader(ctx context.Context, target raft.ServerAddress) (*LeaderResponse, error)

func (*Client) LeadershipTransfer added in v0.11.0

func (c *Client) LeadershipTransfer(ctx context.Context, target raft.ServerAddress, req *LeadershipTransferToServerRequest) (*AwaitResponse, error)

func (*Client) RemoveServer added in v0.11.0

func (c *Client) RemoveServer(ctx context.Context, target raft.ServerAddress, req *RemoveServerRequest) (*AwaitResponse, error)

func (*Client) Shutdown added in v0.11.0

func (c *Client) Shutdown(ctx context.Context, target raft.ServerAddress) (*AwaitResponse, error)

func (*Client) State added in v0.11.0

func (c *Client) State(ctx context.Context, target raft.ServerAddress) (*StateResponse, error)

func (*Client) Stats added in v0.11.0

func (c *Client) Stats(ctx context.Context, target raft.ServerAddress) (*StatsResponse, error)

func (*Client) VerifyLeader added in v0.11.0

func (c *Client) VerifyLeader(ctx context.Context, target raft.ServerAddress) error

type DemoteVoterRequest

type DemoteVoterRequest struct {
	ID        string `json:"id"`
	PrevIndex uint64 `json:"prev_index"`
}

type Doer

type Doer func(*http.Request) (*http.Response, error)

type ForgetResponse

type ForgetResponse struct {
	OperationToken string `json:"operation_token"`
}

type Future

type Future struct {
	OperationToken string
}

type GetConfigurationResponse

type GetConfigurationResponse struct {
	Servers []*GetConfigurationServer `json:"servers"`
}

type GetConfigurationServer

type GetConfigurationServer struct {
	Suffrage RaftSuffrage `json:"suffrage"`
	ID       string       `json:"id"`
	Address  string       `json:"address"`
}

type LastContactResponse

type LastContactResponse struct {
	UnixNano int64 `json:"unix_nano"`
}

type LastIndexResponse

type LastIndexResponse struct {
	Index uint64 `json:"index"`
}

type LeaderResponse

type LeaderResponse struct {
	ID      string `json:"id"`
	Address string `json:"address"`
}

type LeadershipTransferToServerRequest

type LeadershipTransferToServerRequest struct {
	ID      string `json:"id"`
	Address string `json:"address"`
}

type RaftState

type RaftState string
const (
	RaftStateLeader    RaftState = "leader"
	RaftStateFollower  RaftState = "follower"
	RaftStateCandidate RaftState = "candidate"
	RaftStateShutdown  RaftState = "shutdown"
)

type RaftSuffrage

type RaftSuffrage string
const (
	RaftSuffrageVoter    RaftSuffrage = "voter"
	RaftSuffrageNonvoter RaftSuffrage = "nonvoter"
)

type RemoveServerRequest

type RemoveServerRequest struct {
	ID        string `json:"id"`
	PrevIndex uint64 `json:"prev_index"`
}

type Server added in v0.11.0

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

Server provides a HTTP-based transport that can be used to communicate with Raft on remote machines. It is convenient to use if your application is an HTTP server already and you do not want to use multiple different transports (if not, you can use raft.NetworkTransport).

func NewServer added in v0.11.0

func NewServer(r *raft.Raft, logger *zap.Logger, addrs []raft.ServerAddress) *Server

NewServer creates a new HTTP transport on the given addr.

func (*Server) AddNonvoter added in v0.11.0

func (a *Server) AddNonvoter(ctx context.Context, req *AddNonvoterRequest) (*Future, error)

func (*Server) AddVoter added in v0.11.0

func (a *Server) AddVoter(ctx context.Context, req *AddVoterRequest) (*Future, error)

func (*Server) AppliedIndex added in v0.11.0

func (a *Server) AppliedIndex(ctx context.Context) (*AppliedIndexResponse, error)

func (*Server) Await added in v0.11.0

func (a *Server) Await(ctx context.Context, req *Future) (*AwaitResponse, error)

func (*Server) Barrier added in v0.11.0

func (a *Server) Barrier(ctx context.Context) (*Future, error)

func (*Server) CurrentNodeIsLeader added in v0.11.0

func (a *Server) CurrentNodeIsLeader(ctx context.Context) bool

func (*Server) DemoteVoter added in v0.11.0

func (a *Server) DemoteVoter(ctx context.Context, req *DemoteVoterRequest) (*Future, error)

func (*Server) Forget added in v0.11.0

func (a *Server) Forget(ctx context.Context, req *Future) (*ForgetResponse, error)

func (*Server) GetConfiguration added in v0.11.0

func (a *Server) GetConfiguration(ctx context.Context) (*GetConfigurationResponse, error)

func (*Server) LastContact added in v0.11.0

func (a *Server) LastContact(ctx context.Context) (*LastContactResponse, error)

func (*Server) LastIndex added in v0.11.0

func (a *Server) LastIndex(ctx context.Context) (*LastIndexResponse, error)

func (*Server) Leader added in v0.11.0

func (a *Server) Leader(ctx context.Context) (*LeaderResponse, error)

func (*Server) LeadershipTransfer added in v0.11.0

func (a *Server) LeadershipTransfer(ctx context.Context) (*Future, error)

func (*Server) LeadershipTransferToServer added in v0.11.0

func (a *Server) LeadershipTransferToServer(ctx context.Context, req *LeadershipTransferToServerRequest) (*Future, error)

func (*Server) RemoveServer added in v0.11.0

func (a *Server) RemoveServer(ctx context.Context, req *RemoveServerRequest) (*Future, error)

func (*Server) ServeHTTP added in v0.11.0

func (t *Server) ServeHTTP(res http.ResponseWriter, req *http.Request)

ServeHTTP implements the net/http.Handler interface, so that you can use

func (*Server) Shutdown added in v0.11.0

func (a *Server) Shutdown(ctx context.Context) (*Future, error)

func (*Server) Snapshot added in v0.11.0

func (a *Server) Snapshot(ctx context.Context) (*Future, error)

func (*Server) State added in v0.11.0

func (a *Server) State(ctx context.Context) (*StateResponse, error)

func (*Server) Stats added in v0.11.0

func (a *Server) Stats(ctx context.Context) (*StatsResponse, error)

func (*Server) VerifyLeader added in v0.11.0

func (a *Server) VerifyLeader(ctx context.Context) (*Future, error)

type StateResponse

type StateResponse struct {
	Index int64 `json:"index"`
	State RaftState
}

type StatsResponse

type StatsResponse struct {
	Stats map[string]string `json:"stats"`
}

Jump to

Keyboard shortcuts

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