raft

package
v0.0.0-...-fc753bc Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2019 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthProtocol        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowProtocol          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupProtocol = fmt.Errorf("proto: unexpected end of group")
)

Functions

func RegisterRaftProtocolServer

func RegisterRaftProtocolServer(s *grpc.Server, srv RaftProtocolServer)

Types

type Client

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

Client is the Raft client

func (*Client) IsLeader

func (c *Client) IsLeader() bool

func (*Client) Leader

func (c *Client) Leader() string

func (*Client) MustLeader

func (c *Client) MustLeader() bool

func (*Client) Read

func (c *Client) Read(ctx context.Context, input []byte, stream streams.Stream) error

func (*Client) Write

func (c *Client) Write(ctx context.Context, input []byte, stream streams.Stream) error

type CommandRequest

type CommandRequest struct {
	Value []byte `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
}

func (*CommandRequest) Descriptor

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

func (*CommandRequest) GetValue

func (m *CommandRequest) GetValue() []byte

func (*CommandRequest) Marshal

func (m *CommandRequest) Marshal() (dAtA []byte, err error)

func (*CommandRequest) MarshalTo

func (m *CommandRequest) MarshalTo(dAtA []byte) (int, error)

func (*CommandRequest) MarshalToSizedBuffer

func (m *CommandRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*CommandRequest) ProtoMessage

func (*CommandRequest) ProtoMessage()

func (*CommandRequest) Reset

func (m *CommandRequest) Reset()

func (*CommandRequest) Size

func (m *CommandRequest) Size() (n int)

func (*CommandRequest) String

func (m *CommandRequest) String() string

func (*CommandRequest) Unmarshal

func (m *CommandRequest) Unmarshal(dAtA []byte) error

func (*CommandRequest) XXX_DiscardUnknown

func (m *CommandRequest) XXX_DiscardUnknown()

func (*CommandRequest) XXX_Marshal

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

func (*CommandRequest) XXX_Merge

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

func (*CommandRequest) XXX_Size

func (m *CommandRequest) XXX_Size() int

func (*CommandRequest) XXX_Unmarshal

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

type CommandResponse

type CommandResponse struct {
	Value []byte `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
	Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"`
}

func (*CommandResponse) Descriptor

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

func (*CommandResponse) GetError

func (m *CommandResponse) GetError() string

func (*CommandResponse) GetValue

func (m *CommandResponse) GetValue() []byte

func (*CommandResponse) Marshal

func (m *CommandResponse) Marshal() (dAtA []byte, err error)

func (*CommandResponse) MarshalTo

func (m *CommandResponse) MarshalTo(dAtA []byte) (int, error)

func (*CommandResponse) MarshalToSizedBuffer

func (m *CommandResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*CommandResponse) ProtoMessage

func (*CommandResponse) ProtoMessage()

func (*CommandResponse) Reset

func (m *CommandResponse) Reset()

func (*CommandResponse) Size

func (m *CommandResponse) Size() (n int)

func (*CommandResponse) String

func (m *CommandResponse) String() string

func (*CommandResponse) Unmarshal

func (m *CommandResponse) Unmarshal(dAtA []byte) error

func (*CommandResponse) XXX_DiscardUnknown

func (m *CommandResponse) XXX_DiscardUnknown()

func (*CommandResponse) XXX_Marshal

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

func (*CommandResponse) XXX_Merge

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

func (*CommandResponse) XXX_Size

func (m *CommandResponse) XXX_Size() int

func (*CommandResponse) XXX_Unmarshal

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

type Entry

type Entry struct {
	// value is the value of the entry
	Value []byte `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
	// stream_id is the entry stream identifier
	StreamID streamID `protobuf:"varint,2,opt,name=stream_id,json=streamId,proto3,casttype=streamID" json:"stream_id,omitempty"`
	// timestamp is the entry timestamp
	Timestamp time.Time `protobuf:"bytes,3,opt,name=timestamp,proto3,stdtime" json:"timestamp"`
}

Entry is a Raft log entry

func (*Entry) Descriptor

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

func (*Entry) GetStreamID

func (m *Entry) GetStreamID() streamID

func (*Entry) GetTimestamp

func (m *Entry) GetTimestamp() time.Time

func (*Entry) GetValue

func (m *Entry) GetValue() []byte

func (*Entry) Marshal

func (m *Entry) Marshal() (dAtA []byte, err error)

func (*Entry) MarshalTo

func (m *Entry) MarshalTo(dAtA []byte) (int, error)

func (*Entry) MarshalToSizedBuffer

func (m *Entry) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Entry) ProtoMessage

func (*Entry) ProtoMessage()

func (*Entry) Reset

func (m *Entry) Reset()

func (*Entry) Size

func (m *Entry) Size() (n int)

func (*Entry) String

func (m *Entry) String() string

func (*Entry) Unmarshal

func (m *Entry) Unmarshal(dAtA []byte) error

func (*Entry) XXX_DiscardUnknown

func (m *Entry) XXX_DiscardUnknown()

func (*Entry) XXX_Marshal

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

func (*Entry) XXX_Merge

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

func (*Entry) XXX_Size

func (m *Entry) XXX_Size() int

func (*Entry) XXX_Unmarshal

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

type Protocol

type Protocol struct {
	node.Protocol
	// contains filtered or unexported fields
}

Protocol is an implementation of the Client interface providing the Raft consensus protocol

func NewProtocol

func NewProtocol(config *config.ProtocolConfig) *Protocol

NewProtocol returns a new Raft Protocol instance

func (*Protocol) Client

func (p *Protocol) Client() node.Client

Client returns the Raft protocol client

func (*Protocol) Start

func (p *Protocol) Start(cluster cluster.Cluster, registry *node.Registry) error

Start starts the Raft protocol

func (*Protocol) Stop

func (p *Protocol) Stop() error

Stop stops the Raft protocol

type QueryRequest

type QueryRequest struct {
	Value []byte `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
}

func (*QueryRequest) Descriptor

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

func (*QueryRequest) GetValue

func (m *QueryRequest) GetValue() []byte

func (*QueryRequest) Marshal

func (m *QueryRequest) Marshal() (dAtA []byte, err error)

func (*QueryRequest) MarshalTo

func (m *QueryRequest) MarshalTo(dAtA []byte) (int, error)

func (*QueryRequest) MarshalToSizedBuffer

func (m *QueryRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*QueryRequest) ProtoMessage

func (*QueryRequest) ProtoMessage()

func (*QueryRequest) Reset

func (m *QueryRequest) Reset()

func (*QueryRequest) Size

func (m *QueryRequest) Size() (n int)

func (*QueryRequest) String

func (m *QueryRequest) String() string

func (*QueryRequest) Unmarshal

func (m *QueryRequest) Unmarshal(dAtA []byte) error

func (*QueryRequest) XXX_DiscardUnknown

func (m *QueryRequest) XXX_DiscardUnknown()

func (*QueryRequest) XXX_Marshal

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

func (*QueryRequest) XXX_Merge

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

func (*QueryRequest) XXX_Size

func (m *QueryRequest) XXX_Size() int

func (*QueryRequest) XXX_Unmarshal

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

type QueryResponse

type QueryResponse struct {
	Value []byte `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
	Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"`
}

func (*QueryResponse) Descriptor

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

func (*QueryResponse) GetError

func (m *QueryResponse) GetError() string

func (*QueryResponse) GetValue

func (m *QueryResponse) GetValue() []byte

func (*QueryResponse) Marshal

func (m *QueryResponse) Marshal() (dAtA []byte, err error)

func (*QueryResponse) MarshalTo

func (m *QueryResponse) MarshalTo(dAtA []byte) (int, error)

func (*QueryResponse) MarshalToSizedBuffer

func (m *QueryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*QueryResponse) ProtoMessage

func (*QueryResponse) ProtoMessage()

func (*QueryResponse) Reset

func (m *QueryResponse) Reset()

func (*QueryResponse) Size

func (m *QueryResponse) Size() (n int)

func (*QueryResponse) String

func (m *QueryResponse) String() string

func (*QueryResponse) Unmarshal

func (m *QueryResponse) Unmarshal(dAtA []byte) error

func (*QueryResponse) XXX_DiscardUnknown

func (m *QueryResponse) XXX_DiscardUnknown()

func (*QueryResponse) XXX_Marshal

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

func (*QueryResponse) XXX_Merge

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

func (*QueryResponse) XXX_Size

func (m *QueryResponse) XXX_Size() int

func (*QueryResponse) XXX_Unmarshal

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

type RaftProtocolClient

type RaftProtocolClient interface {
	Command(ctx context.Context, in *CommandRequest, opts ...grpc.CallOption) (*CommandResponse, error)
	Query(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error)
}

RaftProtocolClient is the client API for RaftProtocol service.

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

func NewRaftProtocolClient

func NewRaftProtocolClient(cc *grpc.ClientConn) RaftProtocolClient

type RaftProtocolServer

type RaftProtocolServer interface {
	Command(context.Context, *CommandRequest) (*CommandResponse, error)
	Query(context.Context, *QueryRequest) (*QueryResponse, error)
}

RaftProtocolServer is the server API for RaftProtocol service.

type Server

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

Server implements the Raft consensus protocol server

func (*Server) Start

func (s *Server) Start() error

Start starts the Raft server

func (*Server) Stop

func (s *Server) Stop() error

Stop shuts down the Raft server

type StateMachine

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

func (*StateMachine) Apply

func (s *StateMachine) Apply(log *raft.Log) interface{}

func (*StateMachine) Index

func (s *StateMachine) Index() uint64

func (*StateMachine) Node

func (s *StateMachine) Node() string

func (*StateMachine) OperationType

func (s *StateMachine) OperationType() service.OperationType

func (*StateMachine) Query

func (s *StateMachine) Query(value []byte, ch chan<- streams.Result) error

func (*StateMachine) Restore

func (s *StateMachine) Restore(reader io.ReadCloser) error

func (*StateMachine) Snapshot

func (s *StateMachine) Snapshot() (raft.FSMSnapshot, error)

func (*StateMachine) Timestamp

func (s *StateMachine) Timestamp() time.Time

type UnimplementedRaftProtocolServer

type UnimplementedRaftProtocolServer struct {
}

UnimplementedRaftProtocolServer can be embedded to have forward compatible implementations.

func (*UnimplementedRaftProtocolServer) Command

func (*UnimplementedRaftProtocolServer) Query

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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