pb

package
v0.0.0-...-2499e25 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package pb is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

View Source
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. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterGreeterServiceHandlerFromEndpoint instead.

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.

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

Deprecated: Use HelloReq.ProtoReflect.Descriptor instead.

func (*HelloReq) GetName

func (x *HelloReq) GetName() string

func (*HelloReq) ProtoMessage

func (*HelloReq) ProtoMessage()

func (*HelloReq) ProtoReflect

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

func (*HelloReq) Reset

func (x *HelloReq) Reset()

func (*HelloReq) String

func (x *HelloReq) String() string

type UnimplementedGreeterServiceServer

type UnimplementedGreeterServiceServer struct {
}

UnimplementedGreeterServiceServer can be embedded to have forward compatible implementations.

func (*UnimplementedGreeterServiceServer) SayHello

Jump to

Keyboard shortcuts

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