lichao
2021-04-06 4deeafbd502dc3c57dab8ad6ca601a38a9e7f074
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
syntax = "proto3";
 
option optimize_for = LITE_RUNTIME;
 
import "google/protobuf/descriptor.proto";
import "error_msg.proto";
 
package bhome.msg;
 
 
// message format : header(BHMsgHead) + body(variable types)
message BHAddress {
    bytes mq_id = 1; // mqid, uuid
    bytes ip = 2;   //
    int32 port = 3;
}
 
message ProcInfo
{
    bytes id = 1; // serial number, maybe managed
    bytes name = 2;
    bytes public_info = 3;
    bytes private_info = 4;
}
 
message BHMsgHead {
    bytes msg_id = 1;
    repeated BHAddress route = 2; // for reply and proxy.
    int64 timestamp = 3;
    int32 type = 4;
    ProcInfo proc = 5;
    bytes topic = 6; // for request route
}
 
message BHMsgBody {
    bytes data = 1;
}
 
message BHMsg { // deprecated
    bytes msg_id = 1;
    int64 timestamp = 2;
    int32 type = 3;
    repeated BHAddress route = 4; // for reply and proxy.
    bytes body = 5;
}
 
enum MsgType {
    kMsgTypeInvalid = 0;
 
    kMsgTypeCommonReply = 2;
 
    kMsgTypeRegister= 10;
    // kMsgTypeRegisterReply= 11;
    kMsgTypeHeartbeat = 12;
    // kMsgTypeHeartbeatReply = 13;
    kMsgTypeQueryTopic = 14;
    kMsgTypeQueryTopicReply = 15;
    kMsgTypeRequestTopic = 16;
    kMsgTypeRequestTopicReply = 17;
 
    kMsgTypePublish = 100;
    // kMsgTypePublishReply = 101;
    kMsgTypeSubscribe = 102;
    // kMsgTypeSubscribeReply = 103;
    kMsgTypeUnsubscribe = 104;
    // kMsgTypeUnsubscribeReply = 105;
 
}
 
message MsgPub {
    bytes topic = 1;
    bytes data = 2; 
}
 
message MsgSub {
    repeated bytes topics = 1;
}
 
message MsgCommonReply {
    ErrorMsg errmsg = 1;
}
 
message MsgRequestTopic {
    bytes topic = 1;
    bytes data = 2; 
}
 
message MsgRequestTopicReply {
    ErrorMsg errmsg = 1;
    bytes data = 2; 
}
 
message MsgRegister
{
    ProcInfo proc = 1;
    repeated bytes topics = 2;
}
 
message MsgHeartbeat
{
    ProcInfo proc = 1;
}
 
message MsgQueryTopic {
    bytes topic = 1;
}
 
message MsgQueryTopicReply {
    ErrorMsg errmsg = 1;
    BHAddress address = 2;
}
 
service TopicRPC {
    rpc Query (MsgQueryTopic) returns (MsgQueryTopicReply);
    rpc Request (MsgRequestTopic) returns (MsgQueryTopicReply);
}