Documentation ¶
Index ¶
- type Chat
- func (c *Chat) Connect(ctx context.Context, stream pb.Chat_ConnectStream) error
- func (c *Chat) History(ctx context.Context, req *pb.HistoryRequest, rsp *pb.HistoryResponse) error
- func (c *Chat) New(ctx context.Context, req *pb.NewRequest, rsp *pb.NewResponse) error
- func (c *Chat) Send(ctx context.Context, req *pb.SendRequest, rsp *pb.SendResponse) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chat ¶
type Chat struct{}
Chat satisfies the ChatHandler interface. You can see this inteface defined in chat.pb.micro.go
func (*Chat) Connect ¶
Connect to a chat using a bidirectional stream enabling the client to send and recieve messages over a single RPC. When a message is sent on the stream, it will be added to the chat history and sent to the other connected users. When opening the connection, the client should provide the chat_id and user_id in the context so the server knows which messages to stream.
func (*Chat) History ¶
func (c *Chat) History(ctx context.Context, req *pb.HistoryRequest, rsp *pb.HistoryResponse) error
History returns the historical messages in a chat
func (*Chat) New ¶
func (c *Chat) New(ctx context.Context, req *pb.NewRequest, rsp *pb.NewResponse) error
New creates a chat for a group of users. The RPC is idempotent so if it's called multiple times for the same users, the same response will be returned. It's good practice to design APIs as idempotent since this enables safe retries.
func (*Chat) Send ¶
func (c *Chat) Send(ctx context.Context, req *pb.SendRequest, rsp *pb.SendResponse) error
Send a single message to the chat, designed for ease of use via the API / CLI