Documentation ¶
Index ¶
- Variables
- func RegisterRaftProtocolServer(s *grpc.Server, srv RaftProtocolServer)
- type Client
- type CommandRequest
- func (*CommandRequest) Descriptor() ([]byte, []int)
- func (m *CommandRequest) GetValue() []byte
- func (m *CommandRequest) Marshal() (dAtA []byte, err error)
- func (m *CommandRequest) MarshalTo(dAtA []byte) (int, error)
- func (m *CommandRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*CommandRequest) ProtoMessage()
- func (m *CommandRequest) Reset()
- func (m *CommandRequest) Size() (n int)
- func (m *CommandRequest) String() string
- func (m *CommandRequest) Unmarshal(dAtA []byte) error
- func (m *CommandRequest) XXX_DiscardUnknown()
- func (m *CommandRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *CommandRequest) XXX_Merge(src proto.Message)
- func (m *CommandRequest) XXX_Size() int
- func (m *CommandRequest) XXX_Unmarshal(b []byte) error
- type CommandResponse
- func (*CommandResponse) Descriptor() ([]byte, []int)
- func (m *CommandResponse) GetError() string
- func (m *CommandResponse) GetValue() []byte
- func (m *CommandResponse) Marshal() (dAtA []byte, err error)
- func (m *CommandResponse) MarshalTo(dAtA []byte) (int, error)
- func (m *CommandResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*CommandResponse) ProtoMessage()
- func (m *CommandResponse) Reset()
- func (m *CommandResponse) Size() (n int)
- func (m *CommandResponse) String() string
- func (m *CommandResponse) Unmarshal(dAtA []byte) error
- func (m *CommandResponse) XXX_DiscardUnknown()
- func (m *CommandResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *CommandResponse) XXX_Merge(src proto.Message)
- func (m *CommandResponse) XXX_Size() int
- func (m *CommandResponse) XXX_Unmarshal(b []byte) error
- type Entry
- func (*Entry) Descriptor() ([]byte, []int)
- func (m *Entry) GetStreamID() streamID
- func (m *Entry) GetTimestamp() time.Time
- func (m *Entry) GetValue() []byte
- func (m *Entry) Marshal() (dAtA []byte, err error)
- func (m *Entry) MarshalTo(dAtA []byte) (int, error)
- func (m *Entry) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Entry) ProtoMessage()
- func (m *Entry) Reset()
- func (m *Entry) Size() (n int)
- func (m *Entry) String() string
- func (m *Entry) Unmarshal(dAtA []byte) error
- func (m *Entry) XXX_DiscardUnknown()
- func (m *Entry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Entry) XXX_Merge(src proto.Message)
- func (m *Entry) XXX_Size() int
- func (m *Entry) XXX_Unmarshal(b []byte) error
- type Protocol
- type QueryRequest
- func (*QueryRequest) Descriptor() ([]byte, []int)
- func (m *QueryRequest) GetValue() []byte
- func (m *QueryRequest) Marshal() (dAtA []byte, err error)
- func (m *QueryRequest) MarshalTo(dAtA []byte) (int, error)
- func (m *QueryRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*QueryRequest) ProtoMessage()
- func (m *QueryRequest) Reset()
- func (m *QueryRequest) Size() (n int)
- func (m *QueryRequest) String() string
- func (m *QueryRequest) Unmarshal(dAtA []byte) error
- func (m *QueryRequest) XXX_DiscardUnknown()
- func (m *QueryRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *QueryRequest) XXX_Merge(src proto.Message)
- func (m *QueryRequest) XXX_Size() int
- func (m *QueryRequest) XXX_Unmarshal(b []byte) error
- type QueryResponse
- func (*QueryResponse) Descriptor() ([]byte, []int)
- func (m *QueryResponse) GetError() string
- func (m *QueryResponse) GetValue() []byte
- func (m *QueryResponse) Marshal() (dAtA []byte, err error)
- func (m *QueryResponse) MarshalTo(dAtA []byte) (int, error)
- func (m *QueryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*QueryResponse) ProtoMessage()
- func (m *QueryResponse) Reset()
- func (m *QueryResponse) Size() (n int)
- func (m *QueryResponse) String() string
- func (m *QueryResponse) Unmarshal(dAtA []byte) error
- func (m *QueryResponse) XXX_DiscardUnknown()
- func (m *QueryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *QueryResponse) XXX_Merge(src proto.Message)
- func (m *QueryResponse) XXX_Size() int
- func (m *QueryResponse) XXX_Unmarshal(b []byte) error
- type Raft
- func (r *Raft) IsIDRemoved(id uint64) bool
- func (r *Raft) IsLeader() bool
- func (r *Raft) Leader() int
- func (r *Raft) Process(ctx context.Context, m raftpb.Message) error
- func (r *Raft) Propose(ctx context.Context, data []byte) error
- func (r *Raft) ReportSnapshot(id uint64, status raft.SnapshotStatus)
- func (r *Raft) ReportUnreachable(id uint64)
- type RaftProtocolClient
- type RaftProtocolServer
- type Server
- type StateMachine
- func (s *StateMachine) Apply(entry *raftpb.Entry) error
- func (s *StateMachine) Index() uint64
- func (s *StateMachine) Node() string
- func (s *StateMachine) OperationType() service.OperationType
- func (s *StateMachine) Query(value []byte, stream streams.WriteStream) error
- func (s *StateMachine) Restore(reader io.Reader) error
- func (s *StateMachine) Snapshot(writer io.Writer) error
- func (s *StateMachine) Timestamp() time.Time
- type UnimplementedRaftProtocolServer
Constants ¶
This section is empty.
Variables ¶
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) MustLeader ¶
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) 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) 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) GetStreamID ¶
func (m *Entry) GetStreamID() streamID
func (*Entry) GetTimestamp ¶
func (*Entry) ProtoMessage ¶
func (*Entry) ProtoMessage()
func (*Entry) XXX_DiscardUnknown ¶
func (m *Entry) XXX_DiscardUnknown()
func (*Entry) XXX_Marshal ¶
func (*Entry) XXX_Unmarshal ¶
type Protocol ¶
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
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) 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) 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 Raft ¶
type Raft struct {
// contains filtered or unexported fields
}
A key-value stream backed by raft
func (*Raft) IsIDRemoved ¶
func (*Raft) ReportSnapshot ¶
func (r *Raft) ReportSnapshot(id uint64, status raft.SnapshotStatus)
func (*Raft) ReportUnreachable ¶
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 is a Raft server
type StateMachine ¶
type StateMachine struct {
// contains filtered or unexported fields
}
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, stream streams.WriteStream) 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) Command(ctx context.Context, req *CommandRequest) (*CommandResponse, error)
func (*UnimplementedRaftProtocolServer) Query ¶
func (*UnimplementedRaftProtocolServer) Query(ctx context.Context, req *QueryRequest) (*QueryResponse, error)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.