forked from synerex/synerex_api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsynerex.proto
131 lines (112 loc) · 3.57 KB
/
synerex.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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
syntax = "proto3";
package api;
option go_package="github.com/synerex/synerex_api";
import "google/protobuf/timestamp.proto";
import "google/protobuf/duration.proto";
service Synerex {
rpc NotifyDemand(Demand) returns (Response) {}
rpc NotifySupply(Supply) returns (Response) {}
rpc ProposeDemand(Demand) returns (Response) {}
rpc ProposeSupply(Supply) returns (Response) {}
rpc SelectSupply(Target) returns (ConfirmResponse) {}
rpc SelectDemand(Target) returns (ConfirmResponse) {}
rpc Confirm(Target) returns (Response){}
rpc SubscribeDemand(Channel) returns (stream Demand) {}
rpc SubscribeSupply(Channel) returns (stream Supply) {}
rpc SubscribeMbus(Mbus) returns (stream MbusMsg) {}
rpc SendMsg(MbusMsg) returns (Response){}
rpc CloseMbus(Mbus) returns (Response){}
rpc SubscribeGateway(GatewayInfo) returns (stream GatewayMsg) {} // read messages
rpc ForwardToGateway(GatewayMsg) returns (Response){} // send messages
}
message Response {
bool ok = 1;
string err = 2;
}
message ConfirmResponse{
bool ok = 1;
fixed64 mbus_id = 2;
google.protobuf.Duration wait =3;
string err = 4;
}
message Content {
bytes entity = 1;
}
message Supply{
fixed64 id = 1;
fixed64 sender_id = 2;
fixed64 target_id = 3;// for message id (not for sender_id)
uint32 channel_type = 4; // channel type
string supply_name = 5;
google.protobuf.Timestamp ts = 6;
string arg_json = 7;
fixed64 mbus_id = 8; // new mbus id for select demand.
Content cdata = 9; // content data
}
message Demand {
fixed64 id = 1;
fixed64 sender_id = 2;
fixed64 target_id = 3; // if set with message id (not for sender_id) (select for supply)
uint32 channel_type = 4; // channel type
string demand_name = 5;
google.protobuf.Timestamp ts = 6;
string arg_json = 7;
fixed64 mbus_id = 8; // new mbus id for select supply...
Content cdata = 9; // content data
}
message Target {
fixed64 id = 1;
fixed64 sender_id = 2;
fixed64 target_id = 3; // for target
uint32 channel_type = 4; // channel type
google.protobuf.Duration wait = 5;
fixed64 mbus_id = 6; // if you need message bus, set Mbus with mbus_id = 1
}
message Channel {
fixed64 client_id = 1;
uint32 channel_type = 2; // channel type
string arg_json = 3; // for Channel Argument
}
message Mbus {
fixed64 client_id = 1;
fixed64 mbus_id = 2;
string arg_json = 3; // for mbus description
}
message MbusMsg {
fixed64 msg_id = 1; // if 0 for close message
fixed64 sender_id = 2;
fixed64 target_id = 3; // for target // if 0 for broadcast in mbus
fixed64 mbus_id = 4;
uint32 msg_type = 5; // for message type
string msg_info = 6; // for abstract information
string arg_json = 7;
}
enum GatewayType {
BIDIRECTIONAL = 0; // normal gateway
WRITE_ONLY = 1; // no need to receive
READ_ONLY = 2; //
}
message GatewayInfo {
fixed64 client_id = 1; // client_id (snowflake) of gateway
GatewayType gateway_type = 2;
repeated uint32 channels = 3; // which channel for forward
}
enum MsgType {
DEMAND = 0;
SUPPLY = 1;
TARGET = 2; // target for select/confirm
MBUS = 3; // mbus id for subscribe
MBUSMSG = 4;
}
// Subscribe from Gateway to SynerexServer
message GatewayMsg{ // how to prevent loop!
fixed64 src_synerex_id = 1;
MsgType msg_type = 2; // massage type
oneof msg_oneof {
Demand demand = 3;
Supply supply = 4;
Target target = 5;
Mbus mbus = 6;
MbusMsg mbus_msg= 7;
}
}