mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-11 19:04:35 +00:00
* Autogenerate services.m3o.com * Openapi for all * Gen * Fix * Whaat * Fix dep * Fix * Hmm * Install make * Debug * Debug 1 * Location -> locations * Fix * Intall protoc gen micro * F * F * F * Push * Rename secret * Fix npm install * Fix script * Fix v2 * Ignore errors * Ignore v2 * F * F * F * Docs index * Add hugo theme * Hugo tania fixes * Change gen * Change gen 2 * Install hugo * Change gen * Gen fix * Change hugo install * Change hugo install * CNAME * Change articles wording * Tiny fix * Fix gen * Redoc it all * Fix gen * Fixing up protos * Fix proto * Fix gen * Fix * Trigger build * Fix copy * Openapi docs * Flatten * Changes * No date vol2 * Changes * Add make to chat * Fixes * Change * api spec * replace RSS * fix link * Dont continue on error * increase the width * use micro at master * change box colours * move some things * Pushing new readmes to see how they look like * Add skip file * Readmes * Nicer api link * Remove stutter * FIx mistake * set service font weight * Messages readme fix * add other font bold * Notes * Remove post from url * Revert "Remove post from url" This reverts commit 5fea2c23d0bafa910f5dc4d4cc63f71f578530e3. * move exampleSite to site * replace exampleSite with site * update readme * use filename for post * update index * Add source urls * set source as params * set source as params * Fix entries * Generator in go * Fixes to generator * F * Change doc gen * FIx cname * Fixing protos * Change to makefiles * Fix gen script Co-authored-by: Asim Aslam <asim@aslam.me>
77 lines
2.7 KiB
Protocol Buffer
77 lines
2.7 KiB
Protocol Buffer
syntax = "proto3";
|
|
|
|
package chat;
|
|
option go_package = "proto;chat";
|
|
|
|
service Chat {
|
|
// 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.
|
|
rpc New(NewRequest) returns (NewResponse);
|
|
// History returns the historical messages in a chat
|
|
rpc History(HistoryRequest) returns (HistoryResponse);
|
|
// Send a single message to the chat
|
|
rpc Send(SendRequest) returns (SendResponse);
|
|
// 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.
|
|
rpc Connect(stream Message) returns (stream Message);
|
|
}
|
|
|
|
// NewRequest contains the infromation needed to create a new chat
|
|
message NewRequest {
|
|
repeated string user_ids = 1;
|
|
}
|
|
|
|
// NewResponse contains the chat id for the users
|
|
message NewResponse {
|
|
string chat_id = 1;
|
|
}
|
|
|
|
// HistoryRequest contains the id of the chat we want the history for. This RPC will return all
|
|
// historical messages, however in a real life application we'd introduce some form of pagination
|
|
// here, only loading the older messages when required.
|
|
message HistoryRequest {
|
|
string chat_id = 1;
|
|
}
|
|
|
|
// HistoryResponse contains the historical messages in a chat
|
|
message HistoryResponse {
|
|
repeated Message messages = 1;
|
|
}
|
|
|
|
// SendRequest contains a single message to send to a chat
|
|
message SendRequest {
|
|
// a client side id, should be validated by the server to make the request retry safe
|
|
string client_id = 1;
|
|
// id of the chat the message is being sent to / from
|
|
string chat_id = 2;
|
|
// id of the user who sent the message
|
|
string user_id = 3;
|
|
// subject of the message
|
|
string subject = 4;
|
|
// text of the message
|
|
string text = 5;
|
|
}
|
|
|
|
// SendResponse is a blank message returned when a message is successfully created
|
|
message SendResponse {}
|
|
|
|
// Message sent to a chat
|
|
message Message {
|
|
// id of the message, allocated by the server
|
|
string id = 1;
|
|
// a client side id, should be validated by the server to make the request retry safe
|
|
string client_id = 2;
|
|
// id of the chat the message is being sent to / from
|
|
string chat_id = 3;
|
|
// id of the user who sent the message
|
|
string user_id = 4;
|
|
// time time the message was sent in unix format
|
|
int64 sent_at = 5;
|
|
// subject of the message
|
|
string subject = 6;
|
|
// text of the message
|
|
string text = 7;
|
|
} |