raftadmin

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: Apache-2.0 Imports: 15 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 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 HTTPAdminClient

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

func NewHTTPAdminClient

func NewHTTPAdminClient(doer Doer, urlFmt string, logger *zap.Logger) *HTTPAdminClient

func (*HTTPAdminClient) AddNonvoter

func (*HTTPAdminClient) AddVoter

func (*HTTPAdminClient) AppliedIndex

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

func (*HTTPAdminClient) ApplyLog

func (*HTTPAdminClient) Barrier

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

func (*HTTPAdminClient) DemoteVoter

func (*HTTPAdminClient) GetConfiguration

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

func (*HTTPAdminClient) LastContact

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

func (*HTTPAdminClient) LastIndex

func (*HTTPAdminClient) Leader

func (*HTTPAdminClient) LeadershipTransfer

func (*HTTPAdminClient) RemoveServer

func (*HTTPAdminClient) Shutdown

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

func (*HTTPAdminClient) State

func (*HTTPAdminClient) Stats

func (*HTTPAdminClient) VerifyLeader

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

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 RaftAdminHTTPServer

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

RaftAdminHTTPServer 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 NewRaftAdminHTTPServer

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

NewRaftAdminHTTPServer creates a new HTTP transport on the given addr.

func (*RaftAdminHTTPServer) AddNonvoter

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

func (*RaftAdminHTTPServer) AddVoter

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

func (*RaftAdminHTTPServer) AppliedIndex

func (*RaftAdminHTTPServer) Await

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

func (*RaftAdminHTTPServer) Barrier

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

func (*RaftAdminHTTPServer) CurrentNodeIsLeader

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

func (*RaftAdminHTTPServer) DemoteVoter

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

func (*RaftAdminHTTPServer) Forget

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

func (*RaftAdminHTTPServer) GetConfiguration

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

func (*RaftAdminHTTPServer) LastContact

func (*RaftAdminHTTPServer) LastIndex

func (*RaftAdminHTTPServer) Leader

func (*RaftAdminHTTPServer) LeadershipTransfer

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

func (*RaftAdminHTTPServer) LeadershipTransferToServer

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

func (*RaftAdminHTTPServer) RemoveServer

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

func (*RaftAdminHTTPServer) ServeHTTP

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

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

func (*RaftAdminHTTPServer) Shutdown

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

func (*RaftAdminHTTPServer) Snapshot

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

func (*RaftAdminHTTPServer) State

func (*RaftAdminHTTPServer) Stats

func (*RaftAdminHTTPServer) VerifyLeader

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

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 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