添加Centrifugo订阅发布消息服务api

This commit is contained in:
walker 2023-07-25 10:38:49 +08:00
parent c1f6f3ae59
commit a2c59b7308
7 changed files with 13802 additions and 9 deletions

9
go.mod
View File

@ -4,10 +4,12 @@ go 1.20
require (
github.com/appleboy/gin-jwt/v2 v2.9.1
github.com/gin-contrib/zap v0.1.0
github.com/spf13/viper v1.16.0
github.com/swaggo/files v1.0.1
github.com/swaggo/swag v1.16.1
go.uber.org/zap v1.23.0
google.golang.org/grpc v1.55.0
gorm.io/driver/mysql v1.5.1
gorm.io/gen v0.3.23
gorm.io/gorm v1.25.2
@ -16,15 +18,13 @@ require (
require (
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/PuerkitoBio/purell v1.2.0 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/gin-contrib/zap v0.1.0 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/spec v0.20.9 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-sql-driver/mysql v1.7.0 // indirect
github.com/golang-jwt/jwt/v4 v4.4.3 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/josharian/intern v1.0.0 // indirect
@ -35,6 +35,7 @@ require (
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/tools v0.11.0 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gorm.io/datatypes v1.1.1-0.20230130040222-c43177d3cf8c // indirect
gorm.io/hints v1.1.0 // indirect
@ -75,7 +76,7 @@ require (
golang.org/x/net v0.12.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
google.golang.org/protobuf v1.30.0
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

12
go.sum
View File

@ -153,6 +153,8 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
@ -337,8 +339,6 @@ go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8=
go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8=
go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw=
go.uber.org/zap v1.23.0 h1:OjGQ5KQDEUawVHxNwQgPpiypGHOxo2mNZsOqTak4fFY=
go.uber.org/zap v1.23.0/go.mod h1:D+nX8jyLsMHMYrln8A0rJjFt/T/9/bGgIhAqxv5URuY=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
@ -355,8 +355,6 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80=
golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g=
golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0=
golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA=
golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
@ -642,6 +640,8 @@ google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6D
google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A=
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
@ -658,6 +658,8 @@ google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8=
google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag=
google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
@ -669,6 +671,7 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
@ -684,7 +687,6 @@ gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

11677
grpcproto/api.pb.go Normal file

File diff suppressed because it is too large Load Diff

835
grpcproto/api.proto Normal file
View File

@ -0,0 +1,835 @@
syntax = "proto3";
package centrifugal.centrifugo.api;
option go_package = "./;apiproto";
service CentrifugoApi {
rpc Batch(BatchRequest) returns (BatchResponse) {}
rpc Publish (PublishRequest) returns (PublishResponse) {}
rpc Broadcast (BroadcastRequest) returns (BroadcastResponse) {}
rpc Subscribe (SubscribeRequest) returns (SubscribeResponse) {}
rpc Unsubscribe (UnsubscribeRequest) returns (UnsubscribeResponse) {}
rpc Disconnect (DisconnectRequest) returns (DisconnectResponse) {}
rpc Presence (PresenceRequest) returns (PresenceResponse) {}
rpc PresenceStats (PresenceStatsRequest) returns (PresenceStatsResponse) {}
rpc History (HistoryRequest) returns (HistoryResponse) {}
rpc HistoryRemove (HistoryRemoveRequest) returns (HistoryRemoveResponse) {}
rpc Info (InfoRequest) returns (InfoResponse) {}
rpc RPC (RPCRequest) returns (RPCResponse) {}
rpc Refresh (RefreshRequest) returns (RefreshResponse) {}
rpc Channels (ChannelsRequest) returns (ChannelsResponse) {}
rpc Connections (ConnectionsRequest) returns (ConnectionsResponse) {}
rpc UpdateUserStatus (UpdateUserStatusRequest) returns (UpdateUserStatusResponse) {}
rpc GetUserStatus (GetUserStatusRequest) returns (GetUserStatusResponse) {}
rpc DeleteUserStatus (DeleteUserStatusRequest) returns (DeleteUserStatusResponse) {}
rpc BlockUser (BlockUserRequest) returns (BlockUserResponse) {}
rpc UnblockUser (UnblockUserRequest) returns (UnblockUserResponse) {}
rpc RevokeToken (RevokeTokenRequest) returns (RevokeTokenResponse) {}
rpc InvalidateUserTokens (InvalidateUserTokensRequest) returns (InvalidateUserTokensResponse) {}
rpc DeviceRegister (DeviceRegisterRequest) returns (DeviceRegisterResponse) {}
rpc DeviceUpdate (DeviceUpdateRequest) returns (DeviceUpdateResponse) {}
rpc DeviceRemove (DeviceRemoveRequest) returns (DeviceRemoveResponse) {}
rpc DeviceList (DeviceListRequest) returns (DeviceListResponse) {}
rpc DeviceTopicList (DeviceTopicListRequest) returns (DeviceTopicListResponse) {}
rpc DeviceTopicUpdate (DeviceTopicUpdateRequest) returns (DeviceTopicUpdateResponse) {}
rpc UserTopicList (UserTopicListRequest) returns (UserTopicListResponse) {}
rpc UserTopicUpdate (UserTopicUpdateRequest) returns (UserTopicUpdateResponse) {}
rpc SendPushNotification (SendPushNotificationRequest) returns (SendPushNotificationResponse) {}
rpc UpdatePushStatus (UpdatePushStatusRequest) returns (UpdatePushStatusResponse) {}
}
message Command {
enum MethodType {
PUBLISH = 0;
BROADCAST = 1;
UNSUBSCRIBE = 2;
DISCONNECT = 3;
PRESENCE = 4;
PRESENCE_STATS = 5;
HISTORY = 6;
HISTORY_REMOVE = 7;
CHANNELS = 8;
INFO = 9;
RPC = 10;
SUBSCRIBE = 11;
REFRESH = 12;
CONNECTIONS = 14;
UPDATE_USER_STATUS = 15;
GET_USER_STATUS = 16;
DELETE_USER_STATUS = 17;
BLOCK_USER = 18;
UNBLOCK_USER = 19;
REVOKE_TOKEN = 20;
INVALIDATE_USER_TOKENS = 21;
DEVICE_REGISTER = 22;
DEVICE_UPDATE = 23;
DEVICE_REMOVE = 24;
DEVICE_LIST = 25;
DEVICE_TOPIC_LIST = 26;
DEVICE_TOPIC_UPDATE = 27;
USER_TOPIC_LIST = 28;
USER_TOPIC_UPDATE = 29;
SEND_PUSH_NOTIFICATION = 30;
UPDATE_PUSH_STATUS = 31;
}
uint32 id = 1;
MethodType method = 2;
bytes params = 3;
PublishRequest publish = 4;
BroadcastRequest broadcast = 5;
SubscribeRequest subscribe = 6;
UnsubscribeRequest unsubscribe = 7;
DisconnectRequest disconnect = 8;
PresenceRequest presence = 9;
PresenceStatsRequest presence_stats = 10;
HistoryRequest history = 11;
HistoryRemoveRequest history_remove = 12;
InfoRequest info = 13;
RPCRequest rpc = 14;
RefreshRequest refresh = 15;
ChannelsRequest channels = 16;
ConnectionsRequest connections = 17;
UpdateUserStatusRequest update_user_status = 18;
GetUserStatusRequest get_user_status = 19;
DeleteUserStatusRequest delete_user_status = 20;
BlockUserRequest block_user = 21;
UnblockUserRequest unblock_user = 22;
RevokeTokenRequest revoke_token = 23;
InvalidateUserTokensRequest invalidate_user_tokens = 24;
DeviceRegisterRequest device_register = 25;
DeviceUpdateRequest device_update = 26;
DeviceRemoveRequest device_remove = 27;
DeviceListRequest device_list = 28;
DeviceTopicListRequest device_topic_list = 29;
DeviceTopicUpdateRequest device_topic_update = 30;
UserTopicListRequest user_topic_list = 31;
UserTopicUpdateRequest user_topic_update = 32;
SendPushNotificationRequest send_push_notification = 33;
UpdatePushStatusRequest update_push_status = 34;
}
message Error {
uint32 code = 1;
string message = 2;
}
message Reply {
uint32 id = 1;
Error error = 2;
bytes result = 3;
PublishResult publish = 4;
BroadcastResult broadcast = 5;
SubscribeResult subscribe = 6;
UnsubscribeResult unsubscribe = 7;
DisconnectResult disconnect = 8;
PresenceResult presence = 9;
PresenceStatsResult presence_stats = 10;
HistoryResult history = 11;
HistoryRemoveResult history_remove = 12;
InfoResult info = 13;
RPCResult rpc = 14;
RefreshResult refresh = 15;
ChannelsResult channels = 16;
ConnectionsResult connections = 17;
UpdateUserStatusResult update_user_status = 18;
GetUserStatusResult get_user_status = 19;
DeleteUserStatusResult delete_user_status = 20;
BlockUserResult block_user = 21;
UnblockUserResult unblock_user = 22;
RevokeTokenResult revoke_token = 23;
InvalidateUserTokensResult invalidate_user_tokens = 24;
DeviceRegisterResult device_register = 25;
DeviceUpdateResult device_update = 26;
DeviceRemoveResult device_remove = 27;
DeviceListResult device_list = 28;
DeviceTopicListResult device_topic_list = 29;
DeviceTopicUpdateResult device_topic_update = 30;
UserTopicListResult user_topic_list = 31;
UserTopicUpdateResult user_topic_update = 32;
SendPushNotificationResult send_push_notification = 33;
UpdatePushStatusResult update_push_status = 34;
}
message BoolValue {
bool value = 1;
}
message Int32Value {
int32 value = 1;
}
message SubscribeOptionOverride {
BoolValue presence = 1;
BoolValue join_leave = 2;
BoolValue force_recovery = 3;
BoolValue force_positioning = 4;
BoolValue force_push_join_leave = 5;
}
message BatchRequest {
repeated Command commands = 1;
}
message BatchResponse {
repeated Reply replies = 1;
}
message PublishRequest {
string channel = 1;
bytes data = 2;
string b64data = 3;
bool skip_history = 4;
map<string, string> tags = 5;
}
message PublishResponse {
Error error = 1;
PublishResult result = 2;
}
message PublishResult {
uint64 offset = 1;
string epoch = 2;
}
message BroadcastRequest {
repeated string channels = 1;
bytes data = 2;
string b64data = 3;
bool skip_history = 4;
map<string, string> tags = 5;
}
message BroadcastResponse {
Error error = 1;
BroadcastResult result = 2;
}
message BroadcastResult {
repeated PublishResponse responses = 1;
}
message SubscribeRequest {
string channel = 1;
string user = 2;
int64 expire_at = 3;
bytes info = 4;
string b64info = 5;
string client = 6;
bytes data = 7;
string b64data = 8;
StreamPosition recover_since = 9;
SubscribeOptionOverride override = 10;
string session = 11;
}
message SubscribeResponse {
Error error = 1;
SubscribeResult result = 2;
}
message SubscribeResult {}
message UnsubscribeRequest {
string channel = 1;
string user = 2;
string client = 3;
string session = 4;
}
message UnsubscribeResponse {
Error error = 1;
UnsubscribeResult result = 2;
}
message UnsubscribeResult {}
message Disconnect {
reserved 3;
uint32 code = 1;
string reason = 2;
}
message DisconnectRequest {
string user = 1;
Disconnect disconnect = 2;
string client = 3;
repeated string whitelist = 4;
string session = 5;
}
message DisconnectResponse {
Error error = 1;
DisconnectResult result = 2;
}
message DisconnectResult {}
message PresenceRequest {
string channel = 1;
}
message PresenceResponse {
Error error = 1;
PresenceResult result = 2;
}
message ClientInfo {
string user = 1;
string client = 2;
bytes conn_info = 3;
bytes chan_info = 4;
}
message PresenceResult {
map<string, ClientInfo> presence = 1;
}
message PresenceStatsRequest {
string channel = 1;
}
message PresenceStatsResponse {
Error error = 1;
PresenceStatsResult result = 2;
}
message PresenceStatsResult {
uint32 num_clients = 1;
uint32 num_users = 2;
}
message StreamPosition {
uint64 offset = 1;
string epoch = 2;
}
message HistoryRequest {
string channel = 1;
int32 limit = 2;
StreamPosition since = 3;
bool reverse = 4;
}
message HistoryResponse {
Error error = 1;
HistoryResult result = 2;
}
message Publication {
// Removed: string uid = 1;
bytes data = 2;
ClientInfo info = 3;
uint64 offset = 4;
map<string, string> tags = 5;
}
message HistoryResult {
repeated Publication publications = 1;
string epoch = 2;
uint64 offset = 3;
}
message HistoryRemoveRequest {
string channel = 1;
}
message HistoryRemoveResponse {
Error error = 1;
HistoryRemoveResult result = 2;
}
message HistoryRemoveResult {}
message InfoRequest {}
message InfoResponse {
Error error = 1;
InfoResult result = 2;
}
message InfoResult {
repeated NodeResult nodes = 1;
}
message RPCRequest {
string method = 1;
bytes params = 2;
}
message RPCResponse {
Error error = 1;
RPCResult result = 2;
}
message RPCResult {
bytes data = 1;
}
message RefreshRequest {
string user = 1;
string client = 2;
bool expired = 3;
int64 expire_at = 4;
bytes info = 5;
string session = 6;
}
message RefreshResponse {
Error error = 1;
RefreshResult result = 2;
}
message RefreshResult {}
message NodeResult {
string uid = 1;
string name = 2;
string version = 3;
uint32 num_clients = 4;
uint32 num_users = 5;
uint32 num_channels = 6;
uint32 uptime = 7;
Metrics metrics = 8;
Process process = 9;
uint32 num_subs = 10;
}
message Metrics {
double interval = 1;
map<string, double> items = 2;
}
message Process {
double cpu = 1;
int64 rss = 2;
}
message ChannelsRequest {
string pattern = 1;
}
message ChannelsResponse {
Error error = 1;
ChannelsResult result = 2;
}
message ChannelsResult {
map<string, ChannelInfo> channels = 1;
}
message ChannelInfo {
uint32 num_clients = 1;
}
message ConnectionsRequest {
string user = 1;
string expression = 2;
}
message ConnectionsResponse {
Error error = 1;
ConnectionsResult result = 2;
}
message ConnectionsResult {
map<string, ConnectionInfo> connections = 1;
}
message ConnectionInfo {
string app_name = 1;
string app_version = 2;
string transport = 3;
string protocol = 4;
// 5-7 dropped for backwards compatibility.
string user = 8;
ConnectionState state = 9;
}
message ConnectionState {
map<string, ChannelContext> channels = 1;
ConnectionTokenInfo connection_token = 2;
map<string, SubscriptionTokenInfo> subscription_tokens = 3;
bytes meta = 4;
}
message ChannelContext {
uint32 source = 1;
}
message ConnectionTokenInfo {
string uid = 1;
int64 issued_at = 2;
}
message SubscriptionTokenInfo {
string uid = 1;
int64 issued_at = 2;
}
message UpdateUserStatusRequest {
repeated string users = 1;
}
message UpdateUserStatusResponse {
Error error = 1;
UpdateUserStatusResult result = 2;
}
message UpdateUserStatusResult {}
message GetUserStatusRequest {
repeated string users = 1;
}
message GetUserStatusResponse {
Error error = 1;
GetUserStatusResult result = 2;
}
message GetUserStatusResult {
repeated UserStatus statuses = 1;
}
message UserStatus {
string user = 1;
int64 active = 2;
int64 online = 3;
}
message DeleteUserStatusRequest {
repeated string users = 1;
}
message DeleteUserStatusResponse {
Error error = 1;
DeleteUserStatusResult result = 2;
}
message DeleteUserStatusResult {
}
message BlockUserRequest {
int64 expire_at = 1;
string user = 2;
}
message BlockUserResult {}
message BlockUserResponse {
Error error = 1;
BlockUserResult result = 2;
}
message UnblockUserRequest {
string user = 1;
}
message UnblockUserResult {}
message UnblockUserResponse {
Error error = 1;
UnblockUserResult result = 2;
}
message RevokeTokenRequest {
int64 expire_at = 1;
string uid = 2;
}
message RevokeTokenResult {}
message RevokeTokenResponse {
Error error = 1;
RevokeTokenResult result = 2;
}
message InvalidateUserTokensRequest {
int64 expire_at = 1;
string user = 2;
int64 issued_before = 3;
string channel = 4;
}
message InvalidateUserTokensResult {}
message InvalidateUserTokensResponse {
Error error = 1;
InvalidateUserTokensResult result = 2;
}
message DeviceRegisterRequest {
string id = 1;
string provider = 2;
string token = 3;
string platform = 4;
string user = 5;
map<string, string> meta = 6;
repeated string topics = 7;
//map<string, string> labels = 8;
//map<string, int64> scores = 9;
}
message DeviceUpdateRequest {
repeated string ids = 1;
repeated string users = 2;
DeviceUserUpdate user_update = 4;
DeviceMetaUpdate meta_update = 5;
DeviceTopicsUpdate topics_update = 6;
//DeviceLabelsUpdate labels_update = 7;
//DeviceScoresUpdate scores_update = 8;
}
message DeviceRemoveRequest {
repeated string ids = 1;
repeated string users = 2;
}
message DeviceUserUpdate {
string user = 1;
}
message DeviceMetaUpdate {
map<string, string> meta = 1;
}
message DeviceTopicsUpdate {
string op = 1; // add | remove | set
repeated string topics = 2;
}
message DeviceFilter {
repeated string ids = 1;
repeated string users = 2;
repeated string topics = 3;
repeated string providers = 4;
repeated string platforms = 5;
}
message DeviceListRequest {
DeviceFilter filter = 1;
bool include_total_count = 2;
bool include_meta = 3;
bool include_topics = 4;
//bool include_labels = 5;
//bool include_scores = 6;
string cursor = 10;
int32 limit = 11;
}
message DeviceTopicFilter {
repeated string device_ids = 1;
repeated string device_providers = 2;
repeated string device_platforms = 3;
repeated string device_users = 4;
repeated string topics = 5;
string topic_prefix = 6;
}
message DeviceTopicListRequest {
DeviceTopicFilter filter = 1;
bool include_total_count = 2;
bool include_device = 3;
string cursor = 10;
int32 limit = 11;
}
message UserTopicFilter {
repeated string users = 1;
repeated string topics = 2;
string topic_prefix = 3;
}
message UserTopicListRequest {
UserTopicFilter filter = 1;
bool include_total_count = 2;
string cursor = 10;
int32 limit = 11;
}
message DeviceTopicUpdateRequest {
string device_id = 1;
string op = 2; // add | remove | set
repeated string topics = 3;
}
message UserTopicUpdateRequest {
string user = 1;
string op = 2; // add | remove | set
repeated string topics = 3;
}
message DeviceRegisterResponse {
Error error = 1;
DeviceRegisterResult result = 2;
}
message DeviceUpdateResponse {
Error error = 1;
DeviceUpdateResult result = 2;
}
message DeviceRemoveResponse {
Error error = 1;
DeviceRemoveResult result = 2;
}
message DeviceListResponse {
Error error = 1;
DeviceListResult result = 2;
}
message DeviceTopicListResponse {
Error error = 1;
DeviceTopicListResult result = 2;
}
message UserTopicListResponse {
Error error = 1;
UserTopicListResult result = 2;
}
message DeviceTopicUpdateResponse {
Error error = 1;
DeviceTopicUpdateResult result = 2;
}
message UserTopicUpdateResponse {
Error error = 1;
UserTopicUpdateResult result = 2;
}
message DeviceRegisterResult {
string id = 1;
}
message DeviceUpdateResult {
}
message DeviceRemoveResult {
}
message DeviceListResult {
repeated Device items = 1;
string next_cursor = 2;
int64 total_count = 3;
}
message Device {
string id = 1;
string platform = 2;
string provider = 3;
string token = 4;
string user = 5;
int64 created_at = 6;
int64 updated_at = 7;
map<string, string> meta = 10;
repeated string topics = 11;
//map<string, string> labels = 12;
//map<string, int64> scores = 13;
}
message DeviceTopicListResult {
repeated DeviceTopic items = 1;
string next_cursor = 2;
int64 total_count = 3;
}
message DeviceTopic {
string id = 1;
string topic = 2;
Device device = 3;
}
message UserTopicListResult {
repeated UserTopic items = 1;
string next_cursor = 2;
int64 total_count = 3;
}
message DeviceTopicUpdateResult {
}
message UserTopicUpdateResult {
}
message UserTopic {
string id = 1;
string user = 2;
string topic = 3;
}
message PushRecipient {
DeviceFilter filter = 1;
repeated string fcm_tokens = 2;
string fcm_topic = 3;
string fcm_condition = 4;
repeated string hms_tokens = 5;
string hms_topic = 6;
string hms_condition = 7;
repeated string apns_tokens = 8;
}
message PushNotification {
FcmPushNotification fcm = 1;
HmsPushNotification hms = 2;
ApnsPushNotification apns = 3;
string uid = 4; // unique identifier for push notification, used for matching in Centrifugo analytics.
int64 expire_at = 5; // timestamp in the future when Centrifugo should stop trying to send push notification.
}
message FcmPushNotification {
bytes message = 1;
}
message HmsPushNotification {
bytes message = 1;
}
message ApnsPushNotification {
map<string, string> headers = 1;
bytes payload = 2;
}
message SendPushNotificationRequest {
PushRecipient recipient = 1;
PushNotification notification = 2;
}
message SendPushNotificationResponse {
Error error = 1;
SendPushNotificationResult result = 2;
}
message SendPushNotificationResult {
string uid = 1; // Unique identifier of notification send request (it's not a FCM message id).
}
message UpdatePushStatusRequest {
string uid = 1; // uid of push notification (matches SendPushNotificationResult.uid)
string status = 2; // failed | sent | delivered | interacted
string device_id = 3; // Centrifugo device id.
string msg_id = 4; // Provider issued message id.
}
message UpdatePushStatusResponse {
Error error = 1;
UpdatePushStatusResult result = 2;
}
message UpdatePushStatusResult {}

1256
grpcproto/api_grpc.pb.go Normal file

File diff suppressed because it is too large Load Diff

17
grpcproto/client.go Normal file
View File

@ -0,0 +1,17 @@
package apiproto
import grpc "google.golang.org/grpc"
var client CentrifugoApiClient
func InitClient() {
conn, err := grpc.Dial("192.168.3.158:10000", grpc.WithInsecure())
if err != nil {
panic(err)
}
client = NewCentrifugoApiClient(conn)
}
func Cli() CentrifugoApiClient {
return client
}

View File

@ -27,3 +27,8 @@ logging:
compress: false
# 控制台是否输出
stdout: true
messaging:
centrifugo:
tokenSecret: aaa
apiKey: bbb
apiEndpoint: /api