You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
100 lines
2.2 KiB
100 lines
2.2 KiB
syntax = "proto3"; |
|
import "google/protobuf/empty.proto"; |
|
|
|
option go_package = "./postal"; |
|
|
|
enum DeliverResult { |
|
Success = 0; |
|
ReceiverOffline = 1; |
|
} |
|
|
|
service Postal { |
|
rpc Deliver(ReqDeliver) returns (ResDeliver); |
|
rpc DeliverBatch(ReqDeliverBatch) returns(ResDeliver); |
|
rpc DeliverGroup(ReqDeliverGroup) returns(ResDeliver); |
|
|
|
// rpc GroupCreate(ReqGroupCreate) returns(ResGroupCreate); |
|
rpc GroupJoin(ReqGroupJoin) returns(google.protobuf.Empty); |
|
rpc GroupLeave(ReqGroupLeave) returns(google.protobuf.Empty); |
|
rpc GroupDissolve(ReqGroupDissolve) returns(google.protobuf.Empty); |
|
|
|
// 返回当前节点外部连接断点, 如 websocket addr |
|
rpc Endpoint(google.protobuf.Empty) returns(ResEndpoint); |
|
} |
|
|
|
message Message { |
|
int64 time = 3; |
|
int32 svcNo = 4; |
|
int32 msgNo = 5; |
|
string svc = 13; |
|
string msg = 14; |
|
bytes body = 15; // protobuf bytes |
|
} |
|
|
|
message ReqDeliver { |
|
string receiver = 1; |
|
Message msg = 2; |
|
|
|
// bool sync = 7; // 是否同步阻塞等待投递结果, 默认false立即返回放到队列消费投递 |
|
} |
|
|
|
message ResDeliver { |
|
bool ok = 1; |
|
int32 code = 2; |
|
string msg = 3; |
|
} |
|
|
|
message ReqDeliverBatch { |
|
repeated string receivers = 1; |
|
Message msg = 2; |
|
} |
|
|
|
message ReqDeliverGroup { |
|
string gid = 1; |
|
Message msg = 2; |
|
} |
|
|
|
message ReqGroupCreate { |
|
string gid = 1; // 群id |
|
map<string, string> tags = 3; // 群标签... |
|
|
|
bool persistent = 7; // 群关系是否持久化, 默认否 |
|
} |
|
|
|
message ResGroupCreate { |
|
string gid = 1; // 群id |
|
} |
|
|
|
message ReqGroupJoin { |
|
string uid = 1; |
|
repeated string gid = 2; |
|
} |
|
|
|
message ReqGroupLeave { |
|
string uid = 1; |
|
repeated string gid = 2; |
|
} |
|
|
|
message ReqGroupDissolve { |
|
string gid = 1; |
|
} |
|
|
|
// 集群之间接口调用,重定向消息... |
|
service PostalCluster { |
|
// socket不在当前节点,重新投递消息 |
|
rpc Redirect(ReqRedirect) returns(ResDeliver); |
|
} |
|
|
|
message ReqRedirect { |
|
int32 ttl = 1; // 投递一次减一, 到0丢弃 |
|
int32 redirectMethod = 2; // 10 deliver, 11 deliverBatch, 12 deliverGroup |
|
// bool sync = 7; // 是否同步阻塞等待投递结果,否则放到channel顺序投递 |
|
ReqDeliver deliver = 10; |
|
ReqDeliverBatch deliverBatch = 11; |
|
ReqDeliverGroup deliverGroup = 12; |
|
} |
|
|
|
message ResEndpoint { |
|
string endpoint = 1; |
|
map<string, string> extra = 2; |
|
}
|
|
|