raftgrpc

package module
v0.0.0-...-9b51962 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: MIT Imports: 12 Imported by: 0

README

Raft GRPC

This project is no longer maintained. You might be interested in https://github.com/Jille/raft-grpc-transport instead.

GoDoc Widget Go Report Card Widget

Introduction

raft-grpc includes a GRPC service definition and implementation of a server and client for pipelining raft streams over GRPC.

To use it in your project, include the package and add the service to your GRPC server. The RaftGRPCTransport can be used as a raft.Transport object, and the GetServerService call will return the GRPC service implementation for your listener side.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LogEntryType_name = map[int32]string{
	0: "LOG_ENTRY_COMMAND",
	1: "LOG_ENTRY_NOOP",
	2: "LOG_ENTRY_ADD_PEER_DEPRECATED",
	3: "LOG_ENTRY_REMOVE_PEER_DEPRECATED",
	4: "LOG_ENTRY_BARRIER",
	5: "LOG_ENTRY_CONFIGURATION",
}
View Source
var LogEntryType_value = map[string]int32{
	"LOG_ENTRY_COMMAND":                0,
	"LOG_ENTRY_NOOP":                   1,
	"LOG_ENTRY_ADD_PEER_DEPRECATED":    2,
	"LOG_ENTRY_REMOVE_PEER_DEPRECATED": 3,
	"LOG_ENTRY_BARRIER":                4,
	"LOG_ENTRY_CONFIGURATION":          5,
}

Functions

func RegisterRaftServiceServer

func RegisterRaftServiceServer(s *grpc.Server, srv RaftServiceServer)

Types

type AppendEntriesPipelineResponse

type AppendEntriesPipelineResponse struct {
	// Error is any potential error.
	Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"`
	// Response is the response object if necessary
	Response             *AppendEntriesResponse `protobuf:"bytes,2,opt,name=response,proto3" json:"response,omitempty"`
	XXX_NoUnkeyedLiteral struct{}               `json:"-"`
	XXX_unrecognized     []byte                 `json:"-"`
	XXX_sizecache        int32                  `json:"-"`
}

AppendEntriesPipelineResponse is the wrapper of an AppendEntriesResponse in a pipeline.

func (*AppendEntriesPipelineResponse) Descriptor

func (*AppendEntriesPipelineResponse) Descriptor() ([]byte, []int)

func (*AppendEntriesPipelineResponse) GetError

func (m *AppendEntriesPipelineResponse) GetError() string

func (*AppendEntriesPipelineResponse) GetResponse

func (*AppendEntriesPipelineResponse) ProtoMessage

func (*AppendEntriesPipelineResponse) ProtoMessage()

func (*AppendEntriesPipelineResponse) Reset

func (m *AppendEntriesPipelineResponse) Reset()

func (*AppendEntriesPipelineResponse) String

func (*AppendEntriesPipelineResponse) XXX_DiscardUnknown

func (m *AppendEntriesPipelineResponse) XXX_DiscardUnknown()

func (*AppendEntriesPipelineResponse) XXX_Marshal

func (m *AppendEntriesPipelineResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*AppendEntriesPipelineResponse) XXX_Merge

func (m *AppendEntriesPipelineResponse) XXX_Merge(src proto.Message)

func (*AppendEntriesPipelineResponse) XXX_Size

func (m *AppendEntriesPipelineResponse) XXX_Size() int

func (*AppendEntriesPipelineResponse) XXX_Unmarshal

func (m *AppendEntriesPipelineResponse) XXX_Unmarshal(b []byte) error

type AppendEntriesRequest

type AppendEntriesRequest struct {
	// Term is the current election term.
	Term uint64 `protobuf:"varint,1,opt,name=term,proto3" json:"term,omitempty"`
	// Leader is the current leader id.
	Leader []byte `protobuf:"bytes,2,opt,name=leader,proto3" json:"leader,omitempty"`
	// PrevLogEntry is the previous log entry.
	PrevLogEntry uint64 `protobuf:"varint,3,opt,name=prev_log_entry,json=prevLogEntry,proto3" json:"prev_log_entry,omitempty"`
	// PrevLogTerm is the previous log term.
	PrevLogTerm uint64 `protobuf:"varint,4,opt,name=prev_log_term,json=prevLogTerm,proto3" json:"prev_log_term,omitempty"`
	// Entries are the new log entries to commit.
	Entries []*LogEntry `protobuf:"bytes,5,rep,name=entries,proto3" json:"entries,omitempty"`
	// LeaderCommitIndex is the commit index on the leader.
	LeaderCommitIndex    uint64      `protobuf:"varint,6,opt,name=leader_commit_index,json=leaderCommitIndex,proto3" json:"leader_commit_index,omitempty"`
	RaftHeader           *RaftHeader `protobuf:"bytes,99,opt,name=raft_header,json=raftHeader,proto3" json:"raft_header,omitempty"`
	XXX_NoUnkeyedLiteral struct{}    `json:"-"`
	XXX_unrecognized     []byte      `json:"-"`
	XXX_sizecache        int32       `json:"-"`
}

AppendEntriesRequest maps to the raft AppendEntriesRequest.

func NewAppendEntriesRequest

func NewAppendEntriesRequest(r *raft.AppendEntriesRequest) *AppendEntriesRequest

NewAppendEntriesRequest builds a new AppendEntriesRequest from a raft AppendEntriesRequest object.

func (*AppendEntriesRequest) Descriptor

func (*AppendEntriesRequest) Descriptor() ([]byte, []int)

func (*AppendEntriesRequest) GetEntries

func (m *AppendEntriesRequest) GetEntries() []*LogEntry

func (*AppendEntriesRequest) GetLeader

func (m *AppendEntriesRequest) GetLeader() []byte

func (*AppendEntriesRequest) GetLeaderCommitIndex

func (m *AppendEntriesRequest) GetLeaderCommitIndex() uint64

func (*AppendEntriesRequest) GetPrevLogEntry

func (m *AppendEntriesRequest) GetPrevLogEntry() uint64

func (*AppendEntriesRequest) GetPrevLogTerm

func (m *AppendEntriesRequest) GetPrevLogTerm() uint64

func (*AppendEntriesRequest) GetRaftHeader

func (m *AppendEntriesRequest) GetRaftHeader() *RaftHeader

func (*AppendEntriesRequest) GetTerm

func (m *AppendEntriesRequest) GetTerm() uint64

func (*AppendEntriesRequest) ProtoMessage

func (*AppendEntriesRequest) ProtoMessage()

func (*AppendEntriesRequest) Reset

func (m *AppendEntriesRequest) Reset()

func (*AppendEntriesRequest) String

func (m *AppendEntriesRequest) String() string

func (*AppendEntriesRequest) ToRaft

func (r *AppendEntriesRequest) ToRaft() interface{}

ToRaft converts the proto back to the raft object.

func (*AppendEntriesRequest) XXX_DiscardUnknown

func (m *AppendEntriesRequest) XXX_DiscardUnknown()

func (*AppendEntriesRequest) XXX_Marshal

func (m *AppendEntriesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*AppendEntriesRequest) XXX_Merge

func (m *AppendEntriesRequest) XXX_Merge(src proto.Message)

func (*AppendEntriesRequest) XXX_Size

func (m *AppendEntriesRequest) XXX_Size() int

func (*AppendEntriesRequest) XXX_Unmarshal

func (m *AppendEntriesRequest) XXX_Unmarshal(b []byte) error

type AppendEntriesResponse

type AppendEntriesResponse struct {
	// Term is the newer term if the leader is out of date.
	Term uint64 `protobuf:"varint,1,opt,name=term,proto3" json:"term,omitempty"`
	// LastLog is a hint to help accelerate rebuilding slow nodes.
	LastLog uint64 `protobuf:"varint,2,opt,name=last_log,json=lastLog,proto3" json:"last_log,omitempty"`
	// Success will be false if we have a conflicting entry.
	Success bool `protobuf:"varint,3,opt,name=success,proto3" json:"success,omitempty"`
	// NoRetryBackoff indicates we don't need to backoff the next attempt.
	NoRetryBackoff       bool        `protobuf:"varint,4,opt,name=no_retry_backoff,json=noRetryBackoff,proto3" json:"no_retry_backoff,omitempty"`
	RaftHeader           *RaftHeader `protobuf:"bytes,99,opt,name=raft_header,json=raftHeader,proto3" json:"raft_header,omitempty"`
	XXX_NoUnkeyedLiteral struct{}    `json:"-"`
	XXX_unrecognized     []byte      `json:"-"`
	XXX_sizecache        int32       `json:"-"`
}

AppendEntriesResponse is the response to the appendentries request.

func NewAppendEntriesResponse

func NewAppendEntriesResponse(r *raft.AppendEntriesResponse) *AppendEntriesResponse

NewAppendEntriesResponse builds a new AppendEntriesResponse from a raft AppendEntriesResponse object.

func (*AppendEntriesResponse) CopyToRaft

CopyToRaft copies to the equivalent raft type.

func (*AppendEntriesResponse) Descriptor

func (*AppendEntriesResponse) Descriptor() ([]byte, []int)

func (*AppendEntriesResponse) GetLastLog

func (m *AppendEntriesResponse) GetLastLog() uint64

func (*AppendEntriesResponse) GetNoRetryBackoff

func (m *AppendEntriesResponse) GetNoRetryBackoff() bool

func (*AppendEntriesResponse) GetRaftHeader

func (m *AppendEntriesResponse) GetRaftHeader() *RaftHeader

func (*AppendEntriesResponse) GetSuccess

func (m *AppendEntriesResponse) GetSuccess() bool

func (*AppendEntriesResponse) GetTerm

func (m *AppendEntriesResponse) GetTerm() uint64

func (*AppendEntriesResponse) ProtoMessage

func (*AppendEntriesResponse) ProtoMessage()

func (*AppendEntriesResponse) Reset

func (m *AppendEntriesResponse) Reset()

func (*AppendEntriesResponse) String

func (m *AppendEntriesResponse) String() string

func (*AppendEntriesResponse) XXX_DiscardUnknown

func (m *AppendEntriesResponse) XXX_DiscardUnknown()

func (*AppendEntriesResponse) XXX_Marshal

func (m *AppendEntriesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*AppendEntriesResponse) XXX_Merge

func (m *AppendEntriesResponse) XXX_Merge(src proto.Message)

func (*AppendEntriesResponse) XXX_Size

func (m *AppendEntriesResponse) XXX_Size() int

func (*AppendEntriesResponse) XXX_Unmarshal

func (m *AppendEntriesResponse) XXX_Unmarshal(b []byte) error

type InstallSnapshotRequest

type InstallSnapshotRequest struct {
	// Term is the current term.
	Term uint64 `protobuf:"varint,1,opt,name=term,proto3" json:"term,omitempty"`
	// Leader is the current leader.
	Leader []byte `protobuf:"bytes,2,opt,name=leader,proto3" json:"leader,omitempty"`
	// LastLogIndex is the last log index included in the snapshot.
	LastLogIndex uint64 `protobuf:"varint,3,opt,name=last_log_index,json=lastLogIndex,proto3" json:"last_log_index,omitempty"`
	// LastLogTerm is the last log term included in the snapshot.
	LastLogTerm uint64 `protobuf:"varint,4,opt,name=last_log_term,json=lastLogTerm,proto3" json:"last_log_term,omitempty"`
	// Peers is the peer set in the snapshot
	Peers []byte `protobuf:"bytes,5,opt,name=peers,proto3" json:"peers,omitempty"`
	// Configuration stores the cluster membership information.
	Configuration []byte `protobuf:"bytes,6,opt,name=configuration,proto3" json:"configuration,omitempty"`
	// ConfigurationIdx is the log index where configuration was originally committed.
	ConfigIdx uint64 `protobuf:"varint,7,opt,name=config_idx,json=configIdx,proto3" json:"config_idx,omitempty"`
	// Size is the size of the snapshot.
	Size                 int64       `protobuf:"varint,8,opt,name=size,proto3" json:"size,omitempty"`
	RaftHeader           *RaftHeader `protobuf:"bytes,99,opt,name=raft_header,json=raftHeader,proto3" json:"raft_header,omitempty"`
	XXX_NoUnkeyedLiteral struct{}    `json:"-"`
	XXX_unrecognized     []byte      `json:"-"`
	XXX_sizecache        int32       `json:"-"`
}

InstallSnapshotRequest is the command sent to a Raft peer to bootstrap its log (and state machine) from a snapshot on another peer.

func NewInstallSnapshotRequest

func NewInstallSnapshotRequest(r *raft.InstallSnapshotRequest) (*InstallSnapshotRequest, error)

NewInstallSnapshotRequest builds a new InstallSnapshotRequest from the raft type.

func (*InstallSnapshotRequest) Descriptor

func (*InstallSnapshotRequest) Descriptor() ([]byte, []int)

func (*InstallSnapshotRequest) GetConfigIdx

func (m *InstallSnapshotRequest) GetConfigIdx() uint64

func (*InstallSnapshotRequest) GetConfiguration

func (m *InstallSnapshotRequest) GetConfiguration() []byte

func (*InstallSnapshotRequest) GetLastLogIndex

func (m *InstallSnapshotRequest) GetLastLogIndex() uint64

func (*InstallSnapshotRequest) GetLastLogTerm

func (m *InstallSnapshotRequest) GetLastLogTerm() uint64

func (*InstallSnapshotRequest) GetLeader

func (m *InstallSnapshotRequest) GetLeader() []byte

func (*InstallSnapshotRequest) GetPeers

func (m *InstallSnapshotRequest) GetPeers() []byte

func (*InstallSnapshotRequest) GetRaftHeader

func (m *InstallSnapshotRequest) GetRaftHeader() *RaftHeader

func (*InstallSnapshotRequest) GetSize

func (m *InstallSnapshotRequest) GetSize() int64

func (*InstallSnapshotRequest) GetTerm

func (m *InstallSnapshotRequest) GetTerm() uint64

func (*InstallSnapshotRequest) ProtoMessage

func (*InstallSnapshotRequest) ProtoMessage()

func (*InstallSnapshotRequest) Reset

func (m *InstallSnapshotRequest) Reset()

func (*InstallSnapshotRequest) String

func (m *InstallSnapshotRequest) String() string

func (*InstallSnapshotRequest) ToRaft

func (r *InstallSnapshotRequest) ToRaft() interface{}

ToRaft converts the message to an equivalent raft type.

func (*InstallSnapshotRequest) XXX_DiscardUnknown

func (m *InstallSnapshotRequest) XXX_DiscardUnknown()

func (*InstallSnapshotRequest) XXX_Marshal

func (m *InstallSnapshotRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*InstallSnapshotRequest) XXX_Merge

func (m *InstallSnapshotRequest) XXX_Merge(src proto.Message)

func (*InstallSnapshotRequest) XXX_Size

func (m *InstallSnapshotRequest) XXX_Size() int

func (*InstallSnapshotRequest) XXX_Unmarshal

func (m *InstallSnapshotRequest) XXX_Unmarshal(b []byte) error

type InstallSnapshotResponse

type InstallSnapshotResponse struct {
	// Term is the term in the snapshot.
	Term uint64 `protobuf:"varint,1,opt,name=term,proto3" json:"term,omitempty"`
	// Success indiciates if the snapshot was installed properly.
	Success              bool        `protobuf:"varint,2,opt,name=success,proto3" json:"success,omitempty"`
	RaftHeader           *RaftHeader `protobuf:"bytes,99,opt,name=raft_header,json=raftHeader,proto3" json:"raft_header,omitempty"`
	XXX_NoUnkeyedLiteral struct{}    `json:"-"`
	XXX_unrecognized     []byte      `json:"-"`
	XXX_sizecache        int32       `json:"-"`
}

InstallSnapshotResponse is the response to the InstallSnapshot call.

func NewInstallSnapshotResponse

func NewInstallSnapshotResponse(r *raft.InstallSnapshotResponse) *InstallSnapshotResponse

NewInstallSnapshotResponse builds an InstallSnapshotResponse from the equivalent raft type.

func (*InstallSnapshotResponse) CopyToRaft

ToRaft converts the message to the equivalent raft type.

func (*InstallSnapshotResponse) Descriptor

func (*InstallSnapshotResponse) Descriptor() ([]byte, []int)

func (*InstallSnapshotResponse) GetRaftHeader

func (m *InstallSnapshotResponse) GetRaftHeader() *RaftHeader

func (*InstallSnapshotResponse) GetSuccess

func (m *InstallSnapshotResponse) GetSuccess() bool

func (*InstallSnapshotResponse) GetTerm

func (m *InstallSnapshotResponse) GetTerm() uint64

func (*InstallSnapshotResponse) ProtoMessage

func (*InstallSnapshotResponse) ProtoMessage()

func (*InstallSnapshotResponse) Reset

func (m *InstallSnapshotResponse) Reset()

func (*InstallSnapshotResponse) String

func (m *InstallSnapshotResponse) String() string

func (*InstallSnapshotResponse) XXX_DiscardUnknown

func (m *InstallSnapshotResponse) XXX_DiscardUnknown()

func (*InstallSnapshotResponse) XXX_Marshal

func (m *InstallSnapshotResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*InstallSnapshotResponse) XXX_Merge

func (m *InstallSnapshotResponse) XXX_Merge(src proto.Message)

func (*InstallSnapshotResponse) XXX_Size

func (m *InstallSnapshotResponse) XXX_Size() int

func (*InstallSnapshotResponse) XXX_Unmarshal

func (m *InstallSnapshotResponse) XXX_Unmarshal(b []byte) error

type InstallSnapshotStream

type InstallSnapshotStream struct {
	// Types that are valid to be assigned to Payload:
	//	*InstallSnapshotStream_Request
	//	*InstallSnapshotStream_Data
	Payload              isInstallSnapshotStream_Payload `protobuf_oneof:"payload"`
	XXX_NoUnkeyedLiteral struct{}                        `json:"-"`
	XXX_unrecognized     []byte                          `json:"-"`
	XXX_sizecache        int32                           `json:"-"`
}

InstallSnapshotStream encodes information used when transmitting a snapshot.

func (*InstallSnapshotStream) Descriptor

func (*InstallSnapshotStream) Descriptor() ([]byte, []int)

func (*InstallSnapshotStream) GetData

func (m *InstallSnapshotStream) GetData() []byte

func (*InstallSnapshotStream) GetPayload

func (m *InstallSnapshotStream) GetPayload() isInstallSnapshotStream_Payload

func (*InstallSnapshotStream) GetRequest

func (*InstallSnapshotStream) ProtoMessage

func (*InstallSnapshotStream) ProtoMessage()

func (*InstallSnapshotStream) Reset

func (m *InstallSnapshotStream) Reset()

func (*InstallSnapshotStream) String

func (m *InstallSnapshotStream) String() string

func (*InstallSnapshotStream) XXX_DiscardUnknown

func (m *InstallSnapshotStream) XXX_DiscardUnknown()

func (*InstallSnapshotStream) XXX_Marshal

func (m *InstallSnapshotStream) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*InstallSnapshotStream) XXX_Merge

func (m *InstallSnapshotStream) XXX_Merge(src proto.Message)

func (*InstallSnapshotStream) XXX_OneofWrappers

func (*InstallSnapshotStream) XXX_OneofWrappers() []interface{}

XXX_OneofWrappers is for the internal use of the proto package.

func (*InstallSnapshotStream) XXX_Size

func (m *InstallSnapshotStream) XXX_Size() int

func (*InstallSnapshotStream) XXX_Unmarshal

func (m *InstallSnapshotStream) XXX_Unmarshal(b []byte) error

type InstallSnapshotStream_Data

type InstallSnapshotStream_Data struct {
	Data []byte `protobuf:"bytes,2,opt,name=data,proto3,oneof"`
}

type InstallSnapshotStream_Request

type InstallSnapshotStream_Request struct {
	Request *InstallSnapshotRequest `protobuf:"bytes,1,opt,name=request,proto3,oneof"`
}

type LogEntry

type LogEntry struct {
	// Index holds the index of the log entry.
	Index uint64 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"`
	// Term holds the election term of the log entry.
	Term uint64 `protobuf:"varint,2,opt,name=term,proto3" json:"term,omitempty"`
	// Type holds the type of the log entry.
	Type LogEntryType `protobuf:"varint,3,opt,name=type,proto3,enum=raftgrpc.LogEntryType" json:"type,omitempty"`
	// Data holds the log entry's type-specific data.
	Data []byte `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"`
	// Extensions holds an opaque byte slice of information for middleware.
	Extensions           []byte   `protobuf:"bytes,5,opt,name=extensions,proto3" json:"extensions,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

LogEntry contains a raft log entry.

func NewLogEntry

func NewLogEntry(l *raft.Log) *LogEntry

NewLogEntry builds a new LogEntry from a raft.Log object.

func (*LogEntry) CopyRaft

func (r *LogEntry) CopyRaft(log *raft.Log)

CopyRaft converts to the equivalent raft type.

func (*LogEntry) Descriptor

func (*LogEntry) Descriptor() ([]byte, []int)

func (*LogEntry) GetData

func (m *LogEntry) GetData() []byte

func (*LogEntry) GetExtensions

func (m *LogEntry) GetExtensions() []byte

func (*LogEntry) GetIndex

func (m *LogEntry) GetIndex() uint64

func (*LogEntry) GetTerm

func (m *LogEntry) GetTerm() uint64

func (*LogEntry) GetType

func (m *LogEntry) GetType() LogEntryType

func (*LogEntry) ProtoMessage

func (*LogEntry) ProtoMessage()

func (*LogEntry) Reset

func (m *LogEntry) Reset()

func (*LogEntry) String

func (m *LogEntry) String() string

func (*LogEntry) ToRaft

func (r *LogEntry) ToRaft() *raft.Log

ToRaft converts to the equivalent raft type.

func (*LogEntry) XXX_DiscardUnknown

func (m *LogEntry) XXX_DiscardUnknown()

func (*LogEntry) XXX_Marshal

func (m *LogEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*LogEntry) XXX_Merge

func (m *LogEntry) XXX_Merge(src proto.Message)

func (*LogEntry) XXX_Size

func (m *LogEntry) XXX_Size() int

func (*LogEntry) XXX_Unmarshal

func (m *LogEntry) XXX_Unmarshal(b []byte) error

type LogEntryType

type LogEntryType int32

LogEntryType is the type of the LogEntry

const (
	LogEntryType_LOG_ENTRY_COMMAND                LogEntryType = 0
	LogEntryType_LOG_ENTRY_NOOP                   LogEntryType = 1
	LogEntryType_LOG_ENTRY_ADD_PEER_DEPRECATED    LogEntryType = 2
	LogEntryType_LOG_ENTRY_REMOVE_PEER_DEPRECATED LogEntryType = 3
	LogEntryType_LOG_ENTRY_BARRIER                LogEntryType = 4
	LogEntryType_LOG_ENTRY_CONFIGURATION          LogEntryType = 5
)

func (LogEntryType) EnumDescriptor

func (LogEntryType) EnumDescriptor() ([]byte, []int)

func (LogEntryType) String

func (x LogEntryType) String() string

type PeerNameContainer

type PeerNameContainer struct {
	// PeerName is the peer name in the container.
	PeerName             string   `protobuf:"bytes,1,opt,name=peer_name,json=peerName,proto3" json:"peer_name,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

PeerNameContainer encodes a peer name to bytes.

func (*PeerNameContainer) Descriptor

func (*PeerNameContainer) Descriptor() ([]byte, []int)

func (*PeerNameContainer) GetPeerName

func (m *PeerNameContainer) GetPeerName() string

func (*PeerNameContainer) ProtoMessage

func (*PeerNameContainer) ProtoMessage()

func (*PeerNameContainer) Reset

func (m *PeerNameContainer) Reset()

func (*PeerNameContainer) String

func (m *PeerNameContainer) String() string

func (*PeerNameContainer) XXX_DiscardUnknown

func (m *PeerNameContainer) XXX_DiscardUnknown()

func (*PeerNameContainer) XXX_Marshal

func (m *PeerNameContainer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PeerNameContainer) XXX_Merge

func (m *PeerNameContainer) XXX_Merge(src proto.Message)

func (*PeerNameContainer) XXX_Size

func (m *PeerNameContainer) XXX_Size() int

func (*PeerNameContainer) XXX_Unmarshal

func (m *PeerNameContainer) XXX_Unmarshal(b []byte) error

type RaftGRPCTransport

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

RaftGRPCTransport implements raft.Transport over GRPC.

func NewTransport

func NewTransport(ctx context.Context, localId string) *RaftGRPCTransport

NewTransport builds a new transport service.

func (*RaftGRPCTransport) AddPeer

func (t *RaftGRPCTransport) AddPeer(id string, peerConn RaftServiceClient)

AddPeer adds a peer by id to the transport.

func (*RaftGRPCTransport) AppendEntries

AppendEntries sends the appropriate RPC to the target node.

func (*RaftGRPCTransport) AppendEntriesPipeline

func (t *RaftGRPCTransport) AppendEntriesPipeline(
	target raft.ServerID,
	addr raft.ServerAddress,
) (raft.AppendPipeline, error)

AppendEntriesPipeline returns an interface that can be used to pipeline AppendEntries requests.

func (*RaftGRPCTransport) Consumer

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

Consumer returns a channel that raft uses to process incoming requests.

func (*RaftGRPCTransport) DecodePeer

func (*RaftGRPCTransport) DecodePeer(dat []byte) raft.ServerAddress

DecodePeer is used to deserialize a peer name.

func (*RaftGRPCTransport) EncodePeer

func (*RaftGRPCTransport) EncodePeer(id raft.ServerID, addr raft.ServerAddress) []byte

EncodePeer is used to serialize a peer name.

func (*RaftGRPCTransport) GetServerService

func (t *RaftGRPCTransport) GetServerService() RaftServiceServer

GetServerService returns a wrapper that contains the server methods.

func (*RaftGRPCTransport) InstallSnapshot

func (t *RaftGRPCTransport) InstallSnapshot(
	target raft.ServerID,
	addr raft.ServerAddress,
	args *raft.InstallSnapshotRequest,
	resp *raft.InstallSnapshotResponse,
	data io.Reader,
) error

InstallSnapshot is used to push a snapshot down to a follower. The data is read from the ReadCloser and streamed to the client.

func (*RaftGRPCTransport) LocalAddr

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

LocalAddr returns the local address to distinguish from peers.

func (*RaftGRPCTransport) RemovePeer

func (t *RaftGRPCTransport) RemovePeer(id string)

RemovePeer removes a peer by id from the transport.

func (*RaftGRPCTransport) RequestVote

RequestVote sends the appropriate RPC to the target node.

func (*RaftGRPCTransport) SetHeartbeatHandler

func (t *RaftGRPCTransport) SetHeartbeatHandler(
	cb func(rpc raft.RPC),
)

SetHeartbeatHandler is used to setup a heartbeat handler as a fast-pass. This is to avoid head-of-line blocking from disk IO. If a Transport does not support this, it can simply ignore the call, and push the heartbeat onto the Consumer channel.

func (*RaftGRPCTransport) TimeoutNow

func (t *RaftGRPCTransport) TimeoutNow(
	target raft.ServerID,
	addr raft.ServerAddress,
	args *raft.TimeoutNowRequest,
	resp *raft.TimeoutNowResponse,
) error

TimeoutNow is used to start a leadership transfer to the target node.

type RaftHeader

type RaftHeader struct {
	ProtocolVersion      int32    `protobuf:"varint,1,opt,name=protocol_version,json=protocolVersion,proto3" json:"protocol_version,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

RaftHeader describes information contained in every RPC command + response.

func (*RaftHeader) Descriptor

func (*RaftHeader) Descriptor() ([]byte, []int)

func (*RaftHeader) GetProtocolVersion

func (m *RaftHeader) GetProtocolVersion() int32

func (*RaftHeader) ProtoMessage

func (*RaftHeader) ProtoMessage()

func (*RaftHeader) Reset

func (m *RaftHeader) Reset()

func (*RaftHeader) String

func (m *RaftHeader) String() string

func (*RaftHeader) XXX_DiscardUnknown

func (m *RaftHeader) XXX_DiscardUnknown()

func (*RaftHeader) XXX_Marshal

func (m *RaftHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*RaftHeader) XXX_Merge

func (m *RaftHeader) XXX_Merge(src proto.Message)

func (*RaftHeader) XXX_Size

func (m *RaftHeader) XXX_Size() int

func (*RaftHeader) XXX_Unmarshal

func (m *RaftHeader) XXX_Unmarshal(b []byte) error

type RaftServiceClient

type RaftServiceClient interface {
	// AppendEntriesPipeline opens an AppendEntries message stream.
	AppendEntriesPipeline(ctx context.Context, opts ...grpc.CallOption) (RaftService_AppendEntriesPipelineClient, error)
	// AppendEntries performs a single append entries request / response.
	AppendEntries(ctx context.Context, in *AppendEntriesRequest, opts ...grpc.CallOption) (*AppendEntriesResponse, error)
	// RequestVote is the command used by a candidate to ask a Raft peer for a vote in an election.
	RequestVote(ctx context.Context, in *RequestVoteRequest, opts ...grpc.CallOption) (*RequestVoteResponse, error)
	// InstallSnapshot is the command sent to a Raft peer to bootstrap its log (and state machine) from a snapshot on another peer.
	InstallSnapshot(ctx context.Context, opts ...grpc.CallOption) (RaftService_InstallSnapshotClient, error)
	// TimeoutNow is used to start a leadership transfer to the target node.
	TimeoutNow(ctx context.Context, in *TimeoutNowRequest, opts ...grpc.CallOption) (*TimeoutNowResponse, error)
}

RaftServiceClient is the client API for RaftService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

type RaftServiceServer

type RaftServiceServer interface {
	// AppendEntriesPipeline opens an AppendEntries message stream.
	AppendEntriesPipeline(RaftService_AppendEntriesPipelineServer) error
	// AppendEntries performs a single append entries request / response.
	AppendEntries(context.Context, *AppendEntriesRequest) (*AppendEntriesResponse, error)
	// RequestVote is the command used by a candidate to ask a Raft peer for a vote in an election.
	RequestVote(context.Context, *RequestVoteRequest) (*RequestVoteResponse, error)
	// InstallSnapshot is the command sent to a Raft peer to bootstrap its log (and state machine) from a snapshot on another peer.
	InstallSnapshot(RaftService_InstallSnapshotServer) error
	// TimeoutNow is used to start a leadership transfer to the target node.
	TimeoutNow(context.Context, *TimeoutNowRequest) (*TimeoutNowResponse, error)
}

RaftServiceServer is the server API for RaftService service.

type RaftService_AppendEntriesPipelineClient

type RaftService_AppendEntriesPipelineClient interface {
	Send(*AppendEntriesRequest) error
	Recv() (*AppendEntriesPipelineResponse, error)
	grpc.ClientStream
}

type RaftService_AppendEntriesPipelineServer

type RaftService_AppendEntriesPipelineServer interface {
	Send(*AppendEntriesPipelineResponse) error
	Recv() (*AppendEntriesRequest, error)
	grpc.ServerStream
}

type RaftService_InstallSnapshotClient

type RaftService_InstallSnapshotClient interface {
	Send(*InstallSnapshotStream) error
	CloseAndRecv() (*InstallSnapshotResponse, error)
	grpc.ClientStream
}

type RaftService_InstallSnapshotServer

type RaftService_InstallSnapshotServer interface {
	SendAndClose(*InstallSnapshotResponse) error
	Recv() (*InstallSnapshotStream, error)
	grpc.ServerStream
}

type RequestVoteRequest

type RequestVoteRequest struct {
	// Term is the new voting term.
	Term uint64 `protobuf:"varint,1,opt,name=term,proto3" json:"term,omitempty"`
	// Candidate is the candidate id
	Candidate []byte `protobuf:"bytes,2,opt,name=candidate,proto3" json:"candidate,omitempty"`
	// LastLogIndex is the last log index.
	LastLogIndex uint64 `protobuf:"varint,3,opt,name=last_log_index,json=lastLogIndex,proto3" json:"last_log_index,omitempty"`
	// LastLogTerm is the last log term.
	LastLogTerm uint64 `protobuf:"varint,4,opt,name=last_log_term,json=lastLogTerm,proto3" json:"last_log_term,omitempty"`
	// LeadershipTransfer indicates to peers if the vote was triggered by
	// a leadership transfer.
	LeadershipTransfer   bool        `protobuf:"varint,5,opt,name=leadership_transfer,json=leadershipTransfer,proto3" json:"leadership_transfer,omitempty"`
	RaftHeader           *RaftHeader `protobuf:"bytes,99,opt,name=raft_header,json=raftHeader,proto3" json:"raft_header,omitempty"`
	XXX_NoUnkeyedLiteral struct{}    `json:"-"`
	XXX_unrecognized     []byte      `json:"-"`
	XXX_sizecache        int32       `json:"-"`
}

RequestVoteRequest is the command used by a candidate to ask a Raft peer for a vote in an election.

func NewRequestVoteRequest

func NewRequestVoteRequest(r *raft.RequestVoteRequest) *RequestVoteRequest

NewRequestVoteRequest builds the RequestVoteRequest message from the equivalent raft type.

func (*RequestVoteRequest) Descriptor

func (*RequestVoteRequest) Descriptor() ([]byte, []int)

func (*RequestVoteRequest) GetCandidate

func (m *RequestVoteRequest) GetCandidate() []byte

func (*RequestVoteRequest) GetLastLogIndex

func (m *RequestVoteRequest) GetLastLogIndex() uint64

func (*RequestVoteRequest) GetLastLogTerm

func (m *RequestVoteRequest) GetLastLogTerm() uint64

func (*RequestVoteRequest) GetLeadershipTransfer

func (m *RequestVoteRequest) GetLeadershipTransfer() bool

func (*RequestVoteRequest) GetRaftHeader

func (m *RequestVoteRequest) GetRaftHeader() *RaftHeader

func (*RequestVoteRequest) GetTerm

func (m *RequestVoteRequest) GetTerm() uint64

func (*RequestVoteRequest) ProtoMessage

func (*RequestVoteRequest) ProtoMessage()

func (*RequestVoteRequest) Reset

func (m *RequestVoteRequest) Reset()

func (*RequestVoteRequest) String

func (m *RequestVoteRequest) String() string

func (*RequestVoteRequest) ToRaft

func (r *RequestVoteRequest) ToRaft() interface{}

ToRaft converts to the equivalent raft type.

func (*RequestVoteRequest) XXX_DiscardUnknown

func (m *RequestVoteRequest) XXX_DiscardUnknown()

func (*RequestVoteRequest) XXX_Marshal

func (m *RequestVoteRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*RequestVoteRequest) XXX_Merge

func (m *RequestVoteRequest) XXX_Merge(src proto.Message)

func (*RequestVoteRequest) XXX_Size

func (m *RequestVoteRequest) XXX_Size() int

func (*RequestVoteRequest) XXX_Unmarshal

func (m *RequestVoteRequest) XXX_Unmarshal(b []byte) error

type RequestVoteResponse

type RequestVoteResponse struct {
	// Term is the newer term if the lader is out of date.
	Term uint64 `protobuf:"varint,1,opt,name=term,proto3" json:"term,omitempty"`
	// Peers contains the current peers list so a node can shutdown on removal.
	Peers []byte `protobuf:"bytes,2,opt,name=peers,proto3" json:"peers,omitempty"`
	// Granted if the vote was granted.
	Granted              bool        `protobuf:"varint,3,opt,name=granted,proto3" json:"granted,omitempty"`
	RaftHeader           *RaftHeader `protobuf:"bytes,99,opt,name=raft_header,json=raftHeader,proto3" json:"raft_header,omitempty"`
	XXX_NoUnkeyedLiteral struct{}    `json:"-"`
	XXX_unrecognized     []byte      `json:"-"`
	XXX_sizecache        int32       `json:"-"`
}

RequestVoteResponse is the response returned from a RequestVoteRequest.

func NewRequestVoteResponse

func NewRequestVoteResponse(r *raft.RequestVoteResponse) *RequestVoteResponse

NewRequestVoteResponse builds the RequestVoteResponse message from the equivalent raft type.

func (*RequestVoteResponse) CopyToRaft

func (r *RequestVoteResponse) CopyToRaft(o *raft.RequestVoteResponse)

ToRaft converts to the equivalent raft type.

func (*RequestVoteResponse) Descriptor

func (*RequestVoteResponse) Descriptor() ([]byte, []int)

func (*RequestVoteResponse) GetGranted

func (m *RequestVoteResponse) GetGranted() bool

func (*RequestVoteResponse) GetPeers

func (m *RequestVoteResponse) GetPeers() []byte

func (*RequestVoteResponse) GetRaftHeader

func (m *RequestVoteResponse) GetRaftHeader() *RaftHeader

func (*RequestVoteResponse) GetTerm

func (m *RequestVoteResponse) GetTerm() uint64

func (*RequestVoteResponse) ProtoMessage

func (*RequestVoteResponse) ProtoMessage()

func (*RequestVoteResponse) Reset

func (m *RequestVoteResponse) Reset()

func (*RequestVoteResponse) String

func (m *RequestVoteResponse) String() string

func (*RequestVoteResponse) XXX_DiscardUnknown

func (m *RequestVoteResponse) XXX_DiscardUnknown()

func (*RequestVoteResponse) XXX_Marshal

func (m *RequestVoteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*RequestVoteResponse) XXX_Merge

func (m *RequestVoteResponse) XXX_Merge(src proto.Message)

func (*RequestVoteResponse) XXX_Size

func (m *RequestVoteResponse) XXX_Size() int

func (*RequestVoteResponse) XXX_Unmarshal

func (m *RequestVoteResponse) XXX_Unmarshal(b []byte) error

type TimeoutNowRequest

type TimeoutNowRequest struct {
	RaftHeader           *RaftHeader `protobuf:"bytes,99,opt,name=raft_header,json=raftHeader,proto3" json:"raft_header,omitempty"`
	XXX_NoUnkeyedLiteral struct{}    `json:"-"`
	XXX_unrecognized     []byte      `json:"-"`
	XXX_sizecache        int32       `json:"-"`
}

TimeoutNowRequest is the command used by a leader to signal another server to start an election.

func NewTimeoutNowRequest

func NewTimeoutNowRequest(r *raft.TimeoutNowRequest) *TimeoutNowRequest

NewTimeoutNowRequest builds a TimeoutNowRequest struct from the equivalent raft type.

func (*TimeoutNowRequest) Descriptor

func (*TimeoutNowRequest) Descriptor() ([]byte, []int)

func (*TimeoutNowRequest) GetRaftHeader

func (m *TimeoutNowRequest) GetRaftHeader() *RaftHeader

func (*TimeoutNowRequest) ProtoMessage

func (*TimeoutNowRequest) ProtoMessage()

func (*TimeoutNowRequest) Reset

func (m *TimeoutNowRequest) Reset()

func (*TimeoutNowRequest) String

func (m *TimeoutNowRequest) String() string

func (*TimeoutNowRequest) ToRaft

func (r *TimeoutNowRequest) ToRaft() interface{}

ToRaft converts the message to an equivalent raft type.

func (*TimeoutNowRequest) XXX_DiscardUnknown

func (m *TimeoutNowRequest) XXX_DiscardUnknown()

func (*TimeoutNowRequest) XXX_Marshal

func (m *TimeoutNowRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TimeoutNowRequest) XXX_Merge

func (m *TimeoutNowRequest) XXX_Merge(src proto.Message)

func (*TimeoutNowRequest) XXX_Size

func (m *TimeoutNowRequest) XXX_Size() int

func (*TimeoutNowRequest) XXX_Unmarshal

func (m *TimeoutNowRequest) XXX_Unmarshal(b []byte) error

type TimeoutNowResponse

type TimeoutNowResponse struct {
	RaftHeader           *RaftHeader `protobuf:"bytes,99,opt,name=raft_header,json=raftHeader,proto3" json:"raft_header,omitempty"`
	XXX_NoUnkeyedLiteral struct{}    `json:"-"`
	XXX_unrecognized     []byte      `json:"-"`
	XXX_sizecache        int32       `json:"-"`
}

TimeoutNowResponse is the response to TimeoutNowRequest.

func NewTimeoutNowResponse

func NewTimeoutNowResponse(r *raft.TimeoutNowResponse) *TimeoutNowResponse

NewTimeoutNowResponse builds a TimeoutNowResponse struct from the equivalent raft type.

func (*TimeoutNowResponse) CopyToRaft

func (r *TimeoutNowResponse) CopyToRaft(resp *raft.TimeoutNowResponse)

ToRaft converts the message to the equivalent raft type.

func (*TimeoutNowResponse) Descriptor

func (*TimeoutNowResponse) Descriptor() ([]byte, []int)

func (*TimeoutNowResponse) GetRaftHeader

func (m *TimeoutNowResponse) GetRaftHeader() *RaftHeader

func (*TimeoutNowResponse) ProtoMessage

func (*TimeoutNowResponse) ProtoMessage()

func (*TimeoutNowResponse) Reset

func (m *TimeoutNowResponse) Reset()

func (*TimeoutNowResponse) String

func (m *TimeoutNowResponse) String() string

func (*TimeoutNowResponse) XXX_DiscardUnknown

func (m *TimeoutNowResponse) XXX_DiscardUnknown()

func (*TimeoutNowResponse) XXX_Marshal

func (m *TimeoutNowResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TimeoutNowResponse) XXX_Merge

func (m *TimeoutNowResponse) XXX_Merge(src proto.Message)

func (*TimeoutNowResponse) XXX_Size

func (m *TimeoutNowResponse) XXX_Size() int

func (*TimeoutNowResponse) XXX_Unmarshal

func (m *TimeoutNowResponse) XXX_Unmarshal(b []byte) error

type UnimplementedRaftServiceServer

type UnimplementedRaftServiceServer struct {
}

UnimplementedRaftServiceServer can be embedded to have forward compatible implementations.

func (*UnimplementedRaftServiceServer) AppendEntries

func (*UnimplementedRaftServiceServer) AppendEntriesPipeline

func (*UnimplementedRaftServiceServer) InstallSnapshot

func (*UnimplementedRaftServiceServer) RequestVote

func (*UnimplementedRaftServiceServer) TimeoutNow

Jump to

Keyboard shortcuts

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