Documentation ¶
Overview ¶
Package pb is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Variables
- func RegisterSayHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
- func RegisterSayHandlerClient(ctx context.Context, mux *runtime.ServeMux, client SayClient) error
- func RegisterSayHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) (err error)
- func RegisterSayHandlerServer(ctx context.Context, mux *runtime.ServeMux, server SayServer) error
- func RegisterSayServer(s grpc.ServiceRegistrar, srv SayServer)
- type ErrorCode
- type HelloReq
- func (*HelloReq) Descriptor() ([]byte, []int)deprecated
- func (x *HelloReq) GetName() string
- func (*HelloReq) ProtoMessage()
- func (x *HelloReq) ProtoReflect() protoreflect.Message
- func (x *HelloReq) Reset()
- func (x *HelloReq) String() string
- func (m *HelloReq) Validate() error
- func (m *HelloReq) ValidateAll() error
- type HelloReqMultiError
- type HelloReqValidationError
- type HelloRes
- func (*HelloRes) Descriptor() ([]byte, []int)deprecated
- func (x *HelloRes) GetMsg() string
- func (*HelloRes) ProtoMessage()
- func (x *HelloRes) ProtoReflect() protoreflect.Message
- func (x *HelloRes) Reset()
- func (x *HelloRes) String() string
- func (m *HelloRes) Validate() error
- func (m *HelloRes) ValidateAll() error
- type HelloResMultiError
- type HelloResValidationError
- type RpcCliReq
- func (*RpcCliReq) Descriptor() ([]byte, []int)deprecated
- func (x *RpcCliReq) GetName() string
- func (*RpcCliReq) ProtoMessage()
- func (x *RpcCliReq) ProtoReflect() protoreflect.Message
- func (x *RpcCliReq) Reset()
- func (x *RpcCliReq) String() string
- func (m *RpcCliReq) Validate() error
- func (m *RpcCliReq) ValidateAll() error
- type RpcCliReqMultiError
- type RpcCliReqValidationError
- type RpcCliRes
- func (*RpcCliRes) Descriptor() ([]byte, []int)deprecated
- func (x *RpcCliRes) GetMsg() string
- func (*RpcCliRes) ProtoMessage()
- func (x *RpcCliRes) ProtoReflect() protoreflect.Message
- func (x *RpcCliRes) Reset()
- func (x *RpcCliRes) String() string
- func (m *RpcCliRes) Validate() error
- func (m *RpcCliRes) ValidateAll() error
- type RpcCliResMultiError
- type RpcCliResValidationError
- type SayClient
- type SayServer
- type TopicReq
- func (*TopicReq) Descriptor() ([]byte, []int)deprecated
- func (x *TopicReq) GetName() string
- func (*TopicReq) ProtoMessage()
- func (x *TopicReq) ProtoReflect() protoreflect.Message
- func (x *TopicReq) Reset()
- func (x *TopicReq) String() string
- func (m *TopicReq) Validate() error
- func (m *TopicReq) ValidateAll() error
- type TopicReqMultiError
- type TopicReqValidationError
- type TopicRes
- func (*TopicRes) Descriptor() ([]byte, []int)deprecated
- func (x *TopicRes) GetMsg() string
- func (*TopicRes) ProtoMessage()
- func (x *TopicRes) ProtoReflect() protoreflect.Message
- func (x *TopicRes) Reset()
- func (x *TopicRes) String() string
- func (m *TopicRes) Validate() error
- func (m *TopicRes) ValidateAll() error
- type TopicResMultiError
- type TopicResValidationError
- type UnimplementedSayServer
- type UnsafeSayServer
Constants ¶
This section is empty.
Variables ¶
var ( ErrorCode_name = map[int32]string{ 0: "OK", 4404: "CustomNotFound", } ErrorCode_value = map[string]int32{ "OK": 0, "CustomNotFound": 4404, } )
Enum value maps for ErrorCode.
var File_api_proto_error_proto protoreflect.FileDescriptor
var File_api_proto_main_proto protoreflect.FileDescriptor
var Say_ServiceDesc = grpc.ServiceDesc{ ServiceName: "pb.Say", HandlerType: (*SayServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Hello", Handler: _Say_Hello_Handler, }, { MethodName: "Topic", Handler: _Say_Topic_Handler, }, { MethodName: "RpcCli", Handler: _Say_RpcCli_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "api/proto/main.proto", }
Say_ServiceDesc is the grpc.ServiceDesc for Say service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func RegisterSayHandler ¶
RegisterSayHandler registers the http handlers for service Say to "mux". The handlers forward requests to the grpc endpoint over "conn".
func RegisterSayHandlerClient ¶
RegisterSayHandlerClient registers the http handlers for service Say to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "SayClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "SayClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "SayClient" to call the correct interceptors.
func RegisterSayHandlerFromEndpoint ¶
func RegisterSayHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)
RegisterSayHandlerFromEndpoint is same as RegisterSayHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterSayHandlerServer ¶
RegisterSayHandlerServer registers the http handlers for service Say to "mux". UnaryRPC :call SayServer 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 RegisterSayHandlerFromEndpoint instead.
func RegisterSayServer ¶
func RegisterSayServer(s grpc.ServiceRegistrar, srv SayServer)
Types ¶
type ErrorCode ¶
type ErrorCode int32
ErrorCode 错误码枚举类型 一般错误,参考: https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto
func (ErrorCode) Descriptor ¶
func (ErrorCode) Descriptor() protoreflect.EnumDescriptor
func (ErrorCode) EnumDescriptor
deprecated
func (ErrorCode) Number ¶
func (x ErrorCode) Number() protoreflect.EnumNumber
func (ErrorCode) Type ¶
func (ErrorCode) Type() protoreflect.EnumType
type HelloReq ¶
type HelloReq struct { // 姓名 Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // contains filtered or unexported fields }
Hello 请求
func (*HelloReq) Descriptor
deprecated
func (*HelloReq) ProtoMessage ¶
func (*HelloReq) ProtoMessage()
func (*HelloReq) ProtoReflect ¶
func (x *HelloReq) ProtoReflect() protoreflect.Message
func (*HelloReq) Validate ¶
Validate checks the field values on HelloReq with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.
func (*HelloReq) ValidateAll ¶
ValidateAll checks the field values on HelloReq with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in HelloReqMultiError, or nil if none found.
type HelloReqMultiError ¶
type HelloReqMultiError []error
HelloReqMultiError is an error wrapping multiple validation errors returned by HelloReq.ValidateAll() if the designated constraints aren't met.
func (HelloReqMultiError) AllErrors ¶
func (m HelloReqMultiError) AllErrors() []error
AllErrors returns a list of validation violation errors.
func (HelloReqMultiError) Error ¶
func (m HelloReqMultiError) Error() string
Error returns a concatenation of all the error messages it wraps.
type HelloReqValidationError ¶
type HelloReqValidationError struct {
// contains filtered or unexported fields
}
HelloReqValidationError is the validation error returned by HelloReq.Validate if the designated constraints aren't met.
func (HelloReqValidationError) Cause ¶
func (e HelloReqValidationError) Cause() error
Cause function returns cause value.
func (HelloReqValidationError) Error ¶
func (e HelloReqValidationError) Error() string
Error satisfies the builtin error interface
func (HelloReqValidationError) ErrorName ¶
func (e HelloReqValidationError) ErrorName() string
ErrorName returns error name.
func (HelloReqValidationError) Field ¶
func (e HelloReqValidationError) Field() string
Field function returns field value.
func (HelloReqValidationError) Key ¶
func (e HelloReqValidationError) Key() bool
Key function returns key value.
func (HelloReqValidationError) Reason ¶
func (e HelloReqValidationError) Reason() string
Reason function returns reason value.
type HelloRes ¶
type HelloRes struct { // 回复消息 Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"` // contains filtered or unexported fields }
Hello 响应
func (*HelloRes) Descriptor
deprecated
func (*HelloRes) ProtoMessage ¶
func (*HelloRes) ProtoMessage()
func (*HelloRes) ProtoReflect ¶
func (x *HelloRes) ProtoReflect() protoreflect.Message
func (*HelloRes) Validate ¶
Validate checks the field values on HelloRes with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.
func (*HelloRes) ValidateAll ¶
ValidateAll checks the field values on HelloRes with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in HelloResMultiError, or nil if none found.
type HelloResMultiError ¶
type HelloResMultiError []error
HelloResMultiError is an error wrapping multiple validation errors returned by HelloRes.ValidateAll() if the designated constraints aren't met.
func (HelloResMultiError) AllErrors ¶
func (m HelloResMultiError) AllErrors() []error
AllErrors returns a list of validation violation errors.
func (HelloResMultiError) Error ¶
func (m HelloResMultiError) Error() string
Error returns a concatenation of all the error messages it wraps.
type HelloResValidationError ¶
type HelloResValidationError struct {
// contains filtered or unexported fields
}
HelloResValidationError is the validation error returned by HelloRes.Validate if the designated constraints aren't met.
func (HelloResValidationError) Cause ¶
func (e HelloResValidationError) Cause() error
Cause function returns cause value.
func (HelloResValidationError) Error ¶
func (e HelloResValidationError) Error() string
Error satisfies the builtin error interface
func (HelloResValidationError) ErrorName ¶
func (e HelloResValidationError) ErrorName() string
ErrorName returns error name.
func (HelloResValidationError) Field ¶
func (e HelloResValidationError) Field() string
Field function returns field value.
func (HelloResValidationError) Key ¶
func (e HelloResValidationError) Key() bool
Key function returns key value.
func (HelloResValidationError) Reason ¶
func (e HelloResValidationError) Reason() string
Reason function returns reason value.
type RpcCliReq ¶
type RpcCliReq struct { // 姓名 Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // contains filtered or unexported fields }
func (*RpcCliReq) Descriptor
deprecated
func (*RpcCliReq) ProtoMessage ¶
func (*RpcCliReq) ProtoMessage()
func (*RpcCliReq) ProtoReflect ¶
func (x *RpcCliReq) ProtoReflect() protoreflect.Message
func (*RpcCliReq) Validate ¶
Validate checks the field values on RpcCliReq with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.
func (*RpcCliReq) ValidateAll ¶
ValidateAll checks the field values on RpcCliReq with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in RpcCliReqMultiError, or nil if none found.
type RpcCliReqMultiError ¶
type RpcCliReqMultiError []error
RpcCliReqMultiError is an error wrapping multiple validation errors returned by RpcCliReq.ValidateAll() if the designated constraints aren't met.
func (RpcCliReqMultiError) AllErrors ¶
func (m RpcCliReqMultiError) AllErrors() []error
AllErrors returns a list of validation violation errors.
func (RpcCliReqMultiError) Error ¶
func (m RpcCliReqMultiError) Error() string
Error returns a concatenation of all the error messages it wraps.
type RpcCliReqValidationError ¶
type RpcCliReqValidationError struct {
// contains filtered or unexported fields
}
RpcCliReqValidationError is the validation error returned by RpcCliReq.Validate if the designated constraints aren't met.
func (RpcCliReqValidationError) Cause ¶
func (e RpcCliReqValidationError) Cause() error
Cause function returns cause value.
func (RpcCliReqValidationError) Error ¶
func (e RpcCliReqValidationError) Error() string
Error satisfies the builtin error interface
func (RpcCliReqValidationError) ErrorName ¶
func (e RpcCliReqValidationError) ErrorName() string
ErrorName returns error name.
func (RpcCliReqValidationError) Field ¶
func (e RpcCliReqValidationError) Field() string
Field function returns field value.
func (RpcCliReqValidationError) Key ¶
func (e RpcCliReqValidationError) Key() bool
Key function returns key value.
func (RpcCliReqValidationError) Reason ¶
func (e RpcCliReqValidationError) Reason() string
Reason function returns reason value.
type RpcCliRes ¶
type RpcCliRes struct { // 回复消息 Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"` // contains filtered or unexported fields }
func (*RpcCliRes) Descriptor
deprecated
func (*RpcCliRes) ProtoMessage ¶
func (*RpcCliRes) ProtoMessage()
func (*RpcCliRes) ProtoReflect ¶
func (x *RpcCliRes) ProtoReflect() protoreflect.Message
func (*RpcCliRes) Validate ¶
Validate checks the field values on RpcCliRes with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.
func (*RpcCliRes) ValidateAll ¶
ValidateAll checks the field values on RpcCliRes with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in RpcCliResMultiError, or nil if none found.
type RpcCliResMultiError ¶
type RpcCliResMultiError []error
RpcCliResMultiError is an error wrapping multiple validation errors returned by RpcCliRes.ValidateAll() if the designated constraints aren't met.
func (RpcCliResMultiError) AllErrors ¶
func (m RpcCliResMultiError) AllErrors() []error
AllErrors returns a list of validation violation errors.
func (RpcCliResMultiError) Error ¶
func (m RpcCliResMultiError) Error() string
Error returns a concatenation of all the error messages it wraps.
type RpcCliResValidationError ¶
type RpcCliResValidationError struct {
// contains filtered or unexported fields
}
RpcCliResValidationError is the validation error returned by RpcCliRes.Validate if the designated constraints aren't met.
func (RpcCliResValidationError) Cause ¶
func (e RpcCliResValidationError) Cause() error
Cause function returns cause value.
func (RpcCliResValidationError) Error ¶
func (e RpcCliResValidationError) Error() string
Error satisfies the builtin error interface
func (RpcCliResValidationError) ErrorName ¶
func (e RpcCliResValidationError) ErrorName() string
ErrorName returns error name.
func (RpcCliResValidationError) Field ¶
func (e RpcCliResValidationError) Field() string
Field function returns field value.
func (RpcCliResValidationError) Key ¶
func (e RpcCliResValidationError) Key() bool
Key function returns key value.
func (RpcCliResValidationError) Reason ¶
func (e RpcCliResValidationError) Reason() string
Reason function returns reason value.
type SayClient ¶
type SayClient interface { // 测试HelloWorld Hello(ctx context.Context, in *HelloReq, opts ...grpc.CallOption) (*HelloRes, error) Topic(ctx context.Context, in *TopicReq, opts ...grpc.CallOption) (*TopicRes, error) RpcCli(ctx context.Context, in *RpcCliReq, opts ...grpc.CallOption) (*RpcCliRes, error) }
SayClient is the client API for Say 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 NewSayClient ¶
func NewSayClient(cc grpc.ClientConnInterface) SayClient
type SayServer ¶
type SayServer interface { // 测试HelloWorld Hello(context.Context, *HelloReq) (*HelloRes, error) Topic(context.Context, *TopicReq) (*TopicRes, error) RpcCli(context.Context, *RpcCliReq) (*RpcCliRes, error) // contains filtered or unexported methods }
SayServer is the server API for Say service. All implementations must embed UnimplementedSayServer for forward compatibility
type TopicReq ¶
type TopicReq struct { // 姓名 Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // contains filtered or unexported fields }
func (*TopicReq) Descriptor
deprecated
func (*TopicReq) ProtoMessage ¶
func (*TopicReq) ProtoMessage()
func (*TopicReq) ProtoReflect ¶
func (x *TopicReq) ProtoReflect() protoreflect.Message
func (*TopicReq) Validate ¶
Validate checks the field values on TopicReq with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.
func (*TopicReq) ValidateAll ¶
ValidateAll checks the field values on TopicReq with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in TopicReqMultiError, or nil if none found.
type TopicReqMultiError ¶
type TopicReqMultiError []error
TopicReqMultiError is an error wrapping multiple validation errors returned by TopicReq.ValidateAll() if the designated constraints aren't met.
func (TopicReqMultiError) AllErrors ¶
func (m TopicReqMultiError) AllErrors() []error
AllErrors returns a list of validation violation errors.
func (TopicReqMultiError) Error ¶
func (m TopicReqMultiError) Error() string
Error returns a concatenation of all the error messages it wraps.
type TopicReqValidationError ¶
type TopicReqValidationError struct {
// contains filtered or unexported fields
}
TopicReqValidationError is the validation error returned by TopicReq.Validate if the designated constraints aren't met.
func (TopicReqValidationError) Cause ¶
func (e TopicReqValidationError) Cause() error
Cause function returns cause value.
func (TopicReqValidationError) Error ¶
func (e TopicReqValidationError) Error() string
Error satisfies the builtin error interface
func (TopicReqValidationError) ErrorName ¶
func (e TopicReqValidationError) ErrorName() string
ErrorName returns error name.
func (TopicReqValidationError) Field ¶
func (e TopicReqValidationError) Field() string
Field function returns field value.
func (TopicReqValidationError) Key ¶
func (e TopicReqValidationError) Key() bool
Key function returns key value.
func (TopicReqValidationError) Reason ¶
func (e TopicReqValidationError) Reason() string
Reason function returns reason value.
type TopicRes ¶
type TopicRes struct { // 回复消息 Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"` // contains filtered or unexported fields }
func (*TopicRes) Descriptor
deprecated
func (*TopicRes) ProtoMessage ¶
func (*TopicRes) ProtoMessage()
func (*TopicRes) ProtoReflect ¶
func (x *TopicRes) ProtoReflect() protoreflect.Message
func (*TopicRes) Validate ¶
Validate checks the field values on TopicRes with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.
func (*TopicRes) ValidateAll ¶
ValidateAll checks the field values on TopicRes with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in TopicResMultiError, or nil if none found.
type TopicResMultiError ¶
type TopicResMultiError []error
TopicResMultiError is an error wrapping multiple validation errors returned by TopicRes.ValidateAll() if the designated constraints aren't met.
func (TopicResMultiError) AllErrors ¶
func (m TopicResMultiError) AllErrors() []error
AllErrors returns a list of validation violation errors.
func (TopicResMultiError) Error ¶
func (m TopicResMultiError) Error() string
Error returns a concatenation of all the error messages it wraps.
type TopicResValidationError ¶
type TopicResValidationError struct {
// contains filtered or unexported fields
}
TopicResValidationError is the validation error returned by TopicRes.Validate if the designated constraints aren't met.
func (TopicResValidationError) Cause ¶
func (e TopicResValidationError) Cause() error
Cause function returns cause value.
func (TopicResValidationError) Error ¶
func (e TopicResValidationError) Error() string
Error satisfies the builtin error interface
func (TopicResValidationError) ErrorName ¶
func (e TopicResValidationError) ErrorName() string
ErrorName returns error name.
func (TopicResValidationError) Field ¶
func (e TopicResValidationError) Field() string
Field function returns field value.
func (TopicResValidationError) Key ¶
func (e TopicResValidationError) Key() bool
Key function returns key value.
func (TopicResValidationError) Reason ¶
func (e TopicResValidationError) Reason() string
Reason function returns reason value.
type UnimplementedSayServer ¶
type UnimplementedSayServer struct { }
UnimplementedSayServer must be embedded to have forward compatible implementations.
type UnsafeSayServer ¶
type UnsafeSayServer interface {
// contains filtered or unexported methods
}
UnsafeSayServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to SayServer will result in compilation errors.