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 ChatMessage
- 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_Chat1Client
- type Id_Chat1Server
- type Id_ChatClient
- type Id_ChatServer
- type Id_TypeStreamClient
- type Id_TypeStreamServer
- type SrvCode
- type TypesRequest
- type TypesResponse
- type UnimplementedIdServer
- func (UnimplementedIdServer) Chat(Id_ChatServer) error
- func (UnimplementedIdServer) Chat1(Id_Chat1Server) error
- func (UnimplementedIdServer) Generate(context.Context, *GenerateRequest) (*GenerateResponse, error)
- func (UnimplementedIdServer) TypeStream(*TypesRequest, Id_TypeStreamServer) error
- func (UnimplementedIdServer) Types(context.Context, *TypesRequest) (*TypesResponse, error)
- func (UnimplementedIdServer) UploadDownload(context.Context, *UploadFileRequest) (*httpbody.HttpBody, error)
- type UnsafeIdServer
- type UploadFileRequest
- func (*UploadFileRequest) Descriptor() ([]byte, []int)deprecated
- func (x *UploadFileRequest) GetFile() *httpbody.HttpBody
- func (x *UploadFileRequest) GetFilename() string
- func (*UploadFileRequest) ProtoMessage()
- func (x *UploadFileRequest) ProtoReflect() protoreflect.Message
- func (x *UploadFileRequest) Reset()
- func (x *UploadFileRequest) String() string
Constants ¶
const ( Id_Generate_FullMethodName = "/gid.Id/Generate" Id_TypeStream_FullMethodName = "/gid.Id/TypeStream" Id_Types_FullMethodName = "/gid.Id/Types" Id_Chat_FullMethodName = "/gid.Id/Chat" Id_Chat1_FullMethodName = "/gid.Id/Chat1" Id_UploadDownload_FullMethodName = "/gid.Id/UploadDownload" )
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{ Code: int32(100), Message: "id generate error", Name: "gid.id_generate_failed", StatusCode: errorpb.Code_Internal, }
var ErrCodeOK = &errorpb.ErrCode{ Code: int32(0), Message: "ok", Name: "gid.ok", StatusCode: errorpb.Code_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, }, { MethodName: "UploadDownload", Handler: _Id_UploadDownload_Handler, }, }, Streams: []grpc.StreamDesc{ { StreamName: "TypeStream", Handler: _Id_TypeStream_Handler, ServerStreams: true, }, { StreamName: "Chat", Handler: _Id_Chat_Handler, ServerStreams: true, ClientStreams: true, }, { StreamName: "Chat1", Handler: _Id_Chat1_Handler, ServerStreams: true, ClientStreams: 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 ChatMessage ¶
type ChatMessage struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Text string `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"` // contains filtered or unexported fields }
func (*ChatMessage) Descriptor
deprecated
func (*ChatMessage) Descriptor() ([]byte, []int)
Deprecated: Use ChatMessage.ProtoReflect.Descriptor instead.
func (*ChatMessage) GetName ¶
func (x *ChatMessage) GetName() string
func (*ChatMessage) GetText ¶
func (x *ChatMessage) GetText() string
func (*ChatMessage) ProtoMessage ¶
func (*ChatMessage) ProtoMessage()
func (*ChatMessage) ProtoReflect ¶
func (x *ChatMessage) ProtoReflect() protoreflect.Message
func (*ChatMessage) Reset ¶
func (x *ChatMessage) Reset()
func (*ChatMessage) String ¶
func (x *ChatMessage) String() string
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) Chat(ctx context.Context, opts ...grpc.CallOption) (Id_ChatClient, error) // ws: chat1 Chat1(ctx context.Context, opts ...grpc.CallOption) (Id_Chat1Client, error) UploadDownload(ctx context.Context, in *UploadFileRequest, opts ...grpc.CallOption) (*httpbody.HttpBody, 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) Chat(Id_ChatServer) error // ws: chat1 Chat1(Id_Chat1Server) error UploadDownload(context.Context, *UploadFileRequest) (*httpbody.HttpBody, error) }
IdServer is the server API for Id service. All implementations should embed UnimplementedIdServer for forward compatibility
type Id_Chat1Client ¶
type Id_Chat1Client interface { Send(*ChatMessage) error Recv() (*ChatMessage, error) grpc.ClientStream }
type Id_Chat1Server ¶
type Id_Chat1Server interface { Send(*ChatMessage) error Recv() (*ChatMessage, error) grpc.ServerStream }
type Id_ChatClient ¶
type Id_ChatClient interface { Send(*ChatMessage) error Recv() (*ChatMessage, error) grpc.ClientStream }
type Id_ChatServer ¶
type Id_ChatServer interface { Send(*ChatMessage) error Recv() (*ChatMessage, error) grpc.ServerStream }
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) Chat ¶
func (UnimplementedIdServer) Chat(Id_ChatServer) error
func (UnimplementedIdServer) Chat1 ¶
func (UnimplementedIdServer) Chat1(Id_Chat1Server) error
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)
func (UnimplementedIdServer) UploadDownload ¶
func (UnimplementedIdServer) UploadDownload(context.Context, *UploadFileRequest) (*httpbody.HttpBody, 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.
type UploadFileRequest ¶
type UploadFileRequest struct { Filename string `protobuf:"bytes,1,opt,name=filename,proto3" json:"filename,omitempty"` File *httpbody.HttpBody `protobuf:"bytes,2,opt,name=file,proto3" json:"file,omitempty"` // contains filtered or unexported fields }
func (*UploadFileRequest) Descriptor
deprecated
func (*UploadFileRequest) Descriptor() ([]byte, []int)
Deprecated: Use UploadFileRequest.ProtoReflect.Descriptor instead.
func (*UploadFileRequest) GetFile ¶
func (x *UploadFileRequest) GetFile() *httpbody.HttpBody
func (*UploadFileRequest) GetFilename ¶
func (x *UploadFileRequest) GetFilename() string
func (*UploadFileRequest) ProtoMessage ¶
func (*UploadFileRequest) ProtoMessage()
func (*UploadFileRequest) ProtoReflect ¶
func (x *UploadFileRequest) ProtoReflect() protoreflect.Message
func (*UploadFileRequest) Reset ¶
func (x *UploadFileRequest) Reset()
func (*UploadFileRequest) String ¶
func (x *UploadFileRequest) String() string