Documentation
¶
Overview ¶
Package raftpb is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Variables
- func RegisterRaftServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
- func RegisterRaftServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client RaftServiceClient) error
- func RegisterRaftServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) (err error)
- func RegisterRaftServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server RaftServiceServer) error
- func RegisterRaftServiceServer(s grpc.ServiceRegistrar, srv RaftServiceServer)
- type Command
- type Content
- type RaftConfiguration
- func (*RaftConfiguration) Descriptor() ([]byte, []int)deprecated
- func (x *RaftConfiguration) GetLastIndex() uint64
- func (x *RaftConfiguration) GetServerList() []*RaftServer
- func (x *RaftConfiguration) GetState() string
- func (*RaftConfiguration) ProtoMessage()
- func (x *RaftConfiguration) ProtoReflect() protoreflect.Message
- func (x *RaftConfiguration) Reset()
- func (x *RaftConfiguration) String() string
- type RaftNode
- type RaftServer
- func (*RaftServer) Descriptor() ([]byte, []int)deprecated
- func (x *RaftServer) GetApiAddr() string
- func (x *RaftServer) GetNodeId() string
- func (x *RaftServer) GetRaftAddr() string
- func (x *RaftServer) GetSuffrage() string
- func (*RaftServer) ProtoMessage()
- func (x *RaftServer) ProtoReflect() protoreflect.Message
- func (x *RaftServer) Reset()
- func (x *RaftServer) String() string
- type RaftServiceClient
- type RaftServiceServer
- type RaftService_RecoverClient
- type RaftService_RecoverServer
- type Status
- type UnimplementedRaftServiceServer
- func (UnimplementedRaftServiceServer) ApplyCommand(context.Context, *Command) (*Status, error)
- func (UnimplementedRaftServiceServer) Bootstrap(context.Context, *emptypb.Empty) (*emptypb.Empty, error)
- func (UnimplementedRaftServiceServer) GetConfiguration(context.Context, *emptypb.Empty) (*RaftConfiguration, error)
- func (UnimplementedRaftServiceServer) Join(context.Context, *RaftNode) (*emptypb.Empty, error)
- func (UnimplementedRaftServiceServer) Recover(RaftService_RecoverServer) error
- type UnsafeRaftServiceServer
Constants ¶
This section is empty.
Variables ¶
var File_raft_service_proto protoreflect.FileDescriptor
var RaftService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "raft.RaftService", HandlerType: (*RaftServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Bootstrap", Handler: _RaftService_Bootstrap_Handler, }, { MethodName: "Join", Handler: _RaftService_Join_Handler, }, { MethodName: "GetConfiguration", Handler: _RaftService_GetConfiguration_Handler, }, { MethodName: "ApplyCommand", Handler: _RaftService_ApplyCommand_Handler, }, }, Streams: []grpc.StreamDesc{ { StreamName: "Recover", Handler: _RaftService_Recover_Handler, ClientStreams: true, }, }, Metadata: "raft_service.proto", }
RaftService_ServiceDesc is the grpc.ServiceDesc for RaftService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func RegisterRaftServiceHandler ¶
func RegisterRaftServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
RegisterRaftServiceHandler registers the http handlers for service RaftService to "mux". The handlers forward requests to the grpc endpoint over "conn".
func RegisterRaftServiceHandlerClient ¶
func RegisterRaftServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client RaftServiceClient) error
RegisterRaftServiceHandlerClient registers the http handlers for service RaftService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "RaftServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "RaftServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "RaftServiceClient" to call the correct interceptors.
func RegisterRaftServiceHandlerFromEndpoint ¶
func RegisterRaftServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)
RegisterRaftServiceHandlerFromEndpoint is same as RegisterRaftServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterRaftServiceHandlerServer ¶
func RegisterRaftServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server RaftServiceServer) error
RegisterRaftServiceHandlerServer registers the http handlers for service RaftService to "mux". UnaryRPC :call RaftServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterRaftServiceHandlerFromEndpoint instead.
func RegisterRaftServiceServer ¶
func RegisterRaftServiceServer(s grpc.ServiceRegistrar, srv RaftServiceServer)
Types ¶
type Command ¶
type Command struct {
Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"`
// contains filtered or unexported fields
}
func (*Command) Descriptor
deprecated
func (*Command) GetPayload ¶
func (*Command) ProtoMessage ¶
func (*Command) ProtoMessage()
func (*Command) ProtoReflect ¶
func (x *Command) ProtoReflect() protoreflect.Message
type Content ¶
type Content struct {
Content []byte `protobuf:"bytes,1,opt,name=content,proto3" json:"content,omitempty"`
// contains filtered or unexported fields
}
func (*Content) Descriptor
deprecated
func (*Content) GetContent ¶
func (*Content) ProtoMessage ¶
func (*Content) ProtoMessage()
func (*Content) ProtoReflect ¶
func (x *Content) ProtoReflect() protoreflect.Message
type RaftConfiguration ¶
type RaftConfiguration struct {
State string `protobuf:"bytes,1,opt,name=state,proto3" json:"state,omitempty"`
LastIndex uint64 `protobuf:"varint,2,opt,name=last_index,json=lastIndex,proto3" json:"last_index,omitempty"`
ServerList []*RaftServer `protobuf:"bytes,3,rep,name=server_list,json=serverList,proto3" json:"server_list,omitempty"`
// contains filtered or unexported fields
}
func (*RaftConfiguration) Descriptor
deprecated
func (*RaftConfiguration) Descriptor() ([]byte, []int)
Deprecated: Use RaftConfiguration.ProtoReflect.Descriptor instead.
func (*RaftConfiguration) GetLastIndex ¶
func (x *RaftConfiguration) GetLastIndex() uint64
func (*RaftConfiguration) GetServerList ¶
func (x *RaftConfiguration) GetServerList() []*RaftServer
func (*RaftConfiguration) GetState ¶
func (x *RaftConfiguration) GetState() string
func (*RaftConfiguration) ProtoMessage ¶
func (*RaftConfiguration) ProtoMessage()
func (*RaftConfiguration) ProtoReflect ¶
func (x *RaftConfiguration) ProtoReflect() protoreflect.Message
func (*RaftConfiguration) Reset ¶
func (x *RaftConfiguration) Reset()
func (*RaftConfiguration) String ¶
func (x *RaftConfiguration) String() string
type RaftNode ¶
type RaftNode struct {
NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"`
NodeAddr string `protobuf:"bytes,2,opt,name=node_addr,json=nodeAddr,proto3" json:"node_addr,omitempty"`
// contains filtered or unexported fields
}
func (*RaftNode) Descriptor
deprecated
func (*RaftNode) GetNodeAddr ¶
func (*RaftNode) ProtoMessage ¶
func (*RaftNode) ProtoMessage()
func (*RaftNode) ProtoReflect ¶
func (x *RaftNode) ProtoReflect() protoreflect.Message
type RaftServer ¶
type RaftServer struct {
NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"`
RaftAddr string `protobuf:"bytes,2,opt,name=raft_addr,json=raftAddr,proto3" json:"raft_addr,omitempty"`
Suffrage string `protobuf:"bytes,3,opt,name=suffrage,proto3" json:"suffrage,omitempty"`
ApiAddr string `protobuf:"bytes,4,opt,name=api_addr,json=apiAddr,proto3" json:"api_addr,omitempty"`
// contains filtered or unexported fields
}
func (*RaftServer) Descriptor
deprecated
func (*RaftServer) Descriptor() ([]byte, []int)
Deprecated: Use RaftServer.ProtoReflect.Descriptor instead.
func (*RaftServer) GetApiAddr ¶
func (x *RaftServer) GetApiAddr() string
func (*RaftServer) GetNodeId ¶
func (x *RaftServer) GetNodeId() string
func (*RaftServer) GetRaftAddr ¶
func (x *RaftServer) GetRaftAddr() string
func (*RaftServer) GetSuffrage ¶
func (x *RaftServer) GetSuffrage() string
func (*RaftServer) ProtoMessage ¶
func (*RaftServer) ProtoMessage()
func (*RaftServer) ProtoReflect ¶
func (x *RaftServer) ProtoReflect() protoreflect.Message
func (*RaftServer) Reset ¶
func (x *RaftServer) Reset()
func (*RaftServer) String ¶
func (x *RaftServer) String() string
type RaftServiceClient ¶
type RaftServiceClient interface {
Bootstrap(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error)
Join(ctx context.Context, in *RaftNode, opts ...grpc.CallOption) (*emptypb.Empty, error)
GetConfiguration(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*RaftConfiguration, error)
ApplyCommand(ctx context.Context, in *Command, opts ...grpc.CallOption) (*Status, error)
Recover(ctx context.Context, opts ...grpc.CallOption) (RaftService_RecoverClient, error)
}
RaftServiceClient is the client API for RaftService service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
func NewRaftServiceClient ¶
func NewRaftServiceClient(cc grpc.ClientConnInterface) RaftServiceClient
type RaftServiceServer ¶
type RaftServiceServer interface {
Bootstrap(context.Context, *emptypb.Empty) (*emptypb.Empty, error)
Join(context.Context, *RaftNode) (*emptypb.Empty, error)
GetConfiguration(context.Context, *emptypb.Empty) (*RaftConfiguration, error)
ApplyCommand(context.Context, *Command) (*Status, error)
Recover(RaftService_RecoverServer) error
// contains filtered or unexported methods
}
RaftServiceServer is the server API for RaftService service. All implementations must embed UnimplementedRaftServiceServer for forward compatibility
type Status ¶
type Status struct {
Updated bool `protobuf:"varint,1,opt,name=updated,proto3" json:"updated,omitempty"`
Elapsed float64 `protobuf:"fixed64,2,opt,name=elapsed,proto3" json:"elapsed,omitempty"` // operation cost in seconds
// contains filtered or unexported fields
}
func (*Status) Descriptor
deprecated
func (*Status) GetElapsed ¶
func (*Status) GetUpdated ¶
func (*Status) ProtoMessage ¶
func (*Status) ProtoMessage()
func (*Status) ProtoReflect ¶
func (x *Status) ProtoReflect() protoreflect.Message
type UnimplementedRaftServiceServer ¶
type UnimplementedRaftServiceServer struct {
}
UnimplementedRaftServiceServer must be embedded to have forward compatible implementations.
func (UnimplementedRaftServiceServer) ApplyCommand ¶
func (UnimplementedRaftServiceServer) GetConfiguration ¶
func (UnimplementedRaftServiceServer) GetConfiguration(context.Context, *emptypb.Empty) (*RaftConfiguration, error)
func (UnimplementedRaftServiceServer) Recover ¶
func (UnimplementedRaftServiceServer) Recover(RaftService_RecoverServer) error
type UnsafeRaftServiceServer ¶
type UnsafeRaftServiceServer interface {
// contains filtered or unexported methods
}
UnsafeRaftServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to RaftServiceServer will result in compilation errors.