Documentation ¶
Overview ¶
Package proton is a generated protocol buffer package.
It is generated from these files:
proton.proto
It has these top-level messages:
JoinRaftResponse LeaveRaftResponse SendResponse PutObjectRequest PutObjectResponse ListObjectsRequest ListObjectsResponse ListMembersRequest ListMembersResponse NodeInfo Pair
Index ¶
- Constants
- Variables
- func DefaultNodeConfig() *raft.Config
- func EncodePair(key string, value []byte) ([]byte, error)
- func GenID(hostname string) uint64
- func Register(server *grpc.Server, node *Node)
- func RegisterRaftServer(s *grpc.Server, srv RaftServer)
- type ApplyCommand
- type Cluster
- type JoinRaftResponse
- func (m *JoinRaftResponse) GetNodes() []*NodeInfo
- func (m *JoinRaftResponse) Marshal() (data []byte, err error)
- func (m *JoinRaftResponse) MarshalTo(data []byte) (int, error)
- func (*JoinRaftResponse) ProtoMessage()
- func (m *JoinRaftResponse) Reset()
- func (m *JoinRaftResponse) Size() (n int)
- func (m *JoinRaftResponse) String() string
- func (m *JoinRaftResponse) Unmarshal(data []byte) error
- type LeaveRaftResponse
- func (m *LeaveRaftResponse) Marshal() (data []byte, err error)
- func (m *LeaveRaftResponse) MarshalTo(data []byte) (int, error)
- func (*LeaveRaftResponse) ProtoMessage()
- func (m *LeaveRaftResponse) Reset()
- func (m *LeaveRaftResponse) Size() (n int)
- func (m *LeaveRaftResponse) String() string
- func (m *LeaveRaftResponse) Unmarshal(data []byte) error
- type ListMembersRequest
- func (m *ListMembersRequest) Marshal() (data []byte, err error)
- func (m *ListMembersRequest) MarshalTo(data []byte) (int, error)
- func (*ListMembersRequest) ProtoMessage()
- func (m *ListMembersRequest) Reset()
- func (m *ListMembersRequest) Size() (n int)
- func (m *ListMembersRequest) String() string
- func (m *ListMembersRequest) Unmarshal(data []byte) error
- type ListMembersResponse
- func (m *ListMembersResponse) GetMembers() []*NodeInfo
- func (m *ListMembersResponse) Marshal() (data []byte, err error)
- func (m *ListMembersResponse) MarshalTo(data []byte) (int, error)
- func (*ListMembersResponse) ProtoMessage()
- func (m *ListMembersResponse) Reset()
- func (m *ListMembersResponse) Size() (n int)
- func (m *ListMembersResponse) String() string
- func (m *ListMembersResponse) Unmarshal(data []byte) error
- type ListObjectsRequest
- func (m *ListObjectsRequest) Marshal() (data []byte, err error)
- func (m *ListObjectsRequest) MarshalTo(data []byte) (int, error)
- func (*ListObjectsRequest) ProtoMessage()
- func (m *ListObjectsRequest) Reset()
- func (m *ListObjectsRequest) Size() (n int)
- func (m *ListObjectsRequest) String() string
- func (m *ListObjectsRequest) Unmarshal(data []byte) error
- type ListObjectsResponse
- func (m *ListObjectsResponse) GetObjects() []*Pair
- func (m *ListObjectsResponse) Marshal() (data []byte, err error)
- func (m *ListObjectsResponse) MarshalTo(data []byte) (int, error)
- func (*ListObjectsResponse) ProtoMessage()
- func (m *ListObjectsResponse) Reset()
- func (m *ListObjectsResponse) Size() (n int)
- func (m *ListObjectsResponse) String() string
- func (m *ListObjectsResponse) Unmarshal(data []byte) error
- type Node
- func (n *Node) Get(key string) string
- func (n *Node) IsLeader() bool
- func (n *Node) IsPaused() bool
- func (n *Node) JoinRaft(ctx context.Context, info *NodeInfo) (*JoinRaftResponse, error)
- func (n *Node) Leader() uint64
- func (n *Node) LeaveRaft(ctx context.Context, info *NodeInfo) (*LeaveRaftResponse, error)
- func (n *Node) ListMembers(ctx context.Context, req *ListMembersRequest) (*ListMembersResponse, error)
- func (n *Node) ListObjects(ctx context.Context, req *ListObjectsRequest) (*ListObjectsResponse, error)
- func (n *Node) ListPairs() []*Pair
- func (n *Node) Pause()
- func (n *Node) Put(key string, value string)
- func (n *Node) PutObject(ctx context.Context, req *PutObjectRequest) (*PutObjectResponse, error)
- func (n *Node) RegisterNode(node *NodeInfo) error
- func (n *Node) RegisterNodes(nodes []*NodeInfo) (err error)
- func (n *Node) RemoveNode(node *Peer) error
- func (n *Node) Resume()
- func (n *Node) Send(ctx context.Context, msg *raftpb.Message) (*SendResponse, error)
- func (n *Node) SetPaused(pause bool)
- func (n *Node) Shutdown()
- func (n *Node) Start()
- func (n *Node) StoreLength() int
- func (n *Node) UnregisterNode(id uint64)
- type NodeInfo
- type Pair
- type Peer
- type PutObjectRequest
- func (m *PutObjectRequest) GetObject() *Pair
- func (m *PutObjectRequest) Marshal() (data []byte, err error)
- func (m *PutObjectRequest) MarshalTo(data []byte) (int, error)
- func (*PutObjectRequest) ProtoMessage()
- func (m *PutObjectRequest) Reset()
- func (m *PutObjectRequest) Size() (n int)
- func (m *PutObjectRequest) String() string
- func (m *PutObjectRequest) Unmarshal(data []byte) error
- type PutObjectResponse
- func (m *PutObjectResponse) Marshal() (data []byte, err error)
- func (m *PutObjectResponse) MarshalTo(data []byte) (int, error)
- func (*PutObjectResponse) ProtoMessage()
- func (m *PutObjectResponse) Reset()
- func (m *PutObjectResponse) Size() (n int)
- func (m *PutObjectResponse) String() string
- func (m *PutObjectResponse) Unmarshal(data []byte) error
- type Raft
- type RaftClient
- type RaftServer
- type SendResponse
- func (m *SendResponse) Marshal() (data []byte, err error)
- func (m *SendResponse) MarshalTo(data []byte) (int, error)
- func (*SendResponse) ProtoMessage()
- func (m *SendResponse) Reset()
- func (m *SendResponse) Size() (n int)
- func (m *SendResponse) String() string
- func (m *SendResponse) Unmarshal(data []byte) error
Constants ¶
const ( // MaxRetryTime is the number of time we try to initiate // a grpc connection to a remote raft member MaxRetryTime = 3 )
Variables ¶
var ( // ErrConnectionRefused is thrown when a connection is refused to a node member in the raft ErrConnectionRefused = errors.New("connection refused to the node") // ErrConfChangeRefused is thrown when there is an issue with the configuration change ErrConfChangeRefused = errors.New("propose configuration change refused") // ErrApplyNotSpecified is thrown during the creation of a raft node when no apply method was provided ErrApplyNotSpecified = errors.New("apply method was not specified") )
var ( ErrInvalidLengthProton = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowProton = fmt.Errorf("proto: integer overflow") )
Functions ¶
func DefaultNodeConfig ¶
DefaultNodeConfig returns the default config for a raft node that can be modified and customized
func EncodePair ¶
EncodePair returns a protobuf encoded key/value pair to be sent through raft
func GenID ¶
GenID generate an id for a raft node given a hostname.
FIXME there is a high chance of id collision
func RegisterRaftServer ¶
func RegisterRaftServer(s *grpc.Server, srv RaftServer)
Types ¶
type ApplyCommand ¶
type ApplyCommand func(interface{})
ApplyCommand function can be used and triggered every time there is an append entry event
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
Cluster represents a set of active raft members
func NewCluster ¶
func NewCluster() *Cluster
NewCluster creates a new cluster neighbors list for a raft member
func (*Cluster) RemovePeer ¶
RemovePeer removes a node from our neighbors
type JoinRaftResponse ¶
type JoinRaftResponse struct { Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` Nodes []*NodeInfo `protobuf:"bytes,3,rep,name=nodes" json:"nodes,omitempty"` }
func (*JoinRaftResponse) GetNodes ¶
func (m *JoinRaftResponse) GetNodes() []*NodeInfo
func (*JoinRaftResponse) Marshal ¶
func (m *JoinRaftResponse) Marshal() (data []byte, err error)
func (*JoinRaftResponse) ProtoMessage ¶
func (*JoinRaftResponse) ProtoMessage()
func (*JoinRaftResponse) Reset ¶
func (m *JoinRaftResponse) Reset()
func (*JoinRaftResponse) Size ¶
func (m *JoinRaftResponse) Size() (n int)
func (*JoinRaftResponse) String ¶
func (m *JoinRaftResponse) String() string
func (*JoinRaftResponse) Unmarshal ¶
func (m *JoinRaftResponse) Unmarshal(data []byte) error
type LeaveRaftResponse ¶
type LeaveRaftResponse struct { Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` }
func (*LeaveRaftResponse) Marshal ¶
func (m *LeaveRaftResponse) Marshal() (data []byte, err error)
func (*LeaveRaftResponse) MarshalTo ¶
func (m *LeaveRaftResponse) MarshalTo(data []byte) (int, error)
func (*LeaveRaftResponse) ProtoMessage ¶
func (*LeaveRaftResponse) ProtoMessage()
func (*LeaveRaftResponse) Reset ¶
func (m *LeaveRaftResponse) Reset()
func (*LeaveRaftResponse) Size ¶
func (m *LeaveRaftResponse) Size() (n int)
func (*LeaveRaftResponse) String ¶
func (m *LeaveRaftResponse) String() string
func (*LeaveRaftResponse) Unmarshal ¶
func (m *LeaveRaftResponse) Unmarshal(data []byte) error
type ListMembersRequest ¶
type ListMembersRequest struct { }
func (*ListMembersRequest) Marshal ¶
func (m *ListMembersRequest) Marshal() (data []byte, err error)
func (*ListMembersRequest) MarshalTo ¶
func (m *ListMembersRequest) MarshalTo(data []byte) (int, error)
func (*ListMembersRequest) ProtoMessage ¶
func (*ListMembersRequest) ProtoMessage()
func (*ListMembersRequest) Reset ¶
func (m *ListMembersRequest) Reset()
func (*ListMembersRequest) Size ¶
func (m *ListMembersRequest) Size() (n int)
func (*ListMembersRequest) String ¶
func (m *ListMembersRequest) String() string
func (*ListMembersRequest) Unmarshal ¶
func (m *ListMembersRequest) Unmarshal(data []byte) error
type ListMembersResponse ¶
type ListMembersResponse struct {
Members []*NodeInfo `protobuf:"bytes,1,rep,name=members" json:"members,omitempty"`
}
func (*ListMembersResponse) GetMembers ¶
func (m *ListMembersResponse) GetMembers() []*NodeInfo
func (*ListMembersResponse) Marshal ¶
func (m *ListMembersResponse) Marshal() (data []byte, err error)
func (*ListMembersResponse) MarshalTo ¶
func (m *ListMembersResponse) MarshalTo(data []byte) (int, error)
func (*ListMembersResponse) ProtoMessage ¶
func (*ListMembersResponse) ProtoMessage()
func (*ListMembersResponse) Reset ¶
func (m *ListMembersResponse) Reset()
func (*ListMembersResponse) Size ¶
func (m *ListMembersResponse) Size() (n int)
func (*ListMembersResponse) String ¶
func (m *ListMembersResponse) String() string
func (*ListMembersResponse) Unmarshal ¶
func (m *ListMembersResponse) Unmarshal(data []byte) error
type ListObjectsRequest ¶
type ListObjectsRequest struct { }
func (*ListObjectsRequest) Marshal ¶
func (m *ListObjectsRequest) Marshal() (data []byte, err error)
func (*ListObjectsRequest) MarshalTo ¶
func (m *ListObjectsRequest) MarshalTo(data []byte) (int, error)
func (*ListObjectsRequest) ProtoMessage ¶
func (*ListObjectsRequest) ProtoMessage()
func (*ListObjectsRequest) Reset ¶
func (m *ListObjectsRequest) Reset()
func (*ListObjectsRequest) Size ¶
func (m *ListObjectsRequest) Size() (n int)
func (*ListObjectsRequest) String ¶
func (m *ListObjectsRequest) String() string
func (*ListObjectsRequest) Unmarshal ¶
func (m *ListObjectsRequest) Unmarshal(data []byte) error
type ListObjectsResponse ¶
type ListObjectsResponse struct {
Objects []*Pair `protobuf:"bytes,1,rep,name=objects" json:"objects,omitempty"`
}
func (*ListObjectsResponse) GetObjects ¶
func (m *ListObjectsResponse) GetObjects() []*Pair
func (*ListObjectsResponse) Marshal ¶
func (m *ListObjectsResponse) Marshal() (data []byte, err error)
func (*ListObjectsResponse) MarshalTo ¶
func (m *ListObjectsResponse) MarshalTo(data []byte) (int, error)
func (*ListObjectsResponse) ProtoMessage ¶
func (*ListObjectsResponse) ProtoMessage()
func (*ListObjectsResponse) Reset ¶
func (m *ListObjectsResponse) Reset()
func (*ListObjectsResponse) Size ¶
func (m *ListObjectsResponse) Size() (n int)
func (*ListObjectsResponse) String ¶
func (m *ListObjectsResponse) String() string
func (*ListObjectsResponse) Unmarshal ¶
func (m *ListObjectsResponse) Unmarshal(data []byte) error
type Node ¶
type Node struct { raft.Node Client *Raft Cluster *Cluster Server *grpc.Server Listener net.Listener Ctx context.Context ID uint64 Address string Port int Error error PStore map[string]string Store *raft.MemoryStorage Cfg *raft.Config // contains filtered or unexported fields }
Node represents the Raft Node useful configuration.
func NewNode ¶
NewNode generates a new Raft node based on an unique ID, an address and optionally: a handler and receive only channel to send event when an entry is committed to the logs
func (*Node) JoinRaft ¶
JoinRaft sends a configuration change to nodes to add a new member to the raft cluster
func (*Node) LeaveRaft ¶
LeaveRaft sends a configuration change for a node that is willing to abandon its raft cluster membership
func (*Node) ListMembers ¶
func (n *Node) ListMembers(ctx context.Context, req *ListMembersRequest) (*ListMembersResponse, error)
ListMembers lists the members in the raft cluster
func (*Node) ListObjects ¶
func (n *Node) ListObjects(ctx context.Context, req *ListObjectsRequest) (*ListObjectsResponse, error)
ListObjects list the objects in the raft cluster
func (*Node) PutObject ¶
func (n *Node) PutObject(ctx context.Context, req *PutObjectRequest) (*PutObjectResponse, error)
Put proposes and puts a value in the raft cluster
func (*Node) RegisterNode ¶
RegisterNode registers a new node on the cluster
func (*Node) RegisterNodes ¶
RegisterNodes registers a set of nodes in the cluster
func (*Node) RemoveNode ¶
RemoveNode removes a node from the raft cluster
func (*Node) Send ¶
Send calls 'Step' which advances the raft state machine with the received message
func (*Node) Shutdown ¶
func (n *Node) Shutdown()
Shutdown stops the raft node processing loop. Calling Shutdown on an already stopped node will result in a deadlock
func (*Node) Start ¶
func (n *Node) Start()
Start is the main loop for a Raft node, it goes along the state machine, acting on the messages received from other Raft nodes in the cluster
func (*Node) StoreLength ¶
StoreLength returns the length of the store
func (*Node) UnregisterNode ¶
UnregisterNode unregisters a node that has died or has gracefully left the raft subsystem
type NodeInfo ¶
type NodeInfo struct { ID uint64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"` Addr string `protobuf:"bytes,2,opt,name=Addr,proto3" json:"Addr,omitempty"` Port string `protobuf:"bytes,3,opt,name=Port,proto3" json:"Port,omitempty"` Error string `protobuf:"bytes,4,opt,name=Error,proto3" json:"Error,omitempty"` }
func (*NodeInfo) ProtoMessage ¶
func (*NodeInfo) ProtoMessage()
type Pair ¶
type Pair struct { Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` }
func (*Pair) ProtoMessage ¶
func (*Pair) ProtoMessage()
type PutObjectRequest ¶
type PutObjectRequest struct {
Object *Pair `protobuf:"bytes,1,opt,name=object" json:"object,omitempty"`
}
func (*PutObjectRequest) GetObject ¶
func (m *PutObjectRequest) GetObject() *Pair
func (*PutObjectRequest) Marshal ¶
func (m *PutObjectRequest) Marshal() (data []byte, err error)
func (*PutObjectRequest) ProtoMessage ¶
func (*PutObjectRequest) ProtoMessage()
func (*PutObjectRequest) Reset ¶
func (m *PutObjectRequest) Reset()
func (*PutObjectRequest) Size ¶
func (m *PutObjectRequest) Size() (n int)
func (*PutObjectRequest) String ¶
func (m *PutObjectRequest) String() string
func (*PutObjectRequest) Unmarshal ¶
func (m *PutObjectRequest) Unmarshal(data []byte) error
type PutObjectResponse ¶
type PutObjectResponse struct { Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` }
func (*PutObjectResponse) Marshal ¶
func (m *PutObjectResponse) Marshal() (data []byte, err error)
func (*PutObjectResponse) MarshalTo ¶
func (m *PutObjectResponse) MarshalTo(data []byte) (int, error)
func (*PutObjectResponse) ProtoMessage ¶
func (*PutObjectResponse) ProtoMessage()
func (*PutObjectResponse) Reset ¶
func (m *PutObjectResponse) Reset()
func (*PutObjectResponse) Size ¶
func (m *PutObjectResponse) Size() (n int)
func (*PutObjectResponse) String ¶
func (m *PutObjectResponse) String() string
func (*PutObjectResponse) Unmarshal ¶
func (m *PutObjectResponse) Unmarshal(data []byte) error
type Raft ¶
type Raft struct { RaftClient Conn *grpc.ClientConn }
Raft represents a connection to a raft member
type RaftClient ¶
type RaftClient interface { JoinRaft(ctx context.Context, in *NodeInfo, opts ...grpc.CallOption) (*JoinRaftResponse, error) LeaveRaft(ctx context.Context, in *NodeInfo, opts ...grpc.CallOption) (*LeaveRaftResponse, error) Send(ctx context.Context, in *raftpb.Message, opts ...grpc.CallOption) (*SendResponse, error) PutObject(ctx context.Context, in *PutObjectRequest, opts ...grpc.CallOption) (*PutObjectResponse, error) ListObjects(ctx context.Context, in *ListObjectsRequest, opts ...grpc.CallOption) (*ListObjectsResponse, error) ListMembers(ctx context.Context, in *ListMembersRequest, opts ...grpc.CallOption) (*ListMembersResponse, error) }
func NewRaftClient ¶
func NewRaftClient(cc *grpc.ClientConn) RaftClient
type RaftServer ¶
type RaftServer interface { JoinRaft(context.Context, *NodeInfo) (*JoinRaftResponse, error) LeaveRaft(context.Context, *NodeInfo) (*LeaveRaftResponse, error) Send(context.Context, *raftpb.Message) (*SendResponse, error) PutObject(context.Context, *PutObjectRequest) (*PutObjectResponse, error) ListObjects(context.Context, *ListObjectsRequest) (*ListObjectsResponse, error) ListMembers(context.Context, *ListMembersRequest) (*ListMembersResponse, error) }
type SendResponse ¶
type SendResponse struct { Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` }
func (*SendResponse) Marshal ¶
func (m *SendResponse) Marshal() (data []byte, err error)
func (*SendResponse) ProtoMessage ¶
func (*SendResponse) ProtoMessage()
func (*SendResponse) Reset ¶
func (m *SendResponse) Reset()
func (*SendResponse) Size ¶
func (m *SendResponse) Size() (n int)
func (*SendResponse) String ¶
func (m *SendResponse) String() string
func (*SendResponse) Unmarshal ¶
func (m *SendResponse) Unmarshal(data []byte) error