raftpb

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

README

raftpb

Raft Service API Protobuf

Documentation

Overview

Package raftpb is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const (
	RaftService_Bootstrap_FullMethodName        = "/raft.RaftService/Bootstrap"
	RaftService_Join_FullMethodName             = "/raft.RaftService/Join"
	RaftService_GetConfiguration_FullMethodName = "/raft.RaftService/GetConfiguration"
	RaftService_ApplyCommand_FullMethodName     = "/raft.RaftService/ApplyCommand"
	RaftService_Recover_FullMethodName          = "/raft.RaftService/Recover"
)

Variables

View Source
var File_raft_service_proto protoreflect.FileDescriptor
View Source
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) Descriptor() ([]byte, []int)

Deprecated: Use Command.ProtoReflect.Descriptor instead.

func (*Command) GetPayload

func (x *Command) GetPayload() []byte

func (*Command) ProtoMessage

func (*Command) ProtoMessage()

func (*Command) ProtoReflect

func (x *Command) ProtoReflect() protoreflect.Message

func (*Command) Reset

func (x *Command) Reset()

func (*Command) String

func (x *Command) String() string

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) Descriptor() ([]byte, []int)

Deprecated: Use Content.ProtoReflect.Descriptor instead.

func (*Content) GetContent

func (x *Content) GetContent() []byte

func (*Content) ProtoMessage

func (*Content) ProtoMessage()

func (*Content) ProtoReflect

func (x *Content) ProtoReflect() protoreflect.Message

func (*Content) Reset

func (x *Content) Reset()

func (*Content) String

func (x *Content) String() string

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) Descriptor() ([]byte, []int)

Deprecated: Use RaftNode.ProtoReflect.Descriptor instead.

func (*RaftNode) GetNodeAddr

func (x *RaftNode) GetNodeAddr() string

func (*RaftNode) GetNodeId

func (x *RaftNode) GetNodeId() string

func (*RaftNode) ProtoMessage

func (*RaftNode) ProtoMessage()

func (*RaftNode) ProtoReflect

func (x *RaftNode) ProtoReflect() protoreflect.Message

func (*RaftNode) Reset

func (x *RaftNode) Reset()

func (*RaftNode) String

func (x *RaftNode) String() string

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.

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 RaftService_RecoverClient

type RaftService_RecoverClient interface {
	Send(*Content) error
	CloseAndRecv() (*emptypb.Empty, error)
	grpc.ClientStream
}

type RaftService_RecoverServer

type RaftService_RecoverServer interface {
	SendAndClose(*emptypb.Empty) error
	Recv() (*Content, error)
	grpc.ServerStream
}

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
	Id      string  `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"`             // optional id field
	// contains filtered or unexported fields
}

func (*Status) Descriptor deprecated

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

Deprecated: Use Status.ProtoReflect.Descriptor instead.

func (*Status) GetElapsed

func (x *Status) GetElapsed() float64

func (*Status) GetId added in v1.0.2

func (x *Status) GetId() string

func (*Status) GetUpdated

func (x *Status) GetUpdated() bool

func (*Status) ProtoMessage

func (*Status) ProtoMessage()

func (*Status) ProtoReflect

func (x *Status) ProtoReflect() protoreflect.Message

func (*Status) Reset

func (x *Status) Reset()

func (*Status) String

func (x *Status) String() string

type UnimplementedRaftServiceServer

type UnimplementedRaftServiceServer struct {
}

UnimplementedRaftServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedRaftServiceServer) ApplyCommand

func (UnimplementedRaftServiceServer) Bootstrap

func (UnimplementedRaftServiceServer) GetConfiguration

func (UnimplementedRaftServiceServer) Join

func (UnimplementedRaftServiceServer) Recover

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.

Directories

Path Synopsis
third_party

Jump to

Keyboard shortcuts

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