rafthttp

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Doer

type Doer interface {
	Do(*http.Request) (*http.Response, error)
}

Doer provides the Do() method, as found in net/http.Client.

Using this interface instead of net/http.Client directly is useful so that users of the HTTPTransport can wrap requests to, for example, call req.SetBasicAuth.

type HTTPTransport

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

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

func NewHTTPTransport(addr raft.ServerAddress, client Doer, logger zerolog.Logger, urlFmt string) *HTTPTransport

func (*HTTPTransport) AppendEntries

AppendEntries implements the raft.Transport interface.

func (*HTTPTransport) AppendEntriesPipeline

func (t *HTTPTransport) AppendEntriesPipeline(_ raft.ServerID, target raft.ServerAddress) (raft.AppendPipeline, error)

AppendEntriesPipeline implements the raft.Transport interface.

func (*HTTPTransport) Consumer

func (t *HTTPTransport) Consumer() <-chan raft.RPC

Consumer implements the raft.Transport interface.

func (*HTTPTransport) DecodePeer

func (t *HTTPTransport) DecodePeer(b []byte) raft.ServerAddress

DecodePeer implements the raft.Transport interface.

func (*HTTPTransport) EncodePeer

func (t *HTTPTransport) EncodePeer(_ raft.ServerID, a raft.ServerAddress) []byte

EncodePeer implements the raft.Transport interface.

func (*HTTPTransport) InstallSnapshot

InstallSnapshot implements the raft.Transport interface.

func (*HTTPTransport) LocalAddr

func (t *HTTPTransport) LocalAddr() raft.ServerAddress

LocalAddr implements the raft.Transport interface.

func (*HTTPTransport) RequestVote

RequestVote implements the raft.Transport interface.

func (*HTTPTransport) ServeHTTP

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

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

http.Handle("/raft/", transport)

func (*HTTPTransport) SetHeartbeatHandler

func (t *HTTPTransport) SetHeartbeatHandler(cb func(rpc raft.RPC))

SetHeartbeatHandler implements the raft.Transport interface.

func (*HTTPTransport) TimeoutNow

TimeoutNow implements the raft.Transport interface.

Jump to

Keyboard shortcuts

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