-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessaging.proto
63 lines (48 loc) · 1.63 KB
/
messaging.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
syntax = "proto3";
package dev.federicopellegatta.messaging;
option java_multiple_files = true;
import "google/protobuf/timestamp.proto";
// Message request definition
message MessageRequest {
Person sender = 1;
string content = 2;
google.protobuf.Timestamp send_time = 3;
}
// Message response definition
message MessageResponse {
string recipient = 1;
string content = 2;
google.protobuf.Timestamp read_time = 3;
}
// Response for client-streaming service
message GroupedMessagesResponse {
repeated SenderMessagesPair sender_messages = 1;
}
// Pair of sender and messages
message SenderMessagesPair {
Person sender = 1;
repeated string messages = 2;
}
message RecipientsRequest {
repeated Person recipients = 1;
}
message Person {
string name = 1;
optional int32 age = 2;
optional Gender gender = 3;
}
enum Gender {
MALE = 0;
FEMALE = 1;
}
// Messaging service definition
service MessagingService {
// synchronous method (unary): client sends a message and waits for a response
rpc sendMessage(MessageRequest) returns (MessageResponse);
// asynchronous method (client-streaming method): client sends multiple messages and receives a combined response
rpc collectMessagesBySender(stream MessageRequest) returns (GroupedMessagesResponse);
// asynchronous method (server-streaming method): client sends a message and receives multiple responses
rpc sendMessageToAll(RecipientsRequest) returns (stream MessageResponse);
// asynchronous method (bi-directional): client sends a stream of messages and receives a stream of responses
rpc sendMessageStream(stream MessageRequest) returns (stream MessageResponse);
}