Documentation
¶
Overview ¶
Package chat is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Constants
- Variables
- func RegisterChatServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
- func RegisterChatServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ChatServiceClient) error
- func RegisterChatServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) (err error)
- func RegisterChatServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ChatServiceServer) error
- func RegisterChatServiceServer(s grpc.ServiceRegistrar, srv ChatServiceServer)
- type ChatRequest
- type ChatResponse
- type ChatServiceClient
- type ChatServiceServer
- type ChatService_ChatClient
- type ChatService_ChatServer
- type LogInOrRegisterRequest
- func (*LogInOrRegisterRequest) Descriptor() ([]byte, []int)deprecated
- func (x *LogInOrRegisterRequest) GetPassword() string
- func (x *LogInOrRegisterRequest) GetUsername() string
- func (*LogInOrRegisterRequest) ProtoMessage()
- func (x *LogInOrRegisterRequest) ProtoReflect() protoreflect.Message
- func (x *LogInOrRegisterRequest) Reset()
- func (x *LogInOrRegisterRequest) String() string
- type LogInOrRegisterResponse
- func (*LogInOrRegisterResponse) Descriptor() ([]byte, []int)deprecated
- func (x *LogInOrRegisterResponse) GetToken() string
- func (*LogInOrRegisterResponse) ProtoMessage()
- func (x *LogInOrRegisterResponse) ProtoReflect() protoreflect.Message
- func (x *LogInOrRegisterResponse) Reset()
- func (x *LogInOrRegisterResponse) String() string
- type LogOutRequest
- type LogOutResponse
- type Message
- func (*Message) Descriptor() ([]byte, []int)deprecated
- func (x *Message) GetBinaryContent() []byte
- func (x *Message) GetMessageNumber() uint64
- func (x *Message) GetTextContent() string
- func (x *Message) GetTimestamp() int64
- func (x *Message) GetType() MessageType
- func (x *Message) GetUsername() string
- func (*Message) ProtoMessage()
- func (x *Message) ProtoReflect() protoreflect.Message
- func (x *Message) Reset()
- func (x *Message) String() string
- type MessageType
- func (MessageType) Descriptor() protoreflect.EnumDescriptor
- func (x MessageType) Enum() *MessageType
- func (MessageType) EnumDescriptor() ([]byte, []int)deprecated
- func (x MessageType) Number() protoreflect.EnumNumber
- func (x MessageType) String() string
- func (MessageType) Type() protoreflect.EnumType
- type UnimplementedChatServiceServer
- func (UnimplementedChatServiceServer) Chat(grpc.BidiStreamingServer[ChatRequest, ChatResponse]) error
- func (UnimplementedChatServiceServer) LogInOrRegister(context.Context, *LogInOrRegisterRequest) (*LogInOrRegisterResponse, error)
- func (UnimplementedChatServiceServer) LogOut(context.Context, *LogOutRequest) (*LogOutResponse, error)
- type UnsafeChatServiceServer
Constants ¶
const ( ChatService_LogInOrRegister_FullMethodName = "/chat.v1.ChatService/LogInOrRegister" ChatService_LogOut_FullMethodName = "/chat.v1.ChatService/LogOut" ChatService_Chat_FullMethodName = "/chat.v1.ChatService/Chat" )
Variables ¶
var ( MessageType_name = map[int32]string{ 0: "MESSAGE_TYPE_UNSPECIFIED", 1: "MESSAGE_TYPE_USERENTER", 2: "MESSAGE_TYPE_USERLEAVE", 3: "MESSAGE_TYPE_NORMAL", } MessageType_value = map[string]int32{ "MESSAGE_TYPE_UNSPECIFIED": 0, "MESSAGE_TYPE_USERENTER": 1, "MESSAGE_TYPE_USERLEAVE": 2, "MESSAGE_TYPE_NORMAL": 3, } )
Enum value maps for MessageType.
var ChatService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "chat.v1.ChatService", HandlerType: (*ChatServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "LogInOrRegister", Handler: _ChatService_LogInOrRegister_Handler, }, { MethodName: "LogOut", Handler: _ChatService_LogOut_Handler, }, }, Streams: []grpc.StreamDesc{ { StreamName: "Chat", Handler: _ChatService_Chat_Handler, ServerStreams: true, ClientStreams: true, }, }, Metadata: "chat/v1/chat.proto", }
ChatService_ServiceDesc is the grpc.ServiceDesc for ChatService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
var File_chat_v1_chat_proto protoreflect.FileDescriptor
Functions ¶
func RegisterChatServiceHandler ¶
func RegisterChatServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
RegisterChatServiceHandler registers the http handlers for service ChatService to "mux". The handlers forward requests to the grpc endpoint over "conn".
func RegisterChatServiceHandlerClient ¶
func RegisterChatServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ChatServiceClient) error
RegisterChatServiceHandlerClient registers the http handlers for service ChatService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ChatServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ChatServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "ChatServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares.
func RegisterChatServiceHandlerFromEndpoint ¶
func RegisterChatServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)
RegisterChatServiceHandlerFromEndpoint is same as RegisterChatServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterChatServiceHandlerServer ¶
func RegisterChatServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ChatServiceServer) error
RegisterChatServiceHandlerServer registers the http handlers for service ChatService to "mux". UnaryRPC :call ChatServiceServer 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 RegisterChatServiceHandlerFromEndpoint instead. GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call.
func RegisterChatServiceServer ¶
func RegisterChatServiceServer(s grpc.ServiceRegistrar, srv ChatServiceServer)
Types ¶
type ChatRequest ¶
type ChatRequest struct { Message *Message `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` // contains filtered or unexported fields }
func (*ChatRequest) Descriptor
deprecated
func (*ChatRequest) Descriptor() ([]byte, []int)
Deprecated: Use ChatRequest.ProtoReflect.Descriptor instead.
func (*ChatRequest) GetMessage ¶
func (x *ChatRequest) GetMessage() *Message
func (*ChatRequest) ProtoMessage ¶
func (*ChatRequest) ProtoMessage()
func (*ChatRequest) ProtoReflect ¶
func (x *ChatRequest) ProtoReflect() protoreflect.Message
func (*ChatRequest) Reset ¶
func (x *ChatRequest) Reset()
func (*ChatRequest) String ¶
func (x *ChatRequest) String() string
type ChatResponse ¶
type ChatResponse struct { Message *Message `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` // contains filtered or unexported fields }
func (*ChatResponse) Descriptor
deprecated
func (*ChatResponse) Descriptor() ([]byte, []int)
Deprecated: Use ChatResponse.ProtoReflect.Descriptor instead.
func (*ChatResponse) GetMessage ¶
func (x *ChatResponse) GetMessage() *Message
func (*ChatResponse) ProtoMessage ¶
func (*ChatResponse) ProtoMessage()
func (*ChatResponse) ProtoReflect ¶
func (x *ChatResponse) ProtoReflect() protoreflect.Message
func (*ChatResponse) Reset ¶
func (x *ChatResponse) Reset()
func (*ChatResponse) String ¶
func (x *ChatResponse) String() string
type ChatServiceClient ¶
type ChatServiceClient interface { LogInOrRegister(ctx context.Context, in *LogInOrRegisterRequest, opts ...grpc.CallOption) (*LogInOrRegisterResponse, error) LogOut(ctx context.Context, in *LogOutRequest, opts ...grpc.CallOption) (*LogOutResponse, error) Chat(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[ChatRequest, ChatResponse], error) }
ChatServiceClient is the client API for ChatService 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 NewChatServiceClient ¶
func NewChatServiceClient(cc grpc.ClientConnInterface) ChatServiceClient
type ChatServiceServer ¶
type ChatServiceServer interface { LogInOrRegister(context.Context, *LogInOrRegisterRequest) (*LogInOrRegisterResponse, error) LogOut(context.Context, *LogOutRequest) (*LogOutResponse, error) Chat(grpc.BidiStreamingServer[ChatRequest, ChatResponse]) error // contains filtered or unexported methods }
ChatServiceServer is the server API for ChatService service. All implementations must embed UnimplementedChatServiceServer for forward compatibility.
type ChatService_ChatClient ¶
type ChatService_ChatClient = grpc.BidiStreamingClient[ChatRequest, ChatResponse]
This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type ChatService_ChatServer ¶
type ChatService_ChatServer = grpc.BidiStreamingServer[ChatRequest, ChatResponse]
This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type LogInOrRegisterRequest ¶
type LogInOrRegisterRequest struct { Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` // contains filtered or unexported fields }
func (*LogInOrRegisterRequest) Descriptor
deprecated
func (*LogInOrRegisterRequest) Descriptor() ([]byte, []int)
Deprecated: Use LogInOrRegisterRequest.ProtoReflect.Descriptor instead.
func (*LogInOrRegisterRequest) GetPassword ¶
func (x *LogInOrRegisterRequest) GetPassword() string
func (*LogInOrRegisterRequest) GetUsername ¶
func (x *LogInOrRegisterRequest) GetUsername() string
func (*LogInOrRegisterRequest) ProtoMessage ¶
func (*LogInOrRegisterRequest) ProtoMessage()
func (*LogInOrRegisterRequest) ProtoReflect ¶
func (x *LogInOrRegisterRequest) ProtoReflect() protoreflect.Message
func (*LogInOrRegisterRequest) Reset ¶
func (x *LogInOrRegisterRequest) Reset()
func (*LogInOrRegisterRequest) String ¶
func (x *LogInOrRegisterRequest) String() string
type LogInOrRegisterResponse ¶
type LogInOrRegisterResponse struct { Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` // contains filtered or unexported fields }
func (*LogInOrRegisterResponse) Descriptor
deprecated
func (*LogInOrRegisterResponse) Descriptor() ([]byte, []int)
Deprecated: Use LogInOrRegisterResponse.ProtoReflect.Descriptor instead.
func (*LogInOrRegisterResponse) GetToken ¶
func (x *LogInOrRegisterResponse) GetToken() string
func (*LogInOrRegisterResponse) ProtoMessage ¶
func (*LogInOrRegisterResponse) ProtoMessage()
func (*LogInOrRegisterResponse) ProtoReflect ¶
func (x *LogInOrRegisterResponse) ProtoReflect() protoreflect.Message
func (*LogInOrRegisterResponse) Reset ¶
func (x *LogInOrRegisterResponse) Reset()
func (*LogInOrRegisterResponse) String ¶
func (x *LogInOrRegisterResponse) String() string
type LogOutRequest ¶
type LogOutRequest struct {
// contains filtered or unexported fields
}
func (*LogOutRequest) Descriptor
deprecated
func (*LogOutRequest) Descriptor() ([]byte, []int)
Deprecated: Use LogOutRequest.ProtoReflect.Descriptor instead.
func (*LogOutRequest) ProtoMessage ¶
func (*LogOutRequest) ProtoMessage()
func (*LogOutRequest) ProtoReflect ¶
func (x *LogOutRequest) ProtoReflect() protoreflect.Message
func (*LogOutRequest) Reset ¶
func (x *LogOutRequest) Reset()
func (*LogOutRequest) String ¶
func (x *LogOutRequest) String() string
type LogOutResponse ¶
type LogOutResponse struct {
// contains filtered or unexported fields
}
func (*LogOutResponse) Descriptor
deprecated
func (*LogOutResponse) Descriptor() ([]byte, []int)
Deprecated: Use LogOutResponse.ProtoReflect.Descriptor instead.
func (*LogOutResponse) ProtoMessage ¶
func (*LogOutResponse) ProtoMessage()
func (*LogOutResponse) ProtoReflect ¶
func (x *LogOutResponse) ProtoReflect() protoreflect.Message
func (*LogOutResponse) Reset ¶
func (x *LogOutResponse) Reset()
func (*LogOutResponse) String ¶
func (x *LogOutResponse) String() string
type Message ¶
type Message struct { Type MessageType `protobuf:"varint,1,opt,name=type,proto3,enum=chat.v1.MessageType" json:"type,omitempty"` Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` TextContent string `protobuf:"bytes,3,opt,name=text_content,json=textContent,proto3" json:"text_content,omitempty"` BinaryContent []byte `protobuf:"bytes,4,opt,name=binary_content,json=binaryContent,proto3" json:"binary_content,omitempty"` Username string `protobuf:"bytes,5,opt,name=username,proto3" json:"username,omitempty"` MessageNumber uint64 `protobuf:"varint,6,opt,name=message_number,json=messageNumber,proto3" json:"message_number,omitempty"` // contains filtered or unexported fields }
func (*Message) Descriptor
deprecated
func (*Message) GetBinaryContent ¶
func (*Message) GetMessageNumber ¶
func (*Message) GetTextContent ¶
func (*Message) GetTimestamp ¶
func (*Message) GetType ¶
func (x *Message) GetType() MessageType
func (*Message) GetUsername ¶
func (*Message) ProtoMessage ¶
func (*Message) ProtoMessage()
func (*Message) ProtoReflect ¶
func (x *Message) ProtoReflect() protoreflect.Message
type MessageType ¶
type MessageType int32
const ( MessageType_MESSAGE_TYPE_UNSPECIFIED MessageType = 0 MessageType_MESSAGE_TYPE_USERENTER MessageType = 1 MessageType_MESSAGE_TYPE_USERLEAVE MessageType = 2 MessageType_MESSAGE_TYPE_NORMAL MessageType = 3 )
func (MessageType) Descriptor ¶
func (MessageType) Descriptor() protoreflect.EnumDescriptor
func (MessageType) Enum ¶
func (x MessageType) Enum() *MessageType
func (MessageType) EnumDescriptor
deprecated
func (MessageType) EnumDescriptor() ([]byte, []int)
Deprecated: Use MessageType.Descriptor instead.
func (MessageType) Number ¶
func (x MessageType) Number() protoreflect.EnumNumber
func (MessageType) String ¶
func (x MessageType) String() string
func (MessageType) Type ¶
func (MessageType) Type() protoreflect.EnumType
type UnimplementedChatServiceServer ¶
type UnimplementedChatServiceServer struct{}
UnimplementedChatServiceServer 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 (UnimplementedChatServiceServer) LogInOrRegister ¶
func (UnimplementedChatServiceServer) LogInOrRegister(context.Context, *LogInOrRegisterRequest) (*LogInOrRegisterResponse, error)
func (UnimplementedChatServiceServer) LogOut ¶
func (UnimplementedChatServiceServer) LogOut(context.Context, *LogOutRequest) (*LogOutResponse, error)
type UnsafeChatServiceServer ¶
type UnsafeChatServiceServer interface {
// contains filtered or unexported methods
}
UnsafeChatServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to ChatServiceServer will result in compilation errors.