Documentation
¶
Index ¶
- Constants
- Variables
- func RegisterGreeterServiceServer(s grpc.ServiceRegistrar, srv GreeterServiceServer)
- type ChatMessage
- type GoodbyeRequest
- type GoodbyeResponse
- func (*GoodbyeResponse) Descriptor() ([]byte, []int)deprecated
- func (x *GoodbyeResponse) GetMessage() string
- func (x *GoodbyeResponse) GetTimestamp() int64
- func (*GoodbyeResponse) ProtoMessage()
- func (x *GoodbyeResponse) ProtoReflect() protoreflect.Message
- func (x *GoodbyeResponse) Reset()
- func (x *GoodbyeResponse) String() string
- type GreeterServiceClient
- type GreeterServiceServer
- type GreeterService_ChatClient
- type GreeterService_ChatServer
- type GreeterService_WatchHelloClient
- type GreeterService_WatchHelloServer
- type HelloRequest
- type HelloResponse
- func (*HelloResponse) Descriptor() ([]byte, []int)deprecated
- func (x *HelloResponse) GetMessage() string
- func (x *HelloResponse) GetTimestamp() int64
- func (*HelloResponse) ProtoMessage()
- func (x *HelloResponse) ProtoReflect() protoreflect.Message
- func (x *HelloResponse) Reset()
- func (x *HelloResponse) String() string
- type UnimplementedGreeterServiceServer
- func (UnimplementedGreeterServiceServer) Chat(grpc.BidiStreamingServer[ChatMessage, ChatMessage]) error
- func (UnimplementedGreeterServiceServer) SayGoodbye(context.Context, *GoodbyeRequest) (*GoodbyeResponse, error)
- func (UnimplementedGreeterServiceServer) SayHello(context.Context, *HelloRequest) (*HelloResponse, error)
- func (UnimplementedGreeterServiceServer) WatchHello(*WatchHelloRequest, grpc.ServerStreamingServer[HelloResponse]) error
- type UnsafeGreeterServiceServer
- type WatchHelloRequest
- func (*WatchHelloRequest) Descriptor() ([]byte, []int)deprecated
- func (x *WatchHelloRequest) GetCount() int32
- func (x *WatchHelloRequest) GetName() string
- func (*WatchHelloRequest) ProtoMessage()
- func (x *WatchHelloRequest) ProtoReflect() protoreflect.Message
- func (x *WatchHelloRequest) Reset()
- func (x *WatchHelloRequest) String() string
Constants ¶
const ( GreeterService_SayHello_FullMethodName = "/grpcweb.example.v1.GreeterService/SayHello" GreeterService_SayGoodbye_FullMethodName = "/grpcweb.example.v1.GreeterService/SayGoodbye" GreeterService_WatchHello_FullMethodName = "/grpcweb.example.v1.GreeterService/WatchHello" GreeterService_Chat_FullMethodName = "/grpcweb.example.v1.GreeterService/Chat" )
Variables ¶
var File_greeter_proto protoreflect.FileDescriptor
var GreeterService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpcweb.example.v1.GreeterService", HandlerType: (*GreeterServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "SayHello", Handler: _GreeterService_SayHello_Handler, }, { MethodName: "SayGoodbye", Handler: _GreeterService_SayGoodbye_Handler, }, }, Streams: []grpc.StreamDesc{ { StreamName: "WatchHello", Handler: _GreeterService_WatchHello_Handler, ServerStreams: true, }, { StreamName: "Chat", Handler: _GreeterService_Chat_Handler, ServerStreams: true, ClientStreams: true, }, }, Metadata: "greeter.proto", }
GreeterService_ServiceDesc is the grpc.ServiceDesc for GreeterService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func RegisterGreeterServiceServer ¶
func RegisterGreeterServiceServer(s grpc.ServiceRegistrar, srv GreeterServiceServer)
Types ¶
type ChatMessage ¶ added in v2.2.0
type ChatMessage struct {
Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"`
// contains filtered or unexported fields
}
ChatMessage 是 Chat 双向流的消息
func (*ChatMessage) Descriptor
deprecated
added in
v2.2.0
func (*ChatMessage) Descriptor() ([]byte, []int)
Deprecated: Use ChatMessage.ProtoReflect.Descriptor instead.
func (*ChatMessage) GetText ¶ added in v2.2.0
func (x *ChatMessage) GetText() string
func (*ChatMessage) ProtoMessage ¶ added in v2.2.0
func (*ChatMessage) ProtoMessage()
func (*ChatMessage) ProtoReflect ¶ added in v2.2.0
func (x *ChatMessage) ProtoReflect() protoreflect.Message
func (*ChatMessage) Reset ¶ added in v2.2.0
func (x *ChatMessage) Reset()
func (*ChatMessage) String ¶ added in v2.2.0
func (x *ChatMessage) String() string
type GoodbyeRequest ¶
type GoodbyeRequest struct {
// 用户名称
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// contains filtered or unexported fields
}
GoodbyeRequest 是 SayGoodbye 的请求消息
func (*GoodbyeRequest) Descriptor
deprecated
func (*GoodbyeRequest) Descriptor() ([]byte, []int)
Deprecated: Use GoodbyeRequest.ProtoReflect.Descriptor instead.
func (*GoodbyeRequest) GetName ¶
func (x *GoodbyeRequest) GetName() string
func (*GoodbyeRequest) ProtoMessage ¶
func (*GoodbyeRequest) ProtoMessage()
func (*GoodbyeRequest) ProtoReflect ¶
func (x *GoodbyeRequest) ProtoReflect() protoreflect.Message
func (*GoodbyeRequest) Reset ¶
func (x *GoodbyeRequest) Reset()
func (*GoodbyeRequest) String ¶
func (x *GoodbyeRequest) String() string
type GoodbyeResponse ¶
type GoodbyeResponse struct {
// 告别消息
Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
// 服务器时间戳
Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
// contains filtered or unexported fields
}
GoodbyeResponse 是 SayGoodbye 的响应消息
func (*GoodbyeResponse) Descriptor
deprecated
func (*GoodbyeResponse) Descriptor() ([]byte, []int)
Deprecated: Use GoodbyeResponse.ProtoReflect.Descriptor instead.
func (*GoodbyeResponse) GetMessage ¶
func (x *GoodbyeResponse) GetMessage() string
func (*GoodbyeResponse) GetTimestamp ¶
func (x *GoodbyeResponse) GetTimestamp() int64
func (*GoodbyeResponse) ProtoMessage ¶
func (*GoodbyeResponse) ProtoMessage()
func (*GoodbyeResponse) ProtoReflect ¶
func (x *GoodbyeResponse) ProtoReflect() protoreflect.Message
func (*GoodbyeResponse) Reset ¶
func (x *GoodbyeResponse) Reset()
func (*GoodbyeResponse) String ¶
func (x *GoodbyeResponse) String() string
type GreeterServiceClient ¶
type GreeterServiceClient interface {
// SayHello 返回问候语
SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloResponse, error)
// SayGoodbye 返回告别语
SayGoodbye(ctx context.Context, in *GoodbyeRequest, opts ...grpc.CallOption) (*GoodbyeResponse, error)
// WatchHello 服务端流式返回多条问候(用于 WebSocket / server-stream 演示)
WatchHello(ctx context.Context, in *WatchHelloRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[HelloResponse], error)
// Chat 双向流式对话(用于 WebSocket / bidi 演示)
Chat(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[ChatMessage, ChatMessage], error)
}
GreeterServiceClient is the client API for GreeterService 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.
GreeterService 提供简单的问候服务,用于测试 gRPC Web 实现
func NewGreeterServiceClient ¶
func NewGreeterServiceClient(cc grpc.ClientConnInterface) GreeterServiceClient
type GreeterServiceServer ¶
type GreeterServiceServer interface {
// SayHello 返回问候语
SayHello(context.Context, *HelloRequest) (*HelloResponse, error)
// SayGoodbye 返回告别语
SayGoodbye(context.Context, *GoodbyeRequest) (*GoodbyeResponse, error)
// WatchHello 服务端流式返回多条问候(用于 WebSocket / server-stream 演示)
WatchHello(*WatchHelloRequest, grpc.ServerStreamingServer[HelloResponse]) error
// Chat 双向流式对话(用于 WebSocket / bidi 演示)
Chat(grpc.BidiStreamingServer[ChatMessage, ChatMessage]) error
// contains filtered or unexported methods
}
GreeterServiceServer is the server API for GreeterService service. All implementations must embed UnimplementedGreeterServiceServer for forward compatibility.
GreeterService 提供简单的问候服务,用于测试 gRPC Web 实现
type GreeterService_ChatClient ¶ added in v2.2.0
type GreeterService_ChatClient = grpc.BidiStreamingClient[ChatMessage, ChatMessage]
This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type GreeterService_ChatServer ¶ added in v2.2.0
type GreeterService_ChatServer = grpc.BidiStreamingServer[ChatMessage, ChatMessage]
This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type GreeterService_WatchHelloClient ¶ added in v2.2.0
type GreeterService_WatchHelloClient = grpc.ServerStreamingClient[HelloResponse]
This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type GreeterService_WatchHelloServer ¶ added in v2.2.0
type GreeterService_WatchHelloServer = grpc.ServerStreamingServer[HelloResponse]
This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type HelloRequest ¶
type HelloRequest struct {
// 用户名称
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// contains filtered or unexported fields
}
HelloRequest 是 SayHello 的请求消息
func (*HelloRequest) Descriptor
deprecated
func (*HelloRequest) Descriptor() ([]byte, []int)
Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead.
func (*HelloRequest) GetName ¶
func (x *HelloRequest) GetName() string
func (*HelloRequest) ProtoMessage ¶
func (*HelloRequest) ProtoMessage()
func (*HelloRequest) ProtoReflect ¶
func (x *HelloRequest) ProtoReflect() protoreflect.Message
func (*HelloRequest) Reset ¶
func (x *HelloRequest) Reset()
func (*HelloRequest) String ¶
func (x *HelloRequest) String() string
type HelloResponse ¶
type HelloResponse struct {
// 问候消息
Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
// 服务器时间戳
Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
// contains filtered or unexported fields
}
HelloResponse 是 SayHello 的响应消息
func (*HelloResponse) Descriptor
deprecated
func (*HelloResponse) Descriptor() ([]byte, []int)
Deprecated: Use HelloResponse.ProtoReflect.Descriptor instead.
func (*HelloResponse) GetMessage ¶
func (x *HelloResponse) GetMessage() string
func (*HelloResponse) GetTimestamp ¶
func (x *HelloResponse) GetTimestamp() int64
func (*HelloResponse) ProtoMessage ¶
func (*HelloResponse) ProtoMessage()
func (*HelloResponse) ProtoReflect ¶
func (x *HelloResponse) ProtoReflect() protoreflect.Message
func (*HelloResponse) Reset ¶
func (x *HelloResponse) Reset()
func (*HelloResponse) String ¶
func (x *HelloResponse) String() string
type UnimplementedGreeterServiceServer ¶
type UnimplementedGreeterServiceServer struct{}
UnimplementedGreeterServiceServer must be embedded to have forward compatible implementations.
NOTE: this should be embedded by value instead of pointer to avoid a nil pointer dereference when methods are called.
func (UnimplementedGreeterServiceServer) SayGoodbye ¶
func (UnimplementedGreeterServiceServer) SayGoodbye(context.Context, *GoodbyeRequest) (*GoodbyeResponse, error)
func (UnimplementedGreeterServiceServer) SayHello ¶
func (UnimplementedGreeterServiceServer) SayHello(context.Context, *HelloRequest) (*HelloResponse, error)
func (UnimplementedGreeterServiceServer) WatchHello ¶ added in v2.2.0
func (UnimplementedGreeterServiceServer) WatchHello(*WatchHelloRequest, grpc.ServerStreamingServer[HelloResponse]) error
type UnsafeGreeterServiceServer ¶
type UnsafeGreeterServiceServer interface {
// contains filtered or unexported methods
}
UnsafeGreeterServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to GreeterServiceServer will result in compilation errors.
type WatchHelloRequest ¶ added in v2.2.0
type WatchHelloRequest struct {
// 用户名称
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// 推送消息条数,默认 3
Count int32 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"`
// contains filtered or unexported fields
}
WatchHelloRequest 是 WatchHello 的请求消息
func (*WatchHelloRequest) Descriptor
deprecated
added in
v2.2.0
func (*WatchHelloRequest) Descriptor() ([]byte, []int)
Deprecated: Use WatchHelloRequest.ProtoReflect.Descriptor instead.
func (*WatchHelloRequest) GetCount ¶ added in v2.2.0
func (x *WatchHelloRequest) GetCount() int32
func (*WatchHelloRequest) GetName ¶ added in v2.2.0
func (x *WatchHelloRequest) GetName() string
func (*WatchHelloRequest) ProtoMessage ¶ added in v2.2.0
func (*WatchHelloRequest) ProtoMessage()
func (*WatchHelloRequest) ProtoReflect ¶ added in v2.2.0
func (x *WatchHelloRequest) ProtoReflect() protoreflect.Message
func (*WatchHelloRequest) Reset ¶ added in v2.2.0
func (x *WatchHelloRequest) Reset()
func (*WatchHelloRequest) String ¶ added in v2.2.0
func (x *WatchHelloRequest) String() string