From 952ddc7308d6825c0fc2b2a74047c4972098feff Mon Sep 17 00:00:00 2001 From: hujiebin Date: Thu, 9 Feb 2023 16:10:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:proto=E8=AF=95=E8=AF=95=E7=9C=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 6 +- Makefile | 2 + go.mod | 6 + go.sum | 108 ++++++++++++ protocol/biz.proto | 19 ++ protocol/userCenter.proto | 99 +++++++++++ protocol/userProxy.proto | 352 ++++++++++++++++++++++++++++++++++++++ protocol/video.proto | 16 ++ rpc/logRpc.go | 73 ++++++++ rpc/user_center.go | 186 ++++++++++++++++++++ rpc/user_center_coder.go | 119 +++++++++++++ rpc/user_center_func.go | 67 ++++++++ 12 files changed, 1052 insertions(+), 1 deletion(-) create mode 100644 Makefile create mode 100644 protocol/biz.proto create mode 100644 protocol/userCenter.proto create mode 100644 protocol/userProxy.proto create mode 100644 protocol/video.proto create mode 100644 rpc/logRpc.go create mode 100644 rpc/user_center.go create mode 100644 rpc/user_center_coder.go create mode 100644 rpc/user_center_func.go diff --git a/.gitignore b/.gitignore index 1dbe768..da7b0ad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ .idea -*.xlsx \ No newline at end of file +*.xlsx +/protocol/biz/ +/protocol/userProxy/ +/protocol/video/ +/protocol/userCenter/ \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..fc36481 --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +proto: + protoc --go_out=./ --go-grpc_out=. ./protocol/*.proto \ No newline at end of file diff --git a/go.mod b/go.mod index 2512cc9..4231b5a 100644 --- a/go.mod +++ b/go.mod @@ -10,6 +10,7 @@ require ( github.com/fatih/color v1.9.0 // indirect github.com/go-redis/redis/v8 v8.11.5 // indirect github.com/go-sql-driver/mysql v1.6.0 // indirect + github.com/golang/protobuf v1.5.0 // indirect github.com/hashicorp/consul/api v1.7.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.1 // indirect github.com/hashicorp/go-hclog v0.12.0 // indirect @@ -35,7 +36,12 @@ require ( github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.479 // indirect github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ims v1.0.479 // indirect github.com/tencentyun/tls-sig-api-v2-golang v1.0.0 // indirect + golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 // indirect golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect + golang.org/x/text v0.3.6 // indirect + google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect + google.golang.org/grpc v1.42.0 // indirect + google.golang.org/protobuf v1.28.1 // indirect gopkg.in/ini.v1 v1.63.2 // indirect gorm.io/driver/mysql v1.4.3 // indirect gorm.io/gorm v1.23.8 // indirect diff --git a/go.sum b/go.sum index ac20c2b..285d7ee 100644 --- a/go.sum +++ b/go.sum @@ -1,25 +1,68 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da h1:8GUt8eRujhVEGZFFEjBj46YV4rDjvGrNxb0KMWYkL2I= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= +github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI= github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +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 h1:LUVKkCeviFUMKqHa4tXIIij/lbhnMbP7Fn5wKdKkRh4= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hashicorp/consul/api v1.7.0 h1:tGs8Oep67r8CcA2Ycmb/8BLBcJ70St44mF2X10a/qPg= github.com/hashicorp/consul/api v1.7.0/go.mod h1:1NSuaUUkFaJzMasbfq/11wKYWSR67Xn6r2DXKhuDNFg= github.com/hashicorp/consul/sdk v0.6.0/go.mod h1:fY08Y9z5SvJqevyZNy6WWPXiG3KwBPAvlcdx16zZ0fM= @@ -89,8 +132,10 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 h1:mZHayPoR0lNmnHyvtYjDeq0zlVHn9K/ZXoy17ylucdo= github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5/go.mod h1:GEXHk5HgEKCvEIIrSpFI3ozzG5xOKA2DVlEX/gGnewM= +github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= @@ -105,6 +150,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/tealeg/xlsx v1.0.5 h1:+f8oFmvY8Gw1iUXzPk+kz+4GpbDZPK1FhPiQRd+ypgE= github.com/tealeg/xlsx v1.0.5/go.mod h1:btRS8dz54TDnvKNosuAqxrM1QgN1udgk9O34bDCnORM= @@ -118,19 +164,39 @@ github.com/tencentyun/tls-sig-api-v2-golang v1.1.0 h1:dWbCuoTaRWvcS/RWW/8RIAvLRA github.com/tencentyun/tls-sig-api-v2-golang v1.1.0/go.mod h1:D/i1nQrP1hSXxxz+SAmjaprAwH3EhYaktJG6BObWnFE= github.com/tencentyun/tls-sig-api-v2-golang v1.3.0 h1:mW4onVqOP6MqkJtTay74Tch6NvjwQRXeCuhUC/p6YYk= github.com/tencentyun/tls-sig-api-v2-golang v1.3.0/go.mod h1:0L1MSijyEq6a74xZ02h0qKfN8y6RcvDiNabIZWXereE= +go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 h1:DzZ89McO9/gWPsQXS/FVKAlG02ZjaQ6AlZRBimEYOd0= +golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -138,21 +204,63 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.42.0 h1:XT2/MFpuPFsEX2fWh3YQtHkZ+WYZFQRfaUgLZYj/p6A= +google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= +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= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +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.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/ini.v1 v1.63.2 h1:tGK/CyBg7SMzb60vP1M03vNZ3VDu3wGQJwn7Sxi9r3c= gopkg.in/ini.v1 v1.63.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gorm.io/driver/mysql v1.4.3 h1:/JhWJhO2v17d8hjApTltKNADm7K7YI2ogkR7avJUL3k= gorm.io/driver/mysql v1.4.3/go.mod h1:sSIebwZAVPiT+27jK9HIwvsqOGKx3YMPmrA3mBJR10c= gorm.io/gorm v1.23.8 h1:h8sGJ+biDgBA1AD1Ha9gFCx7h8npU7AsLdlkX0n2TpE= gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/protocol/biz.proto b/protocol/biz.proto new file mode 100644 index 0000000..68b1461 --- /dev/null +++ b/protocol/biz.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; +package biz; + +option go_package = "protocol/biz"; + +/* id = 1 */ +message BizMessage { + uint32 type = 2; + string payLoad = 3; +} + +/* id = 2 */ +message BizMessageRsp { + uint32 status = 1; +} + +service Transmitter { + rpc process(BizMessage) returns (BizMessageRsp) {} +} \ No newline at end of file diff --git a/protocol/userCenter.proto b/protocol/userCenter.proto new file mode 100644 index 0000000..10535b3 --- /dev/null +++ b/protocol/userCenter.proto @@ -0,0 +1,99 @@ +syntax = "proto3"; +package userCenter; + +option go_package = "protocol/userCenter"; + +/* id = 1 */ +message RouteMessage { + uint64 uid = 1; + uint32 msgType = 2; + bytes payLoad = 3; +} + +/* id = 2 */ +message RouteMessageRsp { + uint32 status = 1; +} + +/* id = 3 */ +message LoginMessage { + string proxyAddr = 1; // userProxy的地址:ip:port + string token = 2; + string clientAddr = 3; // 客户端地址(websocket):ip:port +} + +/* id = 4 */ +message LoginMessageRsp { + uint32 status = 1; + uint64 uid = 2; +} + +/* id = 5 */ +message LogoutMessage { + string clientAddr = 1; // 客户端地址(websocket):ip:port + uint64 uid = 2; +} + +/* id = 6 */ +message LogoutMessageRsp { + uint32 status = 1; +} + +/* id = 7 */ +message MulticastMessage { + repeated uint64 uids = 1; + uint32 msgType = 2; + bytes payLoad = 3; +} + +/* id = 8 */ +message MulticastMessageRsp { + repeated uint64 failedUids = 1; +} + +/* id = 9 */ +message KickMessage { + uint64 uid = 1; + string addr = 2; +} + +/* id = 10 */ +message KickMessageRsp { + uint32 status = 1; +} + +/* id = 11 */ +message BroadcastMessage { + uint32 msgType = 2; + bytes payLoad = 3; +} + +/* id = 12 */ +message BroadcastMessageRsp { + repeated uint64 failedUids = 1; +} + +/* id = 13 */ +message BizMessage { + uint64 uid = 1; + uint32 msgType = 2; + string payLoad = 3; +} + +/* id = 14 */ +message BizMessageRsp { + uint32 status = 1; +} + +service Router { + rpc route(RouteMessage) returns (RouteMessageRsp) {} + rpc kickUser(KickMessage) returns (KickMessageRsp) {} +} + +service User { + rpc login(LoginMessage) returns (LoginMessageRsp) {} + rpc logout(LogoutMessage) returns (LogoutMessageRsp) {} + rpc multicast(MulticastMessage) returns (MulticastMessageRsp) {} + rpc broadcast(BroadcastMessage) returns (BroadcastMessageRsp) {} + rpc transmit(BizMessage) returns (BizMessageRsp) {} +} \ No newline at end of file diff --git a/protocol/userProxy.proto b/protocol/userProxy.proto new file mode 100644 index 0000000..2a5883b --- /dev/null +++ b/protocol/userProxy.proto @@ -0,0 +1,352 @@ +syntax = "proto3"; + +package userProxy; + +option go_package = "protocol/userProxy"; + +/* user*/ +message User { + uint64 id = 1; + string externalId = 2; + string nick = 3; + string avatar = 4; + string country = 5; + string countryIcon = 6; + uint64 birthday = 7; + bool isVip = 8; + bool isLike = 9; + bool isLikeMe = 10; +} + +/* Svip*/ +message Svip { + uint64 svipLevel = 1; + repeated SvipPrivilege privileges = 2; +} + +message SvipPrivilege { + int32 type = 1; + bool canSwitch = 2; + bool userSwitch = 3; + string mysteryCode = 4; +} + + +/* id = 1 登录*/ +message Login { + string token = 1; +} + +/* id = 2 登录的回应 */ +message LoginRsp { + uint32 status = 1; +} + +/* id = 3 客户端心跳 */ +message HeartBeat { + string externalUid = 1; +} + +/* id = 4 客户端心跳的回应 */ +message HeartBeatRsp { + uint32 status = 1; +} + +/* id = 7 客户端上行消息 */ +message BizRequest { + uint32 type = 1; + string payLoad = 2; +} + +/* id = 8 客户端上行消息的应答 */ +message BizResponse { + uint32 status = 1; +} + +/* id == 100 | 140 匹配结果通知 waitDuration:开始/下一个时间 matchUniqueId:匹配一对的唯一标识码, status:是否是落单 singleWaitTimeInSec:单方等待连接最长时间 dualWaitTimeInSec:双方连接中最长时间*/ +message MatchSuccess { + string localUserId = 1; + string remoteUserId = 2; + uint32 waitDuration = 3; + string matchUniqueId = 4; + bool status = 5; + uint32 singleWaitTimeInSec = 6; + uint32 dualWaitTimeInSec = 7; + User remoteUser = 8; +} + +/* id == 101 匹配后用户选择结果通知, failType: 只有status=2 才有值,其它为0,failType=1:等待时间到了,拒绝 failType=2:主动拒绝 */ +message MatchConfirm { + uint32 status = 1; + string channelId = 2; + string token = 3; + string localUserId = 4; + string remoteUserId = 5; + uint32 remoteAgoraId = 6; + uint32 callDuration = 7; + uint32 localAgoraId = 8; + uint32 diamondBalance = 9; + string matchUniqueId = 10; + uint32 failType = 11; +} + +/* id == 102 视频通话准备 */ +message CallReady { + uint64 startTimestamp = 1; + uint64 endTimestamp = 2; + uint64 callDuration = 3; + string channelId = 4; + uint64 remainDiamond = 5; +} + +/* id == 103 礼物加时 */ +message AddTimeGift { + uint32 giftId = 1; + string token = 2; + uint32 duration = 3; + uint64 endTimestamp = 4; + string channelId = 5; + bool isSender = 6; + uint32 giftNum = 7; + string iconUrl = 8; + string svgaUrl = 9; + string senderAvatar = 10; + string receiverAvatar = 11; +} + +/* id == 104 免费加时 */ +message AddTimeFree { + string token = 1; + uint32 duration = 2; + uint64 endTimestamp = 3; + string channelId = 4; + uint32 senderAgoraId = 5; +} + +/* id == 105 退出 */ +message ConnectsQuit { + uint64 from_user_id = 1; +} + +/* id == 106 连接状态 */ +message ConnectStatus { + uint64 from_user_id = 1; + float user_diamonds = 2; + bool diamonds_enough = 3; +} + +/* id == 107 ??? */ +message ConnectsCall { + uint64 from_user_id = 1; + string rong_room_name = 2; + bool is_join = 3; +} + +/* id == 108 */ +message ConnectCommon { + string rong_room_name = 1; + uint64 from_user_id = 2; + string extra = 3; + string message = 4; +} + +/* id == 109 召回授权弹框 */ +message RecallWindow { +} + +/* id == 110 | 132 视频发送 status:(1:接收到邀请, 2:接收到对方同意, 3:双方拒绝(还没接通), 4:对方挂断(接通后)diamondBalance 只有status=2,才出现)*/ +message Video { + string videoUniqueId = 1; + string channelId = 2; + uint32 localAgoraId = 3; + uint32 remoteAgoraId = 4; + string agoraToken = 5; + string sendUserId = 6; + string receiveUserId = 7; + uint32 status = 8; + uint32 diamondBalance = 9; + User sendUser = 10; +} + +/* id == 111 视频通话准备 */ +message VideoCallReady { + uint64 startTimestamp = 1; + uint64 endTimestamp = 2; + uint64 callDuration = 3; + string channelId = 4; + uint64 remainDiamond = 5; +} + +/* id == 112 互相喜欢 */ +message LikeEach { + string remoteUserId = 1; +} + +/* id == 113 喜欢我 */ +message LikeMe { + string remoteUserId = 1; + string remoteNick = 2; + string channelId = 3; +} + +/* id == 114 日常进入app,获取钻石 */ +message DailyInAppDiamond { + uint32 diamondNum = 1; +} + +/* id == 115 横幅 */ +message GlobalGiftBanner { + uint32 bannerLevel = 1; + uint64 giftId = 2; + uint32 giftNum = 3; + string sendUserId = 4; + string receiveUserId = 5; + string groupId = 6; + string sendUserCode = 7; + string sendUserAvatar = 8; + string sendUserNick = 9; + string receiveUserNick = 10; + string giftPicUrl = 11; + Svip svip = 12; + Svip receiveSvip = 13; +} + +/* id == 116 横幅的回应,用来测量RTT */ +message GlobalGiftBannerRsp { + uint32 bannerLevel = 1; + uint64 giftId = 2; + uint32 giftNum = 3; + string sendUserId = 4; + string receiveUserId = 5; + string groupId = 6; +} + +/*id==117 幸运转盘通知,客户端重新拉取查询, type:客户端不用理*/ +message LuckyWheel { + string groupId = 1; + uint32 type = 2; +} + +/* id == 118 幸运转盘获胜者全服广播 */ +message LuckyWheelBanner { + uint32 diamondNum = 1; + string sendUserId = 2; + string groupId = 3; + string nick = 4; + string code = 5; + string avatar = 6; + Svip svip = 7; +} + +/* id == 119 幸运转盘钻石变化 */ +message LuckyWheelDiamondChange { + string groupId = 1; +} + +/* id == 120 服务器配置变更 */ +message ConfigChange { + uint32 type = 1; +} + +/* id == 121 全局火箭横幅 */ +message GlobalRocketNotice { + string groupId = 1; + string period = 2; + uint32 round = 3; + uint32 stage = 4; + string topUserIcon = 5; + string nick = 6; + string code = 7; + string avatar = 8; + Svip svip = 9; +} + +/* id == 122 群发功能弹窗 */ +message GroupSendNotice { + string senderExtId = 1; + string senderCode = 2; + uint32 senderSex = 3; + string senderAvatar = 4; + string text = 5; + string groupName = 6; + string groupCode = 7; + string groupAvatar = 8; + uint32 userInNum = 9; // 最近进入房间的人数 + string groupId = 10; +} + +/* id == 123 全球消息 */ +message GlobalBroadcast { + string senderExtId = 1; + string senderCode = 2; + uint32 senderSex = 3; + string senderAvatar = 4; + string senderNick = 5; + string msg = 6; + string groupId = 7; + uint32 senderNobleLevel = 8; +} + +/* id == 124 全球消息 */ +message MicTaskFinish { + string userId = 1; + uint32 diamond = 2; +} + +/* id == 125 水果机开奖通知 */ +message FruitMachine { + string date = 1; + uint32 round = 2; +} + +/* id == 126 贵族变化 */ +message NobleChange { +} + +/* id == 127 加入群组成功 */ +message JoinGroup { + string groupId = 1; + string externalId = 2; +} + +/* id == 128 1对1视频1分钟加时成功 */ +message VideoTimeMinuteSuccess { + string token = 1; + uint32 duration = 2; + uint64 endTimestamp = 3; + string channelId = 4; + uint32 senderAgoraId = 5; + string videoUniqueId = 6; + bool isSend = 7; + uint32 sendRemainDiamond = 8; +} + +/* id == 129 1对1视频1分钟加时询问检查 */ +message VideoTimeMinuteCheck { + string videoUniqueId = 1; + uint32 diamond = 2; + string uuid = 3; +} + +/* id == 130 1对1视频,错过 */ +message VideoMiss { + uint32 totalNum = 1; +} + +/* id == 131 进房,群组活动信息 */ +message GroupActivity { + string ActivityId = 1;// id + uint64 StartAt = 2; // 开始时间戳,东八区时间戳 + uint64 EndAt = 3; // 结束时间戳,东八区时间戳 + string Banner = 4; // banner url + int32 AcType = 5; // 类型1.游戏2.比赛3.排队4.诗歌 + string Theme = 6; // 活动主题 + int32 PersonNum = 7; // 订阅人数 + bool IsSubscribe = 8; // 我是否订阅该活动 + string GroupId = 9; // 群id +} + +/* id == 144 邀请用户成为房间会员 */ +message RoomInviteMember { + string group_id = 1; +} \ No newline at end of file diff --git a/protocol/video.proto b/protocol/video.proto new file mode 100644 index 0000000..a0f7ed0 --- /dev/null +++ b/protocol/video.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; +package video; + +option go_package = "protocol/video"; + +/* id = 1 视频加时 */ +message VideoMinuteConfirm { + string videoUid = 1; + string externalId = 2; +} + +/* id = 2 视频加时的应答 */ +message VideoMinuteConfirmRsp { + uint32 status = 1; +} + diff --git a/rpc/logRpc.go b/rpc/logRpc.go new file mode 100644 index 0000000..7b77812 --- /dev/null +++ b/rpc/logRpc.go @@ -0,0 +1,73 @@ +package rpc + +import ( + "encoding/json" + "fmt" + "git.hilo.cn/hilo-common/mylogrus" + "git.hilo.cn/hilo-common/resource/mysql" + "strconv" + "time" +) + +type TypeRpc uint8 + +const ( +//MatchConfirm TypeRpc = 101 +//CallReady TypeRpc = 102 +//AddTimeGift TypeRpc = 103 +//AddTimeFree TypeRpc = 104 +//RecallWindow TypeRpc = 109 +//Video TypeRpc = 110 +//VideoCallReady TypeRpc = 111 +) + +type RpcLog struct { + ID uint64 `gorm:"primary_key"` + Type TypeRpc + UserId string + Msg string + Err string + FailUids string +} + +func (RpcLog) TableName() string { + month := time.Now().Format("200601") + return fmt.Sprintf("rpc_log_%s", month) +} + +func AddRpcLog(t TypeRpc, userId uint64, msg string, failUids []uint64, err error) { + errStr := "" + if err != nil { + errStr = err.Error() + } + failUidStr, _ := json.Marshal(failUids) + logRpc := RpcLog{ + Type: t, + UserId: strconv.FormatUint(userId, 10), + Msg: msg, + Err: errStr, + FailUids: string(failUidStr[:]), + } + if e := mysql.Db.Table(RpcLog{}.TableName()).Create(&logRpc).Error; e != nil { + mylogrus.MyLog.Errorf("log rpc save fail, err:%v", e) + } +} + +func AddRpcLogs(t TypeRpc, userIds []uint64, msg string, failUids []uint64, err error) { + errStr := "" + if err != nil { + errStr = err.Error() + } + failUidStr, _ := json.Marshal(failUids) + userIdStr, _ := json.Marshal(userIds) + logRpc := RpcLog{ + Type: t, + UserId: string(userIdStr[:]), + Msg: msg, + Err: errStr, + FailUids: string(failUidStr[:]), + } + if e := mysql.Db.Table(RpcLog{}.TableName()).Create(&logRpc).Error; e != nil { + mylogrus.MyLog.Errorf("log rpc save fail, err:%v", e) + } +} diff --git a/rpc/user_center.go b/rpc/user_center.go new file mode 100644 index 0000000..47d9921 --- /dev/null +++ b/rpc/user_center.go @@ -0,0 +1,186 @@ +package rpc + +import ( + "context" + "fmt" + "git.hilo.cn/hilo-common/mylogrus" + "git.hilo.cn/hilo-common/protocol/userCenter" + "git.hilo.cn/hilo-common/resource/config" + "git.hilo.cn/hilo-common/resource/consul" + consulapi "github.com/hashicorp/consul/api" + "google.golang.org/grpc" + "google.golang.org/grpc/keepalive" + "google.golang.org/grpc/resolver" + "time" +) + +const ( + Port = 50060 +) + +var userClient userCenter.UserClient +var kacp = keepalive.ClientParameters{ + Time: 10 * time.Second, // send pings every 10 seconds if there is no activity + Timeout: time.Second, // wait 1 second for ping ack before considering the connection dead + PermitWithoutStream: true, // send pings even without active streams +} + +var ( + defaultUserCenterAddr = "127.0.0.1:50040" // userCenter default addr + userCenterAddr = defaultUserCenterAddr + userCenterConsulName = "userCenter" +) + +// grpc服务发现 +type Builder struct { + addrs map[string][]string + + cc resolver.ClientConn +} + +func (b *Builder) Scheme() string { + return "uc" // userCenter +} + +type Resolver struct { +} + +func (r Resolver) ResolveNow(options resolver.ResolveNowOptions) {} + +func (r Resolver) Close() {} + +func (b *Builder) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOptions) (resolver.Resolver, error) { + r := &Resolver{} + paths := b.addrs[target.URL.Path] + addrs := make([]resolver.Address, len(paths)) + for i, s := range paths { + addrs[i] = resolver.Address{Addr: s} + } + cc.UpdateState(resolver.State{Addresses: addrs}) + b.cc = cc + return r, nil +} + +func (b *Builder) UpdateState(addrs []string) { + as := make([]resolver.Address, len(addrs)) + for i, s := range addrs { + as[i] = resolver.Address{Addr: s} + } + b.cc.UpdateState(resolver.State{Addresses: as}) +} + +func init() { + client, err := consulapi.NewClient(consulapi.DefaultConfig()) //非默认情况下需要设置实际的参数 + mylogrus.MyLog.Infoln(client, err) + if err != nil { + mylogrus.MyLog.Fatalln(err) + } + if client == nil { + mylogrus.MyLog.Fatalln("Fail to get consul client.") + } + // 本地环境下不需要userCenter + if config.AppIsLocal() { + mylogrus.MyLog.Infoln("userCenter is not required in local env.") + return + } + // 服务发现 + bd := &Builder{addrs: map[string][]string{"/api": {userCenterAddr}}} + cataLog := client.Catalog() + if cataLog == nil { + mylogrus.MyLog.Fatalln("No catalog.") + } + services, _, err := cataLog.Service("userCenter", "", nil) + if err != nil { + mylogrus.MyLog.Fatalln(err) + } + if len(services) == 0 { + mylogrus.MyLog.Fatalln("userCenter not found.") + } + var addrs []string + for _, s := range services { + addrs = append(addrs, fmt.Sprintf("%s:%d", s.ServiceAddress, s.ServicePort)) + } + if len(addrs) > 0 { + bd = &Builder{addrs: map[string][]string{"/api": addrs}} + userCenterAddr = "uc:///api" + } + mylogrus.MyLog.Infof("userCenterAddr:%v,addr:%v", userCenterAddr, addrs) + resolver.Register(bd) + go func() { + address := consulapi.DefaultConfig().Address // 用consul api的default config + if err := consul.RegisterWatcher("services", nil, address, func(serviceStatus map[string]map[string][]string) { + if statusAddrs, ok := serviceStatus[userCenterConsulName]; ok { + healthAddrs, _ := statusAddrs[consulapi.HealthPassing] + l := len(healthAddrs) + if l > 0 { + mylogrus.MyLog.Infof("consul service update state:%v-%v", userCenterConsulName, healthAddrs) + bd.UpdateState(healthAddrs) // 更新新的注册名 + } else { + mylogrus.MyLog.Warnf("consul service update local state:%v-%v", userCenterConsulName, defaultUserCenterAddr) + bd.UpdateState([]string{defaultUserCenterAddr}) // 都没有健康的,使用默认本地回环的 + } + for status := range statusAddrs { + if status == consulapi.HealthPassing { + continue + } + mylogrus.MyLog.Warnf("consul service wrong state:%v-%v-%v", userCenterConsulName, status, statusAddrs[status]) + } + } + }); err != nil { + mylogrus.MyLog.Errorf("启动 consul 的watch监控失败") + } + }() + + //userCenterAddr := services[0].Address + ":" + strconv.Itoa(services[0].ServicePort) + //mylogrus.MyLog.Printf("Choose userCenter %s, %s, weights: %v\n", services[0].ID, userCenterAddr, services[0].ServiceWeights) + + // Set up a connection to the userCenter. + conn, err := grpc.Dial(userCenterAddr, grpc.WithInsecure(), grpc.WithBlock(), grpc.WithKeepaliveParams(kacp), + grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"LoadBalancingPolicy":"%s"}`, "round_robin"))) + if err != nil { + mylogrus.MyLog.Fatalf("did not connect: %v", err) + } + //defer conn.Close() + userClient = userCenter.NewUserClient(conn) + if userClient == nil { + mylogrus.MyLog.Fatalln("userClient null") + } +} + +func multicast(uids []uint64, msgType uint32, data []byte) ([]uint64, error) { + ctx, cancel := context.WithTimeout(context.Background(), time.Second*3) + defer cancel() + rsp, err := userClient.Multicast(ctx, &userCenter.MulticastMessage{ + Uids: uids, + MsgType: msgType, + PayLoad: data, + }) + if err != nil { + mylogrus.MyLog.Errorf("Multicast message failed %s", err.Error()) + } + if rsp != nil { + mylogrus.MyLog.Infof("Multicast message res:%+v", rsp) + return rsp.FailedUids, err + } else { + return []uint64{}, err + } +} + +//广播 +func broadcast(msgType uint32, data []byte) ([]uint64, error) { + ctx, cancel := context.WithTimeout(context.Background(), time.Second*3) + defer cancel() + rsp, err := userClient.Broadcast(ctx, &userCenter.BroadcastMessage{ + MsgType: msgType, + PayLoad: data, + }) + if err != nil { + mylogrus.MyLog.Errorf("broadcast message failed %s", err.Error()) + } + if rsp != nil { + mylogrus.MyLog.Infof("broadcast message res:%v", rsp) + return rsp.FailedUids, err + } else { + return []uint64{}, err + } +} diff --git a/rpc/user_center_coder.go b/rpc/user_center_coder.go new file mode 100644 index 0000000..5a66b28 --- /dev/null +++ b/rpc/user_center_coder.go @@ -0,0 +1,119 @@ +package rpc + +import ( + "encoding/binary" + "errors" + "fmt" + "hash/crc32" + "time" +) + +const ( + MsgTypeLogin = 1 + iota + MsgTypeLoginRsp + MsgTypeHeartBeat + MsgTypeHeartBeatRsp + MsgTypeKickUser + MsgTypeBiz = 7 + MsgTypeBizRsp +) + +const ( + MsgTypeMatchSuccess = 100 + iota + MsgTypeMatchConfirm + MsgTypeCallReady + MsgTypeAddTimeGift + MsgTypeAddTimeFree +) + +const ( + MsgTypeRecallWindow = 109 + MsgTypeVideo = 110 // 1v1视频-v1-黄钻 + MsgTypeVideoCallReady = 111 + MsgTypeLikeEach = 112 + MsgTypeLikeMe = 113 + MsgTypeDailyInAppDiamond = 114 + MsgTypeGlobalGiftBanner = 115 + MsgTypeGlobalGiftBannerRsp = 116 + MsgTypeLuckyWheel = 117 //已丢弃 + MsgTypeLuckyWheelBanner = 118 + MsgTypeDiamondChange = 119 // Kludge:事实上是通用的钻石变更通知了 + MsgTypeConfigChange = 120 // 配置变更通知 + MsgTypeGlobalRocketNotice = 121 // 火箭全局横幅 + MsgTypeGroupChatNotice = 122 // 群发消息弹窗 + MsgTypeGlobalBroadcast = 123 // 群发消息弹窗 + MsgMicTaskFinish = 124 //麦上任务完成 + MsgFruitMachine = 125 // 水果机开奖 + MsgTypeNobleChange = 126 // 贵族变更 + MsgTypeJoinGroup = 127 // 加入群组成功 + MsgTypeVideoTimeMinuteSuccess = 128 //1对1视频加时成功 + MsgTypeVideoTimeMinuteCheck = 129 // 1对1视频加时检查 + MsgTypeVideoMiss = 130 //1对1视频错过 + MsgTypeRoomGroupActivity = 131 //进房,群组活动推送 + MsgTypeVideoV2 = 132 // 1v1视频-v2-粉钻 + MsgTypeVideoV2TimeMinuteCheck = 133 // 1v1视频-v2-加时检查 + MsgTypeVideoV2CallReady = 134 // 1v1视频-v2-callReady + MsgTypeVideoV2TimeMinuteSuccess = 135 // 1v1视频-v2-加时成功 + MsgTypeMatchV2Success = 140 // 匹配-v2-成功 + MsgTypeMatchV2Confirm = 141 // 匹配-v2-确认 + MsgTypeMatchV2CallReady = 142 // 匹配-v2-callReady + MsgTypeMatchV2AddTimeGift = 143 // 匹配-v2-送礼加时长 +) + +const ( + RoomBannerChange = 1 // 房间banner变更 + GiftConfigChange = 2 // 礼物配置变更 + OpenScreenChange = 3 // 开屏配置变更 + MatchConfigChange = 4 // 匹配配置发生了变化 +) + +func EncodeMessage(msgType uint32, serialNum uint64, userdata []byte) []byte { + msg := make([]byte, 26) + dataLen := len(userdata) + binary.BigEndian.PutUint16(msg, 1) + binary.BigEndian.PutUint32(msg[2:], msgType) + binary.BigEndian.PutUint64(msg[6:], serialNum) + binary.BigEndian.PutUint64(msg[14:], uint64(time.Now().UnixNano()/1000)) + binary.BigEndian.PutUint32(msg[22:], uint32(dataLen)) + + msg = append(msg, userdata...) + + checkSum := crc32.ChecksumIEEE(msg) + msg = append(msg, 0, 0, 0, 0) + binary.BigEndian.PutUint32(msg[26+dataLen:], checkSum) + return msg +} + +func DecodeMessage(message []byte) (uint32, uint64, uint64, []byte, error) { + length := len(message) + + // 保证消息至少有26bytes + if length >= 26 { + //version := binary.BigEndian.Uint16(message[0:2]) + msgType := binary.BigEndian.Uint32(message[2:6]) + msgId := binary.BigEndian.Uint64(message[6:14]) + timeStamp := binary.BigEndian.Uint64(message[14:22]) + dataLen := binary.BigEndian.Uint32(message[22:26]) + //log.Printf("DecodeMessage version = %d, msgType = %d, msgId = %d, timeStamp = %d, dataLen = %d\n", version, msgType, msgId, timeStamp, dataLen) + + // 保证ws消息至少有msgLen长 + if uint32(length) >= dataLen+30 { + pbData := message[26 : dataLen+26] + checksum := binary.BigEndian.Uint32(message[dataLen+26 : dataLen+30]) + + //fmt.Printf("pbData size = %d, checksum = %d\n", len(pbData), checksum) + myCheckSum := crc32.ChecksumIEEE(message[0 : dataLen+26]) + if checksum != myCheckSum { + return 0, msgId, timeStamp, nil, errors.New("checksum error") + } + + return msgType, msgId, timeStamp, pbData, nil + } else { + fmt.Printf("payload too short length = %d, msgType = %d\n", length, msgType) + return 0, msgId, timeStamp, nil, errors.New("payload too short") + } + } else { + fmt.Printf("message too short for header %d\n ", length) + return 0, 0, 0, nil, errors.New("message too short") + } +} diff --git a/rpc/user_center_func.go b/rpc/user_center_func.go new file mode 100644 index 0000000..67f228c --- /dev/null +++ b/rpc/user_center_func.go @@ -0,0 +1,67 @@ +package rpc + +import ( + "encoding/json" + "git.hilo.cn/hilo-common/mylogrus" + "git.hilo.cn/hilo-common/protocol/userProxy" + "google.golang.org/protobuf/proto" +) + +func SendFruitMachine(date string, round uint32) error { + msg := &userProxy.FruitMachine{ + Date: date, + Round: round, + } + if buffer, err := proto.Marshal(msg); err == nil { + rspUids, err := broadcast(MsgFruitMachine, buffer) + + //记录socket,注意闭包问题 + go func(userId uint64, msg *userProxy.FruitMachine, rspUids []uint64, err error) { + buf, _ := json.Marshal(msg) + AddRpcLog(MsgFruitMachine, userId, string(buf[:]), rspUids, err) + }(0, msg, rspUids, err) + + if err != nil { + mylogrus.MyLog.Errorf("grpc SendFruitMachine send fail") + return err + } else { + mylogrus.MyLog.Info("grpc SendFruitMachine send success") + } + } else { + return err + } + return nil +} + +func SendGlobalRocketNotice(groupId string, period string, round uint32, stage uint32, fromUserId uint64, topUserIcon string, nick string, code string, avatar string) error { + msg := &userProxy.GlobalRocketNotice{ + GroupId: groupId, + Period: period, + Round: round, + Stage: stage, + TopUserIcon: topUserIcon, + Nick: nick, + Code: code, + Avatar: avatar, + } + + if buffer, err := proto.Marshal(msg); err == nil { + rspUids, err := broadcast(MsgTypeGlobalRocketNotice, buffer) + + //记录socket,注意闭包问题 + go func(userId uint64, msg *userProxy.GlobalRocketNotice, rspUids []uint64, err error) { + buf, _ := json.Marshal(msg) + AddRpcLog(MsgTypeGlobalRocketNotice, userId, string(buf[:]), rspUids, err) + }(fromUserId, msg, rspUids, err) + + if err != nil { + mylogrus.MyLog.Errorf("grpc GlobalRocketNotice send fail") + return err + } else { + mylogrus.MyLog.Info("grpc GlobalRocketNotice send success") + } + } else { + return err + } + return nil +} -- 2.22.0