Documentation ¶
Overview ¶
Package gidpb is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Constants
- Variables
- func RegisterIdHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
- func RegisterIdHandlerClient(ctx context.Context, mux *runtime.ServeMux, client IdClient) error
- func RegisterIdHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) (err error)
- func RegisterIdHandlerServer(ctx context.Context, mux *runtime.ServeMux, server IdServer) error
- func RegisterIdServer(s grpc.ServiceRegistrar, srv IdServer)
- type GenType
- type GenerateRequest
- type GenerateResponse
- func (*GenerateResponse) Descriptor() ([]byte, []int)deprecated
- func (x *GenerateResponse) GetId() string
- func (x *GenerateResponse) GetType() string
- func (*GenerateResponse) ProtoMessage()
- func (x *GenerateResponse) ProtoReflect() protoreflect.Message
- func (x *GenerateResponse) Reset()
- func (x *GenerateResponse) String() string
- type IdClient
- type IdServer
- type Id_TypeStreamClient
- type Id_TypeStreamServer
- type SrvCode
- type TypesRequest
- type TypesResponse
- type UnimplementedIdServer
- type UnsafeIdServer
Constants ¶
const ( Id_Generate_FullMethodName = "/gid.Id/Generate" Id_TypeStream_FullMethodName = "/gid.Id/TypeStream" Id_Types_FullMethodName = "/gid.Id/Types" )
Variables ¶
var ( SrvCode_name = map[int32]string{ 0: "OK", 100: "IDGenerateFailed", } SrvCode_value = map[string]int32{ "OK": 0, "IDGenerateFailed": 100, } )
Enum value maps for SrvCode.
var ( GenType_name = map[int32]string{ 0: "default", 1: "uuid", 2: "snowflake", 3: "bigflake", 4: "shortid", } GenType_value = map[string]int32{ "default": 0, "uuid": 1, "snowflake": 2, "bigflake": 3, "shortid": 4, } )
Enum value maps for GenType.
var ErrCodeIDGenerateFailed = &errorpb.ErrCode{ BizCode: int32(100), Code: errorpb.Code_Internal, Name: "gid.err_code.id_generate_failed", Reason: "id generate error", }
var ErrCodeOK = &errorpb.ErrCode{ BizCode: int32(0), Code: errorpb.Code_OK, Name: "gid.err_code.ok", Reason: "ok", }
var File_gid_id_proto protoreflect.FileDescriptor
var Id_ServiceDesc = grpc.ServiceDesc{ ServiceName: "gid.Id", HandlerType: (*IdServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Generate", Handler: _Id_Generate_Handler, }, { MethodName: "Types", Handler: _Id_Types_Handler, }, }, Streams: []grpc.StreamDesc{ { StreamName: "TypeStream", Handler: _Id_TypeStream_Handler, ServerStreams: true, }, }, Metadata: "gid/id.proto", }
Id_ServiceDesc is the grpc.ServiceDesc for Id service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func RegisterIdHandler ¶
RegisterIdHandler registers the http handlers for service Id to "mux". The handlers forward requests to the grpc endpoint over "conn".
func RegisterIdHandlerClient ¶
RegisterIdHandlerClient registers the http handlers for service Id to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "IdClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "IdClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "IdClient" to call the correct interceptors.
func RegisterIdHandlerFromEndpoint ¶
func RegisterIdHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)
RegisterIdHandlerFromEndpoint is same as RegisterIdHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterIdHandlerServer ¶
RegisterIdHandlerServer registers the http handlers for service Id to "mux". UnaryRPC :call IdServer 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 RegisterIdHandlerFromEndpoint instead.
func RegisterIdServer ¶
func RegisterIdServer(s grpc.ServiceRegistrar, srv IdServer)
Types ¶
type GenType ¶
type GenType int32
func (GenType) Descriptor ¶
func (GenType) Descriptor() protoreflect.EnumDescriptor
func (GenType) EnumDescriptor
deprecated
func (GenType) Number ¶
func (x GenType) Number() protoreflect.EnumNumber
func (GenType) Type ¶
func (GenType) Type() protoreflect.EnumType
type GenerateRequest ¶
type GenerateRequest struct { // type of id e.g uuid, shortid, snowflake (64 bit), bigflake (128 bit) Type GenType `protobuf:"varint,1,opt,name=type,proto3,enum=gid.GenType" json:"type,omitempty"` // contains filtered or unexported fields }
Generate a unique ID. Defaults to uuid.
func (*GenerateRequest) Descriptor
deprecated
func (*GenerateRequest) Descriptor() ([]byte, []int)
Deprecated: Use GenerateRequest.ProtoReflect.Descriptor instead.
func (*GenerateRequest) GetType ¶
func (x *GenerateRequest) GetType() GenType
func (*GenerateRequest) ProtoMessage ¶
func (*GenerateRequest) ProtoMessage()
func (*GenerateRequest) ProtoReflect ¶
func (x *GenerateRequest) ProtoReflect() protoreflect.Message
func (*GenerateRequest) Reset ¶
func (x *GenerateRequest) Reset()
func (*GenerateRequest) String ¶
func (x *GenerateRequest) String() string
type GenerateResponse ¶
type GenerateResponse struct { // the unique id generated Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // the type of id generated Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` // contains filtered or unexported fields }
func (*GenerateResponse) Descriptor
deprecated
func (*GenerateResponse) Descriptor() ([]byte, []int)
Deprecated: Use GenerateResponse.ProtoReflect.Descriptor instead.
func (*GenerateResponse) GetId ¶
func (x *GenerateResponse) GetId() string
func (*GenerateResponse) GetType ¶
func (x *GenerateResponse) GetType() string
func (*GenerateResponse) ProtoMessage ¶
func (*GenerateResponse) ProtoMessage()
func (*GenerateResponse) ProtoReflect ¶
func (x *GenerateResponse) ProtoReflect() protoreflect.Message
func (*GenerateResponse) Reset ¶
func (x *GenerateResponse) Reset()
func (*GenerateResponse) String ¶
func (x *GenerateResponse) String() string
type IdClient ¶
type IdClient interface { // Generate 生成ID Generate(ctx context.Context, in *GenerateRequest, opts ...grpc.CallOption) (*GenerateResponse, error) TypeStream(ctx context.Context, in *TypesRequest, opts ...grpc.CallOption) (Id_TypeStreamClient, error) // Types id类型 Types(ctx context.Context, in *TypesRequest, opts ...grpc.CallOption) (*TypesResponse, error) }
IdClient is the client API for Id 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 NewIdClient ¶
func NewIdClient(cc grpc.ClientConnInterface) IdClient
type IdServer ¶
type IdServer interface { // Generate 生成ID Generate(context.Context, *GenerateRequest) (*GenerateResponse, error) TypeStream(*TypesRequest, Id_TypeStreamServer) error // Types id类型 Types(context.Context, *TypesRequest) (*TypesResponse, error) }
IdServer is the server API for Id service. All implementations should embed UnimplementedIdServer for forward compatibility
type Id_TypeStreamClient ¶
type Id_TypeStreamClient interface { Recv() (*TypesResponse, error) grpc.ClientStream }
type Id_TypeStreamServer ¶
type Id_TypeStreamServer interface { Send(*TypesResponse) error grpc.ServerStream }
type SrvCode ¶
type SrvCode int32
func (SrvCode) Descriptor ¶
func (SrvCode) Descriptor() protoreflect.EnumDescriptor
func (SrvCode) EnumDescriptor
deprecated
func (SrvCode) Number ¶
func (x SrvCode) Number() protoreflect.EnumNumber
func (SrvCode) Type ¶
func (SrvCode) Type() protoreflect.EnumType
type TypesRequest ¶
type TypesRequest struct {
// contains filtered or unexported fields
}
List the types of IDs available. No query params needed.
func (*TypesRequest) Descriptor
deprecated
func (*TypesRequest) Descriptor() ([]byte, []int)
Deprecated: Use TypesRequest.ProtoReflect.Descriptor instead.
func (*TypesRequest) ProtoMessage ¶
func (*TypesRequest) ProtoMessage()
func (*TypesRequest) ProtoReflect ¶
func (x *TypesRequest) ProtoReflect() protoreflect.Message
func (*TypesRequest) Reset ¶
func (x *TypesRequest) Reset()
func (*TypesRequest) String ¶
func (x *TypesRequest) String() string
type TypesResponse ¶
type TypesResponse struct { Types []string `protobuf:"bytes,1,rep,name=types,proto3" json:"types,omitempty"` // contains filtered or unexported fields }
TypesResponse 返回值类型
func (*TypesResponse) Descriptor
deprecated
func (*TypesResponse) Descriptor() ([]byte, []int)
Deprecated: Use TypesResponse.ProtoReflect.Descriptor instead.
func (*TypesResponse) GetTypes ¶
func (x *TypesResponse) GetTypes() []string
func (*TypesResponse) ProtoMessage ¶
func (*TypesResponse) ProtoMessage()
func (*TypesResponse) ProtoReflect ¶
func (x *TypesResponse) ProtoReflect() protoreflect.Message
func (*TypesResponse) Reset ¶
func (x *TypesResponse) Reset()
func (*TypesResponse) String ¶
func (x *TypesResponse) String() string
type UnimplementedIdServer ¶
type UnimplementedIdServer struct { }
UnimplementedIdServer should be embedded to have forward compatible implementations.
func (UnimplementedIdServer) Generate ¶
func (UnimplementedIdServer) Generate(context.Context, *GenerateRequest) (*GenerateResponse, error)
func (UnimplementedIdServer) TypeStream ¶
func (UnimplementedIdServer) TypeStream(*TypesRequest, Id_TypeStreamServer) error
func (UnimplementedIdServer) Types ¶
func (UnimplementedIdServer) Types(context.Context, *TypesRequest) (*TypesResponse, error)
type UnsafeIdServer ¶
type UnsafeIdServer interface {
// contains filtered or unexported methods
}
UnsafeIdServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to IdServer will result in compilation errors.