Documentation ¶
Overview ¶
Package pb is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Variables
- func RegisterGreeterServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
- func RegisterGreeterServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client GreeterServiceClient) error
- func RegisterGreeterServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) (err error)
- func RegisterGreeterServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server GreeterServiceServer) error
- func RegisterGreeterServiceServer(s *grpc.Server, srv GreeterServiceServer)
- type GreeterServiceClient
- type GreeterServiceServer
- type HelloReply
- type HelloReq
- type UnimplementedGreeterServiceServer
Constants ¶
This section is empty.
Variables ¶
var File_hello_proto protoreflect.FileDescriptor
Functions ¶
func RegisterGreeterServiceHandler ¶
func RegisterGreeterServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
RegisterGreeterServiceHandler registers the http handlers for service GreeterService to "mux". The handlers forward requests to the grpc endpoint over "conn".
func RegisterGreeterServiceHandlerClient ¶
func RegisterGreeterServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client GreeterServiceClient) error
RegisterGreeterServiceHandlerClient registers the http handlers for service GreeterService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "GreeterServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "GreeterServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "GreeterServiceClient" to call the correct interceptors.
func RegisterGreeterServiceHandlerFromEndpoint ¶
func RegisterGreeterServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)
RegisterGreeterServiceHandlerFromEndpoint is same as RegisterGreeterServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterGreeterServiceHandlerServer ¶
func RegisterGreeterServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server GreeterServiceServer) error
RegisterGreeterServiceHandlerServer registers the http handlers for service GreeterService to "mux". UnaryRPC :call GreeterServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
func RegisterGreeterServiceServer ¶
func RegisterGreeterServiceServer(s *grpc.Server, srv GreeterServiceServer)
Types ¶
type GreeterServiceClient ¶
type GreeterServiceClient interface {
SayHello(ctx context.Context, in *HelloReq, opts ...grpc.CallOption) (*HelloReply, error)
}
GreeterServiceClient is the client API for GreeterService service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
func NewGreeterServiceClient ¶
func NewGreeterServiceClient(cc grpc.ClientConnInterface) GreeterServiceClient
type GreeterServiceServer ¶
type GreeterServiceServer interface {
SayHello(context.Context, *HelloReq) (*HelloReply, error)
}
GreeterServiceServer is the server API for GreeterService service.
type HelloReply ¶
type HelloReply struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` // contains filtered or unexported fields }
定义服务端响应的数据格式
func (*HelloReply) Descriptor
deprecated
func (*HelloReply) Descriptor() ([]byte, []int)
Deprecated: Use HelloReply.ProtoReflect.Descriptor instead.
func (*HelloReply) GetMessage ¶
func (x *HelloReply) GetMessage() string
func (*HelloReply) GetName ¶
func (x *HelloReply) GetName() string
func (*HelloReply) ProtoMessage ¶
func (*HelloReply) ProtoMessage()
func (*HelloReply) ProtoReflect ¶
func (x *HelloReply) ProtoReflect() protoreflect.Message
func (*HelloReply) Reset ¶
func (x *HelloReply) Reset()
func (*HelloReply) String ¶
func (x *HelloReply) String() string
type HelloReq ¶
type HelloReq struct { // [修饰符] 类型 字段名 = 标识符; Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // contains filtered or unexported fields }
message 对应生成代码的 struct 定义客户端请求的数据格式
func (*HelloReq) Descriptor
deprecated
func (*HelloReq) ProtoMessage ¶
func (*HelloReq) ProtoMessage()
func (*HelloReq) ProtoReflect ¶
func (x *HelloReq) ProtoReflect() protoreflect.Message
type UnimplementedGreeterServiceServer ¶
type UnimplementedGreeterServiceServer struct { }
UnimplementedGreeterServiceServer can be embedded to have forward compatible implementations.
func (*UnimplementedGreeterServiceServer) SayHello ¶
func (*UnimplementedGreeterServiceServer) SayHello(context.Context, *HelloReq) (*HelloReply, error)