lichao
2021-05-19 34cd75f77d0ca94dbdba4e6cc9451fe4d33e78b3
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
syntax = "proto3";
option optimize_for = LITE_RUNTIME;
option go_package="./bhome_msg";
 
// import "google/protobuf/descriptor.proto";
import "bhome_msg_api.proto";
import "error_msg.proto";
 
package bhome_msg;
 
 
// message format : head_len(4) + head(BHMsgHead) + body_len(4) + body(variable types)
 
message BHMsgHead {
    bytes msg_id = 1;
    repeated BHAddress route = 2; // for reply and proxy.
    int64 timestamp = 3;
    int32 type = 4;
    uint64 ssn_id = 5; // node mq id
    bytes proc_id = 6;
    bytes topic = 7; // for request route
}
 
 
enum MsgType {
    kMsgTypeInvalid = 0;
    kMsgTypeRawData = 1;
 
    kMsgTypeCommonReply = 2;
 
    kMsgTypeProcInit = 8;
    kMsgTypeProcInitReply = 9;
    kMsgTypeRegister= 10;
    // kMsgTypeRegisterReply= 11;
    kMsgTypeHeartbeat = 12;
    // kMsgTypeHeartbeatReply = 13;
    kMsgTypeQueryTopic = 14;
    kMsgTypeQueryTopicReply = 15;
    kMsgTypeRequestTopic = 16;
    kMsgTypeRequestTopicReply = 17;
    kMsgTypeRegisterRPC = 18;
    // reply
 
    kMsgTypePublish = 20;
    // kMsgTypePublishReply = 21;
    kMsgTypeSubscribe = 22;
    // kMsgTypeSubscribeReply = 23;
    kMsgTypeUnsubscribe = 24;
    // kMsgTypeUnsubscribeReply = 25;
    kMsgTypeUnregister = 26;
    // kMsgTypeUnregisterReply = 27;
    kMsgTypeQueryProc = 28;
    kMsgTypeQueryProcReply = 29;
 
}
 
message MsgSubscribe {
    MsgTopicList topics = 1;
}
message MsgUnsubscribe {
    MsgTopicList topics = 1;
}
message MsgRegisterRPC {
    MsgTopicList topics = 1;
}
 
message MsgProcInit{ 
    int32 extra_mq_num = 1;
} // proc_id is in header.
 
message MsgProcInitReply {
    ErrorMsg errmsg = 1;
    int32 proc_index = 2;
    repeated BHAddress extra_mqs = 3;
}
 
service TopicRPC {
    rpc Query (MsgQueryTopic) returns (MsgQueryTopicReply);
    rpc Request (MsgRequestTopic) returns (MsgQueryTopicReply);
}
 
message MsgRequest {
    // oneof body;
    oneof request {
        MsgRegister register = 1;
        MsgRequestTopic topic_request = 2;
        MsgQueryTopic topic_query = 3;
    }
}
 
message MsgReply {
    ErrorMsg err_msg = 1;
    // oneof reply
}
 
message BHMsgBody {
    oneof reqrep {
        MsgRequest request = 1;
        MsgReply reply = 2;
    }
}