handler

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

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

func (c *Chat) Connect(ctx context.Context, stream pb.Chat_ConnectStream) error

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

Jump to

Keyboard shortcuts

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