pb

package
v0.0.0-...-a5b6b36 Latest Latest
Warning

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

Go to latest
Published: May 11, 2017 License: MIT Imports: 5 Imported by: 6

Documentation

Overview

Package pb is a generated protocol buffer package.

It is generated from these files:

raft.proto
raftkv.proto

It has these top-level messages:

AppendEntriesReq
AppendEntriesRes
RequestVoteReq
RequestVoteRes
KVCommand
Session
GetReq
GetRes
PutReq
PutRes
OpenSessionReq
OpenSessionRes

Index

Constants

This section is empty.

Variables

View Source
var CommandType_name = map[int32]string{
	0: "Noop",
	1: "Get",
	2: "Put",
}
View Source
var CommandType_value = map[string]int32{
	"Noop": 0,
	"Get":  1,
	"Put":  2,
}
View Source
var RaftRole_name = map[int32]string{
	0: "Follower",
	1: "Candidate",
	2: "Leader",
}
View Source
var RaftRole_value = map[string]int32{
	"Follower":  0,
	"Candidate": 1,
	"Leader":    2,
}
View Source
var Status_name = map[int32]string{
	0: "OK",
	1: "Timeout",
	2: "NoSuchKey",
	3: "NotLeader",
	4: "NoSession",
}
View Source
var Status_value = map[string]int32{
	"OK":        0,
	"Timeout":   1,
	"NoSuchKey": 2,
	"NotLeader": 3,
	"NoSession": 4,
}

Functions

func RegisterRaftKVServer

func RegisterRaftKVServer(s *grpc.Server, srv RaftKVServer)

func RegisterRaftServer

func RegisterRaftServer(s *grpc.Server, srv RaftServer)

Types

type AppendEntriesReq

type AppendEntriesReq struct {
	Term         int32        `protobuf:"varint,1,opt,name=term" json:"term,omitempty"`
	LeaderId     int32        `protobuf:"varint,2,opt,name=leader_id,json=leaderId" json:"leader_id,omitempty"`
	PrevLogIndex int32        `protobuf:"varint,3,opt,name=prev_log_index,json=prevLogIndex" json:"prev_log_index,omitempty"`
	PrevLogTerm  int32        `protobuf:"varint,4,opt,name=prev_log_term,json=prevLogTerm" json:"prev_log_term,omitempty"`
	LogEntries   []*KVCommand `protobuf:"bytes,5,rep,name=log_entries,json=logEntries" json:"log_entries,omitempty"`
	LeaderCommit int32        `protobuf:"varint,6,opt,name=leader_commit,json=leaderCommit" json:"leader_commit,omitempty"`
}

func (*AppendEntriesReq) Descriptor

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

func (*AppendEntriesReq) GetLeaderCommit

func (m *AppendEntriesReq) GetLeaderCommit() int32

func (*AppendEntriesReq) GetLeaderId

func (m *AppendEntriesReq) GetLeaderId() int32

func (*AppendEntriesReq) GetLogEntries

func (m *AppendEntriesReq) GetLogEntries() []*KVCommand

func (*AppendEntriesReq) GetPrevLogIndex

func (m *AppendEntriesReq) GetPrevLogIndex() int32

func (*AppendEntriesReq) GetPrevLogTerm

func (m *AppendEntriesReq) GetPrevLogTerm() int32

func (*AppendEntriesReq) GetTerm

func (m *AppendEntriesReq) GetTerm() int32

func (*AppendEntriesReq) ProtoMessage

func (*AppendEntriesReq) ProtoMessage()

func (*AppendEntriesReq) Reset

func (m *AppendEntriesReq) Reset()

func (*AppendEntriesReq) String

func (m *AppendEntriesReq) String() string

type AppendEntriesRes

type AppendEntriesRes struct {
	Term    int32 `protobuf:"varint,1,opt,name=term" json:"term,omitempty"`
	Success bool  `protobuf:"varint,2,opt,name=success" json:"success,omitempty"`
}

func (*AppendEntriesRes) Descriptor

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

func (*AppendEntriesRes) GetSuccess

func (m *AppendEntriesRes) GetSuccess() bool

func (*AppendEntriesRes) GetTerm

func (m *AppendEntriesRes) GetTerm() int32

func (*AppendEntriesRes) ProtoMessage

func (*AppendEntriesRes) ProtoMessage()

func (*AppendEntriesRes) Reset

func (m *AppendEntriesRes) Reset()

func (*AppendEntriesRes) String

func (m *AppendEntriesRes) String() string

type CommandType

type CommandType int32
const (
	CommandType_Noop CommandType = 0
	CommandType_Get  CommandType = 1
	CommandType_Put  CommandType = 2
)

func (CommandType) EnumDescriptor

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

func (CommandType) String

func (x CommandType) String() string

type GetReq

type GetReq struct {
	Session *Session `protobuf:"bytes,1,opt,name=session" json:"session,omitempty"`
	Key     string   `protobuf:"bytes,2,opt,name=key" json:"key,omitempty"`
}

func (*GetReq) Descriptor

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

func (*GetReq) GetKey

func (m *GetReq) GetKey() string

func (*GetReq) GetSession

func (m *GetReq) GetSession() *Session

func (*GetReq) ProtoMessage

func (*GetReq) ProtoMessage()

func (*GetReq) Reset

func (m *GetReq) Reset()

func (*GetReq) String

func (m *GetReq) String() string

type GetRes

type GetRes struct {
	Status Status `protobuf:"varint,1,opt,name=status,enum=pb.Status" json:"status,omitempty"`
	Value  string `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"`
}

func (*GetRes) Descriptor

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

func (*GetRes) GetStatus

func (m *GetRes) GetStatus() Status

func (*GetRes) GetValue

func (m *GetRes) GetValue() string

func (*GetRes) ProtoMessage

func (*GetRes) ProtoMessage()

func (*GetRes) Reset

func (m *GetRes) Reset()

func (*GetRes) String

func (m *GetRes) String() string

type KVCommand

type KVCommand struct {
	CmdType CommandType `protobuf:"varint,1,opt,name=cmd_type,json=cmdType,enum=pb.CommandType" json:"cmd_type,omitempty"`
	// Types that are valid to be assigned to Command:
	//	*KVCommand_GetCommand
	//	*KVCommand_PutCommand
	//	*KVCommand_Noop
	Command   isKVCommand_Command `protobuf_oneof:"command"`
	Term      int32               `protobuf:"varint,5,opt,name=term" json:"term,omitempty"`
	Index     int32               `protobuf:"varint,6,opt,name=index" json:"index,omitempty"`
	Timestamp int64               `protobuf:"varint,7,opt,name=timestamp" json:"timestamp,omitempty"`
}

command for KV, it will be replicated to peers, stored in log, and applied to KVStorage

func (*KVCommand) Descriptor

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

func (*KVCommand) GetCmdType

func (m *KVCommand) GetCmdType() CommandType

func (*KVCommand) GetCommand

func (m *KVCommand) GetCommand() isKVCommand_Command

func (*KVCommand) GetGetCommand

func (m *KVCommand) GetGetCommand() *GetReq

func (*KVCommand) GetIndex

func (m *KVCommand) GetIndex() int32

func (*KVCommand) GetNoop

func (m *KVCommand) GetNoop() []byte

func (*KVCommand) GetPutCommand

func (m *KVCommand) GetPutCommand() *PutReq

func (*KVCommand) GetTerm

func (m *KVCommand) GetTerm() int32

func (*KVCommand) GetTimestamp

func (m *KVCommand) GetTimestamp() int64

func (*KVCommand) ProtoMessage

func (*KVCommand) ProtoMessage()

func (*KVCommand) Reset

func (m *KVCommand) Reset()

func (*KVCommand) String

func (m *KVCommand) String() string

func (*KVCommand) XXX_OneofFuncs

func (*KVCommand) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{})

XXX_OneofFuncs is for the internal use of the proto package.

type KVCommand_GetCommand

type KVCommand_GetCommand struct {
	GetCommand *GetReq `protobuf:"bytes,2,opt,name=get_command,json=getCommand,oneof"`
}

type KVCommand_Noop

type KVCommand_Noop struct {
	Noop []byte `protobuf:"bytes,4,opt,name=noop,proto3,oneof"`
}

type KVCommand_PutCommand

type KVCommand_PutCommand struct {
	PutCommand *PutReq `protobuf:"bytes,3,opt,name=put_command,json=putCommand,oneof"`
}

type OpenSessionReq

type OpenSessionReq struct {
	Session *Session `protobuf:"bytes,1,opt,name=session" json:"session,omitempty"`
}

func (*OpenSessionReq) Descriptor

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

func (*OpenSessionReq) GetSession

func (m *OpenSessionReq) GetSession() *Session

func (*OpenSessionReq) ProtoMessage

func (*OpenSessionReq) ProtoMessage()

func (*OpenSessionReq) Reset

func (m *OpenSessionReq) Reset()

func (*OpenSessionReq) String

func (m *OpenSessionReq) String() string

type OpenSessionRes

type OpenSessionRes struct {
	ClientId int64 `protobuf:"varint,1,opt,name=client_id,json=clientId" json:"client_id,omitempty"`
}

func (*OpenSessionRes) Descriptor

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

func (*OpenSessionRes) GetClientId

func (m *OpenSessionRes) GetClientId() int64

func (*OpenSessionRes) ProtoMessage

func (*OpenSessionRes) ProtoMessage()

func (*OpenSessionRes) Reset

func (m *OpenSessionRes) Reset()

func (*OpenSessionRes) String

func (m *OpenSessionRes) String() string

type PutReq

type PutReq struct {
	Session *Session `protobuf:"bytes,1,opt,name=session" json:"session,omitempty"`
	Key     string   `protobuf:"bytes,2,opt,name=key" json:"key,omitempty"`
	Value   string   `protobuf:"bytes,3,opt,name=value" json:"value,omitempty"`
}

func (*PutReq) Descriptor

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

func (*PutReq) GetKey

func (m *PutReq) GetKey() string

func (*PutReq) GetSession

func (m *PutReq) GetSession() *Session

func (*PutReq) GetValue

func (m *PutReq) GetValue() string

func (*PutReq) ProtoMessage

func (*PutReq) ProtoMessage()

func (*PutReq) Reset

func (m *PutReq) Reset()

func (*PutReq) String

func (m *PutReq) String() string

type PutRes

type PutRes struct {
	Status Status `protobuf:"varint,1,opt,name=status,enum=pb.Status" json:"status,omitempty"`
}

func (*PutRes) Descriptor

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

func (*PutRes) GetStatus

func (m *PutRes) GetStatus() Status

func (*PutRes) ProtoMessage

func (*PutRes) ProtoMessage()

func (*PutRes) Reset

func (m *PutRes) Reset()

func (*PutRes) String

func (m *PutRes) String() string

type RaftClient

type RaftClient interface {
	RequestVote(ctx context.Context, in *RequestVoteReq, opts ...grpc.CallOption) (*RequestVoteRes, error)
	AppendEntries(ctx context.Context, in *AppendEntriesReq, opts ...grpc.CallOption) (*AppendEntriesRes, error)
}

func NewRaftClient

func NewRaftClient(cc *grpc.ClientConn) RaftClient

type RaftKVClient

type RaftKVClient interface {
	OpenSession(ctx context.Context, in *OpenSessionReq, opts ...grpc.CallOption) (*OpenSessionRes, error)
	Put(ctx context.Context, in *PutReq, opts ...grpc.CallOption) (*PutRes, error)
	Get(ctx context.Context, in *GetReq, opts ...grpc.CallOption) (*GetRes, error)
}

func NewRaftKVClient

func NewRaftKVClient(cc *grpc.ClientConn) RaftKVClient

type RaftKVServer

type RaftKVServer interface {
	OpenSession(context.Context, *OpenSessionReq) (*OpenSessionRes, error)
	Put(context.Context, *PutReq) (*PutRes, error)
	Get(context.Context, *GetReq) (*GetRes, error)
}

type RaftRole

type RaftRole int32
const (
	RaftRole_Follower  RaftRole = 0
	RaftRole_Candidate RaftRole = 1
	RaftRole_Leader    RaftRole = 2
)

func (RaftRole) EnumDescriptor

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

func (RaftRole) String

func (x RaftRole) String() string

type RaftServer

type RaftServer interface {
	RequestVote(context.Context, *RequestVoteReq) (*RequestVoteRes, error)
	AppendEntries(context.Context, *AppendEntriesReq) (*AppendEntriesRes, error)
}

type RequestVoteReq

type RequestVoteReq struct {
	Term         int32 `protobuf:"varint,1,opt,name=term" json:"term,omitempty"`
	CandidateId  int32 `protobuf:"varint,2,opt,name=candidate_id,json=candidateId" json:"candidate_id,omitempty"`
	LastLogIndex int32 `protobuf:"varint,3,opt,name=last_log_index,json=lastLogIndex" json:"last_log_index,omitempty"`
	LastLogTerm  int32 `protobuf:"varint,4,opt,name=last_log_term,json=lastLogTerm" json:"last_log_term,omitempty"`
}

func (*RequestVoteReq) Descriptor

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

func (*RequestVoteReq) GetCandidateId

func (m *RequestVoteReq) GetCandidateId() int32

func (*RequestVoteReq) GetLastLogIndex

func (m *RequestVoteReq) GetLastLogIndex() int32

func (*RequestVoteReq) GetLastLogTerm

func (m *RequestVoteReq) GetLastLogTerm() int32

func (*RequestVoteReq) GetTerm

func (m *RequestVoteReq) GetTerm() int32

func (*RequestVoteReq) ProtoMessage

func (*RequestVoteReq) ProtoMessage()

func (*RequestVoteReq) Reset

func (m *RequestVoteReq) Reset()

func (*RequestVoteReq) String

func (m *RequestVoteReq) String() string

type RequestVoteRes

type RequestVoteRes struct {
	Term        int32 `protobuf:"varint,1,opt,name=term" json:"term,omitempty"`
	VoteGranted bool  `protobuf:"varint,2,opt,name=vote_granted,json=voteGranted" json:"vote_granted,omitempty"`
}

func (*RequestVoteRes) Descriptor

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

func (*RequestVoteRes) GetTerm

func (m *RequestVoteRes) GetTerm() int32

func (*RequestVoteRes) GetVoteGranted

func (m *RequestVoteRes) GetVoteGranted() bool

func (*RequestVoteRes) ProtoMessage

func (*RequestVoteRes) ProtoMessage()

func (*RequestVoteRes) Reset

func (m *RequestVoteRes) Reset()

func (*RequestVoteRes) String

func (m *RequestVoteRes) String() string

type Session

type Session struct {
	ClientId int64  `protobuf:"varint,1,opt,name=client_id,json=clientId" json:"client_id,omitempty"`
	Sn       int64  `protobuf:"varint,2,opt,name=sn" json:"sn,omitempty"`
	LogId    string `protobuf:"bytes,3,opt,name=log_id,json=logId" json:"log_id,omitempty"`
}

func (*Session) Descriptor

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

func (*Session) GetClientId

func (m *Session) GetClientId() int64

func (*Session) GetLogId

func (m *Session) GetLogId() string

func (*Session) GetSn

func (m *Session) GetSn() int64

func (*Session) ProtoMessage

func (*Session) ProtoMessage()

func (*Session) Reset

func (m *Session) Reset()

func (*Session) String

func (m *Session) String() string

type Status

type Status int32
const (
	Status_OK        Status = 0
	Status_Timeout   Status = 1
	Status_NoSuchKey Status = 2
	Status_NotLeader Status = 3
	Status_NoSession Status = 4
)

func (Status) EnumDescriptor

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

func (Status) String

func (x Status) String() string

Jump to

Keyboard shortcuts

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