Documentation
¶
Index ¶
- Constants
- Variables
- func RegisterGreetServiceServer(s grpc.ServiceRegistrar, srv GreetServiceServer)
- type GreetServiceClient
- type GreetServiceServer
- type GreetService_HelloStreamClient
- type GreetService_HelloStreamServer
- type Request
- type Response
- func (*Response) Descriptor() ([]byte, []int)deprecated
- func (x *Response) GetData() []byte
- func (x *Response) GetId() int64
- func (x *Response) GetStatus() Response_Status
- func (x *Response) GetType() Type
- func (*Response) ProtoMessage()
- func (x *Response) ProtoReflect() protoreflect.Message
- func (x *Response) Reset()
- func (x *Response) String() string
- type Response_Status
- func (Response_Status) Descriptor() protoreflect.EnumDescriptor
- func (x Response_Status) Enum() *Response_Status
- func (Response_Status) EnumDescriptor() ([]byte, []int)deprecated
- func (x Response_Status) Number() protoreflect.EnumNumber
- func (x Response_Status) String() string
- func (Response_Status) Type() protoreflect.EnumType
- type Type
- type UnimplementedGreetServiceServer
- type UnsafeGreetServiceServer
Constants ¶
const ( GreetService_Hello_FullMethodName = "/proto.GreetService/Hello" GreetService_HelloStream_FullMethodName = "/proto.GreetService/HelloStream" )
Variables ¶
var ( Type_name = map[int32]string{ 0: "NORMAL", 1: "PING", 2: "PONG", } Type_value = map[string]int32{ "NORMAL": 0, "PING": 1, "PONG": 2, } )
Enum value maps for Type.
var ( Response_Status_name = map[int32]string{ 0: "OK", 1: "ERROR", } Response_Status_value = map[string]int32{ "OK": 0, "ERROR": 1, } )
Enum value maps for Response_Status.
var File_pkg_protobuf_message_proto protoreflect.FileDescriptor
var GreetService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "proto.GreetService", HandlerType: (*GreetServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Hello", Handler: _GreetService_Hello_Handler, }, }, Streams: []grpc.StreamDesc{ { StreamName: "HelloStream", Handler: _GreetService_HelloStream_Handler, ServerStreams: true, ClientStreams: true, }, }, Metadata: "pkg/protobuf/message.proto", }
GreetService_ServiceDesc is the grpc.ServiceDesc for GreetService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func RegisterGreetServiceServer ¶
func RegisterGreetServiceServer(s grpc.ServiceRegistrar, srv GreetServiceServer)
Types ¶
type GreetServiceClient ¶
type GreetServiceClient interface { // Unary RPC // 客户端发起了一个RPC请求到服务端,服务端进行业务处理并返回响应给客户端, // 这是gRPC最基本的一种工作方式(Unary RPC) Hello(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) // Streaming RPC // 服务端流,客户端发出一个RPC请求,服务端客户端与之间建立一个单向的流。 // 服务端可以向流中写入多个响应消息,最后主动关闭流;而客户端需要监听这个流,不断获取响应直到流关闭。 // 应用场景举例:客户端向服务端发送一个股票代码,服务端就把该股票的实时数据源源不断的返回给客户端。 // // 客户端流,客户端传入多个请求对象,服务端返回一个响应结果。 // 典型的应用场景举例:物联网终端向服务器上报数据、大数据流式计算等。 // // 双向流,双向流式RPC即客户端和服务端均为流式的RPC,能发送多个请求对象也能接收到多个响应对象。 // 典型应用示例:聊天应用等。 HelloStream(ctx context.Context, opts ...grpc.CallOption) (GreetService_HelloStreamClient, error) }
GreetServiceClient is the client API for GreetService 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 NewGreetServiceClient ¶
func NewGreetServiceClient(cc grpc.ClientConnInterface) GreetServiceClient
type GreetServiceServer ¶
type GreetServiceServer interface { // Unary RPC // 客户端发起了一个RPC请求到服务端,服务端进行业务处理并返回响应给客户端, // 这是gRPC最基本的一种工作方式(Unary RPC) Hello(context.Context, *Request) (*Response, error) // Streaming RPC // 服务端流,客户端发出一个RPC请求,服务端客户端与之间建立一个单向的流。 // 服务端可以向流中写入多个响应消息,最后主动关闭流;而客户端需要监听这个流,不断获取响应直到流关闭。 // 应用场景举例:客户端向服务端发送一个股票代码,服务端就把该股票的实时数据源源不断的返回给客户端。 // // 客户端流,客户端传入多个请求对象,服务端返回一个响应结果。 // 典型的应用场景举例:物联网终端向服务器上报数据、大数据流式计算等。 // // 双向流,双向流式RPC即客户端和服务端均为流式的RPC,能发送多个请求对象也能接收到多个响应对象。 // 典型应用示例:聊天应用等。 HelloStream(GreetService_HelloStreamServer) error // contains filtered or unexported methods }
GreetServiceServer is the server API for GreetService service. All implementations must embed UnimplementedGreetServiceServer for forward compatibility
func NewGreetServiceServer ¶
func NewGreetServiceServer() GreetServiceServer
type Request ¶
type Request struct { Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` Type Type `protobuf:"varint,2,opt,name=type,proto3,enum=proto.Type" json:"type,omitempty"` Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` // contains filtered or unexported fields }
func (*Request) Descriptor
deprecated
func (*Request) ProtoMessage ¶
func (*Request) ProtoMessage()
func (*Request) ProtoReflect ¶
func (x *Request) ProtoReflect() protoreflect.Message
type Response ¶
type Response struct { Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` Type Type `protobuf:"varint,2,opt,name=type,proto3,enum=proto.Type" json:"type,omitempty"` Status Response_Status `protobuf:"varint,3,opt,name=status,proto3,enum=proto.Response_Status" json:"status,omitempty"` Data []byte `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"` // contains filtered or unexported fields }
func (*Response) Descriptor
deprecated
func (*Response) GetStatus ¶
func (x *Response) GetStatus() Response_Status
func (*Response) ProtoMessage ¶
func (*Response) ProtoMessage()
func (*Response) ProtoReflect ¶
func (x *Response) ProtoReflect() protoreflect.Message
type Response_Status ¶
type Response_Status int32
const ( Response_OK Response_Status = 0 Response_ERROR Response_Status = 1 )
func (Response_Status) Descriptor ¶
func (Response_Status) Descriptor() protoreflect.EnumDescriptor
func (Response_Status) Enum ¶
func (x Response_Status) Enum() *Response_Status
func (Response_Status) EnumDescriptor
deprecated
func (Response_Status) EnumDescriptor() ([]byte, []int)
Deprecated: Use Response_Status.Descriptor instead.
func (Response_Status) Number ¶
func (x Response_Status) Number() protoreflect.EnumNumber
func (Response_Status) String ¶
func (x Response_Status) String() string
func (Response_Status) Type ¶
func (Response_Status) Type() protoreflect.EnumType
type Type ¶
type Type int32
func (Type) Descriptor ¶
func (Type) Descriptor() protoreflect.EnumDescriptor
func (Type) EnumDescriptor
deprecated
func (Type) Number ¶
func (x Type) Number() protoreflect.EnumNumber
func (Type) Type ¶
func (Type) Type() protoreflect.EnumType
type UnimplementedGreetServiceServer ¶
type UnimplementedGreetServiceServer struct { }
UnimplementedGreetServiceServer must be embedded to have forward compatible implementations.
func (UnimplementedGreetServiceServer) HelloStream ¶
func (UnimplementedGreetServiceServer) HelloStream(GreetService_HelloStreamServer) error
type UnsafeGreetServiceServer ¶
type UnsafeGreetServiceServer interface {
// contains filtered or unexported methods
}
UnsafeGreetServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to GreetServiceServer will result in compilation errors.