From c03ba65bf6af882fc402f680bbf7ff07bdcdba95 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Wed, 10 Aug 2022 13:38:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E8=AE=BA=E5=9D=9B=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/json/game_msgdistrib.json | 23 +- cmd/bench/main_test.go | 2 +- go.mod | 7 +- go.sum | 30 +-- lego/sys/redis/pipe/list.go | 15 +- lego/sys/rpcx/client.go | 2 +- modules/chat/modelChat.go | 8 +- modules/forum/api_getlist.go | 2 +- modules/forum/api_watchhero.go | 32 +++ modules/forum/modelForum.go | 84 ++++++- modules/forum/module.go | 2 +- modules/gateway/agent.go | 18 +- modules/gateway/configure_comp.go | 16 +- modules/gateway/core.go | 3 +- modules/gateway/module.go | 9 +- pb/forum_db.pb.go | 53 +++-- pb/forum_msg.pb.go | 225 ++++++++++++++++--- services/worker/main.go | 2 + sys/configure/structs/game.msgDistrib.go | 2 +- sys/configure/structs/game.msgDistribData.go | 8 +- sys/db/dbconn.go | 6 +- 21 files changed, 422 insertions(+), 127 deletions(-) create mode 100644 modules/forum/api_watchhero.go diff --git a/bin/json/game_msgdistrib.json b/bin/json/game_msgdistrib.json index 0637a088a..c9236b4f3 100644 --- a/bin/json/game_msgdistrib.json +++ b/bin/json/game_msgdistrib.json @@ -1 +1,22 @@ -[] \ No newline at end of file +[ + { + "msgid": "notify.getlist", + "routrules": "~/worker", + "describe": "公告获取接口" + }, + { + "msgid": "forum.getlist", + "routrules": "~/worker", + "describe": "论坛评论获取接口" + }, + { + "msgid": "forum.releasecomment", + "routrules": "~/worker", + "describe": "论坛发布评论接口" + }, + { + "msgid": "forum.watchhero", + "routrules": "~/worker", + "describe": "论坛查看目标英雄接口" + } +] \ No newline at end of file diff --git a/cmd/bench/main_test.go b/cmd/bench/main_test.go index 183953c72..8d5049ea6 100644 --- a/cmd/bench/main_test.go +++ b/cmd/bench/main_test.go @@ -28,7 +28,7 @@ var res string func TestMain(m *testing.M) { if err := cache.OnInit(nil, cache.Set_Redis_Addr([]string{ // "10.0.0.9:6986", - "10.0.0.9:9001","10.0.0.9:9002","10.0.0.9:9003","10.0.0.9:9004","10.0.0.9:9005","10.0.0.9:9006", + "10.0.0.9:9001", "10.0.0.9:9002", "10.0.0.9:9003", "10.0.0.9:9004", "10.0.0.9:9005", "10.0.0.9:9006", }), cache.Set_Redis_Password(""), // cache.Set_Redis_Password("li13451234"), diff --git a/go.mod b/go.mod index da5d9d650..8aed86c5d 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/gorilla/websocket v1.4.2 github.com/json-iterator/go v1.1.12 github.com/modern-go/reflect2 v1.0.2 - github.com/nacos-group/nacos-sdk-go v1.0.8 + github.com/nacos-group/nacos-sdk-go v1.1.2 github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 github.com/robfig/cron/v3 v3.0.1 github.com/rs/xid v1.3.0 @@ -101,8 +101,6 @@ require ( github.com/klauspost/cpuid/v2 v2.0.12 // indirect github.com/klauspost/reedsolomon v1.9.16 // indirect github.com/leodido/go-urn v1.2.1 // indirect - github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f // indirect - github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042 // indirect github.com/lucas-clemente/quic-go v0.27.0 // indirect github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect github.com/magiconair/properties v1.8.5 // indirect @@ -158,7 +156,7 @@ require ( go.opentelemetry.io/otel v1.6.3 // indirect go.opentelemetry.io/otel/trace v1.6.3 // indirect go.uber.org/atomic v1.7.0 // indirect - go.uber.org/zap v1.21.0 // indirect + go.uber.org/zap v1.17.0 // indirect golang.org/x/crypto v0.0.0-20220408190544-5352b0902921 // indirect golang.org/x/image v0.0.0-20220601225756-64ec528b34cd // indirect golang.org/x/mobile v0.0.0-20211207041440-4e6c2922fdee // indirect @@ -169,6 +167,7 @@ require ( golang.org/x/tools v0.1.10 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect gopkg.in/ini.v1 v1.62.0 // indirect + gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect honnef.co/go/js/dom v0.0.0-20210725211120-f030747120f2 // indirect diff --git a/go.sum b/go.sum index 2929bfcaa..1ef8d27b6 100644 --- a/go.sum +++ b/go.sum @@ -51,6 +51,7 @@ git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGy github.com/BabySid/gobase v0.0.0-20220614103908-39ac0a583c02 h1:4VkwDX+9araWz3MeAx/3EAWuQTu+dYnJqBlYrk86i4k= github.com/BabySid/gobase v0.0.0-20220614103908-39ac0a583c02/go.mod h1:psRlcjEywZdxNf9jp6IdYY7VcAsYPtcnLHYQ+dWG5uw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/toml v1.1.0 h1:ksErzDEI1khOiGPgpwuI7x2ebx/uXQNw7xJpn9Eq1+I= github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/ChimeraCoder/gojson v1.1.0/go.mod h1:nYbTQlu6hv8PETM15J927yM0zGj3njIldp72UT1MqSw= @@ -86,8 +87,6 @@ github.com/aws/aws-sdk-go v1.34.28 h1:sscPpn/Ns3i0F4HPEWAVcwdIRaZZCuL7llJ2/60yPI github.com/aws/aws-sdk-go v1.34.28/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48= github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 h1:OYA+5W64v3OgClL+IrOD63t4i/RW7RqrAVl9LTZ9UqQ= github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394/go.mod h1:Q8n74mJTIgjX4RBBcHnJ05h//6/k6foqmgE45jTQtxg= -github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= @@ -95,6 +94,7 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM= github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= +github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= github.com/cenk/backoff v2.2.1+incompatible h1:djdFT7f4gF2ttuzRKPbMOWgZajgesItGLwG5FTQKmmE= github.com/cenk/backoff v2.2.1+incompatible/go.mod h1:7FtoeaSnHoZnmZzz47cM35Y9nSW7tNyaidugnHTaFDE= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= @@ -142,8 +142,6 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.m github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a h1:yDWHCSQ40h88yih2JAcL6Ls/kVkSE8GFACTGVnMPruw= github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a/go.mod h1:7Ga40egUymuWXxAe151lTNnCv97MddSOVsjpPPkityA= -github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 h1:Ghm4eQYC0nEPnSJdVkTrXpu9KtoVCSo1hg7mtI7G9KU= -github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239/go.mod h1:Gdwt2ce0yfBxPvZrHkprdPPTTS3N5rwmLE8T22KBXlw= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= @@ -404,8 +402,6 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt github.com/influxdata/influxdb1-client v0.0.0-20220302092344-a9ab5670611c h1:qSHzRbhzK8RdXOsAdfDgO49TtqC1oZ+acxPrkfTxcCs= github.com/influxdata/influxdb1-client v0.0.0-20220302092344-a9ab5670611c/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/jackmordaunt/icns/v2 v2.2.1/go.mod h1:6aYIB9eSzyfHHMKqDf17Xrs1zetQPReAkiUSHzdw4cI= -github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 h1:IPJ3dvxmJ4uczJe5YQdrYB16oTJlGSC/OyZDqUk9xX4= -github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869/go.mod h1:cJ6Cj7dQo+O6GJNiMx+Pa94qKj+TG8ONdKHgMNIyyag= github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= @@ -413,8 +409,6 @@ github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHW github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= -github.com/jonboulle/clockwork v0.1.0 h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo= -github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/josephspurrier/goversioninfo v1.4.0/go.mod h1:JWzv5rKQr+MmW+LvM412ToT/IkYDZjaclF2pKDss8IY= github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= @@ -463,12 +457,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= -github.com/lestrrat/go-envload v0.0.0-20180220120943-6ed08b54a570 h1:0iQektZGS248WXmGIYOwRXSQhD4qn3icjMpuxwO7qlo= -github.com/lestrrat/go-envload v0.0.0-20180220120943-6ed08b54a570/go.mod h1:BLt8L9ld7wVsvEWQbuLrUZnCMnUmLZ+CGDzKtclrTlE= -github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f h1:sgUSP4zdTUZYZgAGGtN5Lxk92rK+JUFOwf+FT99EEI4= -github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f/go.mod h1:UGmTpUd3rjbtfIpwAPrcfmGf/Z1HS95TATB+m57TPB8= -github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042 h1:Bvq8AziQ5jFF4BHGAEDSqwPW1NJS3XshxbRCxtjFAZc= -github.com/lestrrat/go-strftime v0.0.0-20180220042222-ba3bf9c1d042/go.mod h1:TPpsiPUEh0zFL1Snz4crhMlBe60PYxRHr5oFF3rRYg0= github.com/lucas-clemente/quic-go v0.24.0/go.mod h1:paZuzjXCE5mj6sikVLMvqXk8lJV2AsqtJ6bDhjEfxx0= github.com/lucas-clemente/quic-go v0.27.0 h1:v6WY87q9zD4dKASbG8hy/LpzAVNzEQzw8sEIeloJsc4= github.com/lucas-clemente/quic-go v0.27.0/go.mod h1:AzgQoPda7N+3IqMMMkywBKggIFo2KT6pfnlrQ2QieeI= @@ -539,8 +527,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/nacos-group/nacos-sdk-go v1.0.8 h1:8pEm05Cdav9sQgJSv5kyvlgfz0SzFUUGI3pWX6SiSnM= -github.com/nacos-group/nacos-sdk-go v1.0.8/go.mod h1:hlAPn3UdzlxIlSILAyOXKxjFSvDJ9oLzTJ9hLAK1KzA= +github.com/nacos-group/nacos-sdk-go v1.1.2 h1:lWTpf5SXLetQetS7p31eGic/ncqsnn0Zbau1i3eC25Y= +github.com/nacos-group/nacos-sdk-go v1.1.2/go.mod h1:I8Vj4M8ZLpBk7EY2A8RXQE1SbfCA7b56TJBPIFTrUYE= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= github.com/neelance/sourcemap v0.0.0-20200213170602-2833bce08e4c/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= @@ -716,8 +704,6 @@ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1F github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= -github.com/tebeka/strftime v0.1.3 h1:5HQXOqWKYRFfNyBMNVc9z5+QzuBtIXy03psIhtdJYto= -github.com/tebeka/strftime v0.1.3/go.mod h1:7wJm3dZlpr4l/oVK0t1HYIc4rMzQ2XJlOMIUJUJH6XQ= github.com/templexxx/cpufeat v0.0.0-20180724012125-cef66df7f161 h1:89CEmDvlq/F7SJEOqkIdNDGJXrQIhuIx9D2DBXjavSU= github.com/templexxx/cpufeat v0.0.0-20180724012125-cef66df7f161/go.mod h1:wM7WEvslTq+iOEAMDLSzhVuOt5BRZ05WirO+b09GHQU= github.com/templexxx/xor v0.0.0-20191217153810-f85b25db303b h1:fj5tQ8acgNUr6O8LEplsxDhUIe2573iLkJc+PqnzZTI= @@ -739,7 +725,6 @@ github.com/tklauser/go-sysconf v0.3.9 h1:JeUVdAOWhhxVcU6Eqr/ATFHgXk/mmiItdKeJPev github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs= github.com/tklauser/numcpus v0.3.0 h1:ILuRUQBtssgnxw0XXIjKUC56fgnOrFoQQ/4+DeU2biQ= github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8= -github.com/toolkits/concurrent v0.0.0-20150624120057-a4371d70e3e3/go.mod h1:QDlpd3qS71vYtakd2hmdpqhJ9nwv6mD6A30bQ1BPBFE= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= @@ -801,16 +786,13 @@ go.opentelemetry.io/otel/trace v1.6.3/go.mod h1:GNJQusJlUgZl9/TQBPKU/Y/ty+0iVB5f go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= -go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.15.0/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc= +go.uber.org/zap v1.17.0 h1:MTjgFu6ZLKvY6Pvaqk97GlxNBuMpV4Hy/3P6tRGlI2U= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= -go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8= -go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE= golang.org/x/build v0.0.0-20190111050920-041ab4dc3f9d/go.mod h1:OWs+y06UdEOHN4y+MfF/py+xQ/tYqIWW03b70/CG9Rw= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -1260,6 +1242,8 @@ gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU= gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= +gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/lego/sys/redis/pipe/list.go b/lego/sys/redis/pipe/list.go index f9d238675..9aedcc976 100644 --- a/lego/sys/redis/pipe/list.go +++ b/lego/sys/redis/pipe/list.go @@ -187,15 +187,14 @@ Redis Rpush 命令用于将一个或多个值插入到列表的尾部(最右边) 如果列表不存在,一个空列表会被创建并执行 RPUSH 操作。 当列表存在但不是列表类型时,返回一个错误。 注意:在 Redis 2.4 版本以前的 RPUSH 命令,都只接受单个 value 值 */ -func (this *RedisPipe) RPush(key string, values ...interface{}) (err error) { +func (this *RedisPipe) RPush(key string, values ...interface{}) *redis.IntCmd { agrs := make([]interface{}, 0) agrs = append(agrs, "RPUSH") for _, v := range values { result, _ := this.codec.Marshal(v) agrs = append(agrs, result) } - err = this.client.Do(this.ctx, agrs...).Err() - return + return this.client.RPush(this.ctx, key, agrs...) } /* @@ -203,14 +202,8 @@ Redis Rpush 命令用于将一个或多个值插入到列表的尾部(最右边) 如果列表不存在,一个空列表会被创建并执行 RPUSH 操作。 当列表存在但不是列表类型时,返回一个错误。 注意:在 Redis 2.4 版本以前的 RPUSH 命令,都只接受单个 value 值 */ -func (this *RedisPipe) RPushForStringSlice(key string, values ...string) (err error) { - agrs := make([]interface{}, 0) - agrs = append(agrs, "RPUSH") - for _, v := range values { - agrs = append(agrs, v) - } - err = this.client.Do(this.ctx, agrs...).Err() - return +func (this *RedisPipe) RPushForStringSlice(key string, values ...string) *redis.IntCmd { + return this.client.RPush(this.ctx, key, values) } /* diff --git a/lego/sys/rpcx/client.go b/lego/sys/rpcx/client.go index a01793bf4..6fad78324 100644 --- a/lego/sys/rpcx/client.go +++ b/lego/sys/rpcx/client.go @@ -312,7 +312,7 @@ func (this *Client) getclient(ctx *context.Context, clusterTag string, servicePa } if c, ok = clients[spath[0]]; !ok { - if d, err = client.NewConsulDiscovery(this.options.ServiceTag, spath[0], this.options.ConsulServers, nil); err != nil { + if d, err = client.NewConsulDiscovery(clusterTag, spath[0], this.options.ConsulServers, nil); err != nil { return } c = client.NewBidirectionalXClient(spath[0], client.Failfast, client.RandomSelect, d, client.DefaultOption, this.msgChan) diff --git a/modules/chat/modelChat.go b/modules/chat/modelChat.go index 2cd527602..0a945e51c 100644 --- a/modules/chat/modelChat.go +++ b/modules/chat/modelChat.go @@ -248,10 +248,10 @@ func (this *modelChatComp) addChatMsg(key string, count int64, msgs ...*pb.DBCha this.module.Errorf("err:%v", err) return } - if _, err = this.DB.InsertMany(core.SqlTable(this.TableName), values); err != nil { - this.module.Errorf("err:%v", err) - return - } + // if _, err = this.DB.InsertMany(core.SqlTable(this.TableName), values); err != nil { + // this.module.Errorf("err:%v", err) + // return + // } if len(outkey) > 0 { delkeys := make([]string, 0) for _, v := range outkey { diff --git a/modules/forum/api_getlist.go b/modules/forum/api_getlist.go index 190092f8b..da75b57f3 100644 --- a/modules/forum/api_getlist.go +++ b/modules/forum/api_getlist.go @@ -24,7 +24,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.ForumGetListReq) if code = this.GetListCheck(session, req); code != pb.ErrorCode_Success { return } - if list, err = this.module.modelForum.GetComment(req.Herocid); err != nil { + if list, err = this.module.modelForum.getComment(req.Herocid); err != nil { code = pb.ErrorCode_DBError return } diff --git a/modules/forum/api_watchhero.go b/modules/forum/api_watchhero.go new file mode 100644 index 000000000..0731fb6f2 --- /dev/null +++ b/modules/forum/api_watchhero.go @@ -0,0 +1,32 @@ +package forum + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/pb" + + "google.golang.org/protobuf/proto" +) + +//参数校验 +func (this *apiComp) WatchHeroCheck(session comm.IUserSession, req *pb.ForumWatchHeroReq) (code pb.ErrorCode) { + if req.Uid == "" || req.HerocId == "" || req.HerooId == "" { + code = pb.ErrorCode_ReqParameterError + } + return +} + +///获取本服聊天消息记录 +func (this *apiComp) WatchHero(session comm.IUserSession, req *pb.ForumWatchHeroReq) (code pb.ErrorCode, data proto.Message) { + var ( + hero *pb.DBHero + err error + ) + if code = this.WatchHeroCheck(session, req); code != pb.ErrorCode_Success { + return + } + if hero, err = this.module.modelForum.watchHero(req.Stag, req.Uid, req.HerocId); err != nil { + code = pb.ErrorCode_HeroNoExist + } + session.SendMsg(string(this.module.GetType()), "getlist", &pb.ForumWatchHeroResp{Hero: hero}) + return +} diff --git a/modules/forum/modelForum.go b/modules/forum/modelForum.go index 8643d3464..87f51206b 100644 --- a/modules/forum/modelForum.go +++ b/modules/forum/modelForum.go @@ -1,11 +1,16 @@ package forum import ( + "context" + "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/core" + "go_dreamfactory/lego/sys/redis" "go_dreamfactory/modules" "go_dreamfactory/pb" + "go_dreamfactory/sys/db" + "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/x/bsonx" ) @@ -30,15 +35,90 @@ func (this *modelForumComp) Init(service core.IService, module core.IModule, com } //查询用户未读消息 -func (this *modelForumComp) GetComment(herocId string) (result []*pb.DBComment, err error) { - +func (this *modelForumComp) getComment(herocId string) (result []*pb.DBComment, err error) { + var ( + key string + c *mongo.Cursor + n int + max_chat int32 + ) + result = make([]*pb.DBComment, 0) + key = fmt.Sprintf("%s:%s", this.TableName, herocId) + err = this.GetQueues(key, 10, &result) + if err == redis.RedisNil { + //query from mgo + if c, err = this.DB.Find(core.SqlTable(this.TableName), bson.M{"heroid": herocId}); err != nil { + return + } else { + result = make([]*pb.DBComment, c.RemainingBatchLength()) + for c.Next(context.Background()) { + chat := &pb.DBComment{} + if err = c.Decode(chat); err != nil { + this.module.Errorf("err:%v", err) + } + result[n] = chat + n++ + } + if len(result) > 0 { + this.addCommentChache(key, int64(max_chat), result...) + } + } + } return } ///发布评论 func (this *modelForumComp) releaseComment(comment *pb.DBComment) (err error) { + key := fmt.Sprintf("%s:%s", this.TableName, comment.Heroid) + if err = this.addCommentChache(key, 99, comment); err != nil { + this.module.Errorln(err) + return + } if _, err = this.DB.InsertOne(core.SqlTable(this.TableName), comment); err != nil { this.module.Errorln(err) + return + } + return +} + +//添加评论到缓存中 +func (this *modelForumComp) addCommentChache(key string, count int64, msgs ...*pb.DBComment) (err error) { + var ( + data map[string]*pb.DBComment = make(map[string]*pb.DBComment, len(msgs)) + ) + for _, v := range msgs { + data[fmt.Sprintf("%s-%s", key, v.Id)] = v + } + if _, err = this.AddQueues(key, count, data); err != nil { + this.module.Errorln(err) + return + } + return +} + +func (this *modelForumComp) watchHero(stage string, uid string, herocid string) (hero *pb.DBHero, err error) { + tcoon := db.ServerDBConn(stage) + var ( + c *mongo.Cursor + ) + if c, err = tcoon.Mgo.Find(comm.TableHero, bson.M{"uid": uid, "heroID": herocid}); err != nil { + return + } else { + n := 0 + result := make([]*pb.DBHero, c.RemainingBatchLength()) + for c.Next(context.Background()) { + hero := &pb.DBHero{} + if err = c.Decode(hero); err != nil { + this.module.Errorf("err:%v", err) + } + result[n] = hero + n++ + } + for _, v := range result { + if hero == nil || hero.Lv < v.Lv { + hero = v + } + } } return } diff --git a/modules/forum/module.go b/modules/forum/module.go index 7a94afc89..f4aa142b7 100644 --- a/modules/forum/module.go +++ b/modules/forum/module.go @@ -25,7 +25,7 @@ type Forum struct { //模块名 func (this *Forum) GetType() core.M_Modules { - return comm.ModuleEquipment + return comm.ModuleForum } //模块初始化接口 注册用户创建角色事件 diff --git a/modules/gateway/agent.go b/modules/gateway/agent.go index 7fdbc165c..2813b39a4 100644 --- a/modules/gateway/agent.go +++ b/modules/gateway/agent.go @@ -238,13 +238,23 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) (err error) { SubType: msg.SubType, Message: msg.Data, } - if rule, ok = this.gateway.GetMsgDistribute(msg.MainType, msg.SubType); ok { + msgid := strings.ToLower(fmt.Sprintf("%s.%s", msg.MainType, msg.SubType)) + if rule, ok = this.gateway.GetMsgDistribute(msgid); ok { paths := strings.Split(rule, "/") if len(paths) == 3 { - serviceTag = paths[0] + if paths[0] == "~" { + serviceTag = this.gateway.CrossServiceTag() + } else { + serviceTag = paths[0] + } servicePath = fmt.Sprintf("%s/%s", paths[1], paths[2]) - } else if len(paths) < 3 && len(paths) > 0 { - servicePath = rule + } else if len(paths) == 2 { + if paths[0] == "~" { + serviceTag = this.gateway.CrossServiceTag() + servicePath = paths[1] + } else { + servicePath = rule + } } else { this.gateway.Errorf("messageDistribution rule is empty!") return diff --git a/modules/gateway/configure_comp.go b/modules/gateway/configure_comp.go index 6980d61b8..1dddac24d 100644 --- a/modules/gateway/configure_comp.go +++ b/modules/gateway/configure_comp.go @@ -24,20 +24,18 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp } // GetMsgDistribute 获取消息分发规则读取配置表 -func (this *configureComp) GetMsgDistribute(mtype, stype string) (rule string, ok bool) { +func (this *configureComp) GetMsgDistribute(msgid string) (rule string, ok bool) { var ( - err error - v interface{} + err error + v interface{} + item *cfg.Game_msgdistribData ) if v, err = this.GetConfigure(game_msgdistrib); err != nil { + ok = false return } else { - for _, v := range v.(*cfg.Game_msgdistrib).GetDataMap() { - if v.Mtype == mtype && v.Stype == stype { - rule = v.Routrules - ok = true - return - } + if item, ok = v.(*cfg.Game_msgdistrib).GetDataMap()[msgid]; ok { + rule = item.Routrules } } return diff --git a/modules/gateway/core.go b/modules/gateway/core.go index 3605f84dd..48a77051c 100644 --- a/modules/gateway/core.go +++ b/modules/gateway/core.go @@ -25,8 +25,9 @@ type ( core.IModule log.Ilogf Service() base.IRPCXService + CrossServiceTag() string Connect(a IAgent) DisConnect(a IAgent) - GetMsgDistribute(mtype, stype string) (rule string, ok bool) + GetMsgDistribute(msgid string) (rule string, ok bool) } ) diff --git a/modules/gateway/module.go b/modules/gateway/module.go index 8011b8430..29e39ec4b 100644 --- a/modules/gateway/module.go +++ b/modules/gateway/module.go @@ -44,6 +44,11 @@ func (this *Gateway) Service() base.IRPCXService { return this.service } +//跨服集群标签 +func (this *Gateway) CrossServiceTag() string { + return this.options.SpanServiceTag +} + // Init 模块初始化函数 func (this *Gateway) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { err = this.ModuleBase.Init(service, module, options) @@ -97,8 +102,8 @@ func (this *Gateway) DisConnect(a IAgent) { } // GetMsgDistribute 读取消息分发规则 -func (this *Gateway) GetMsgDistribute(mtype, stype string) (rule string, ok bool) { - return this.configure.GetMsgDistribute(mtype, stype) +func (this *Gateway) GetMsgDistribute(msgid string) (rule string, ok bool) { + return this.configure.GetMsgDistribute(msgid) } //日志 diff --git a/pb/forum_db.pb.go b/pb/forum_db.pb.go index f83b77f39..247185a15 100644 --- a/pb/forum_db.pb.go +++ b/pb/forum_db.pb.go @@ -76,12 +76,13 @@ type DBComment struct { Heroid string `protobuf:"bytes,2,opt,name=heroid,proto3" json:"heroid"` //英雄id Heroobjid string `protobuf:"bytes,3,opt,name=heroobjid,proto3" json:"heroobjid"` //目标英雄的实例id Uid string `protobuf:"bytes,4,opt,name=uid,proto3" json:"uid"` //发送用户id - Avatar int32 `protobuf:"varint,5,opt,name=avatar,proto3" json:"avatar"` //用户头像 - Uname string `protobuf:"bytes,6,opt,name=uname,proto3" json:"uname"` //用户名 - State CommentState `protobuf:"varint,7,opt,name=state,proto3,enum=CommentState" json:"state"` //状态 - Ctime int64 `protobuf:"varint,8,opt,name=ctime,proto3" json:"ctime"` //发布时间 - Content string `protobuf:"bytes,9,opt,name=content,proto3" json:"content"` //内容 - Starlist int32 `protobuf:"varint,10,opt,name=starlist,proto3" json:"starlist"` //点赞数 + Stage string `protobuf:"bytes,5,opt,name=stage,proto3" json:"stage"` //区服id + Avatar int32 `protobuf:"varint,6,opt,name=avatar,proto3" json:"avatar"` //用户头像 + Uname string `protobuf:"bytes,7,opt,name=uname,proto3" json:"uname"` //用户名 + State CommentState `protobuf:"varint,8,opt,name=state,proto3,enum=CommentState" json:"state"` //状态 + Ctime int64 `protobuf:"varint,9,opt,name=ctime,proto3" json:"ctime"` //发布时间 + Content string `protobuf:"bytes,10,opt,name=content,proto3" json:"content"` //内容 + Starlist int32 `protobuf:"varint,11,opt,name=starlist,proto3" json:"starlist"` //点赞数 } func (x *DBComment) Reset() { @@ -144,6 +145,13 @@ func (x *DBComment) GetUid() string { return "" } +func (x *DBComment) GetStage() string { + if x != nil { + return x.Stage + } + return "" +} + func (x *DBComment) GetAvatar() int32 { if x != nil { return x.Avatar @@ -190,27 +198,28 @@ var File_forum_forum_db_proto protoreflect.FileDescriptor var file_forum_forum_db_proto_rawDesc = []byte{ 0x0a, 0x14, 0x66, 0x6f, 0x72, 0x75, 0x6d, 0x2f, 0x66, 0x6f, 0x72, 0x75, 0x6d, 0x5f, 0x64, 0x62, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x82, 0x02, 0x0a, 0x09, 0x44, 0x42, 0x43, 0x6f, 0x6d, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x98, 0x02, 0x0a, 0x09, 0x44, 0x42, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x68, 0x65, 0x72, 0x6f, 0x6f, 0x62, 0x6a, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x68, 0x65, 0x72, 0x6f, 0x6f, 0x62, 0x6a, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, - 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, - 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x61, 0x76, - 0x61, 0x74, 0x61, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x75, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x06, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x05, 0x75, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x05, 0x73, 0x74, - 0x61, 0x74, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0d, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, - 0x65, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, - 0x14, 0x0a, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, - 0x63, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, - 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, - 0x1a, 0x0a, 0x08, 0x73, 0x74, 0x61, 0x72, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x08, 0x73, 0x74, 0x61, 0x72, 0x6c, 0x69, 0x73, 0x74, 0x2a, 0x28, 0x0a, 0x0c, 0x43, - 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x52, - 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x4f, 0x66, 0x66, 0x6c, - 0x69, 0x6e, 0x65, 0x10, 0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, + 0x73, 0x74, 0x61, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x74, 0x61, + 0x67, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x75, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x75, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x23, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x0d, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, + 0x73, 0x74, 0x61, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x09, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, + 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, + 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x74, 0x61, 0x72, 0x6c, 0x69, 0x73, + 0x74, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x73, 0x74, 0x61, 0x72, 0x6c, 0x69, 0x73, + 0x74, 0x2a, 0x28, 0x0a, 0x0c, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, + 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x10, 0x00, 0x12, 0x0b, + 0x0a, 0x07, 0x4f, 0x66, 0x66, 0x6c, 0x69, 0x6e, 0x65, 0x10, 0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e, + 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pb/forum_msg.pb.go b/pb/forum_msg.pb.go index 5b761b1a2..ba6fe8ebc 100644 --- a/pb/forum_msg.pb.go +++ b/pb/forum_msg.pb.go @@ -244,33 +244,165 @@ func (x *ForumReleaseCommentResp) GetComment() *DBComment { return nil } +//查看英雄信息请求 +type ForumWatchHeroReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"` //用户id + Stag string `protobuf:"bytes,2,opt,name=stag,proto3" json:"stag"` //区服id + HerocId string `protobuf:"bytes,3,opt,name=herocId,proto3" json:"herocId"` //用户cid + HerooId string `protobuf:"bytes,4,opt,name=herooId,proto3" json:"herooId"` //英雄实例id +} + +func (x *ForumWatchHeroReq) Reset() { + *x = ForumWatchHeroReq{} + if protoimpl.UnsafeEnabled { + mi := &file_forum_forum_msg_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ForumWatchHeroReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ForumWatchHeroReq) ProtoMessage() {} + +func (x *ForumWatchHeroReq) ProtoReflect() protoreflect.Message { + mi := &file_forum_forum_msg_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ForumWatchHeroReq.ProtoReflect.Descriptor instead. +func (*ForumWatchHeroReq) Descriptor() ([]byte, []int) { + return file_forum_forum_msg_proto_rawDescGZIP(), []int{4} +} + +func (x *ForumWatchHeroReq) GetUid() string { + if x != nil { + return x.Uid + } + return "" +} + +func (x *ForumWatchHeroReq) GetStag() string { + if x != nil { + return x.Stag + } + return "" +} + +func (x *ForumWatchHeroReq) GetHerocId() string { + if x != nil { + return x.HerocId + } + return "" +} + +func (x *ForumWatchHeroReq) GetHerooId() string { + if x != nil { + return x.HerooId + } + return "" +} + +//查看英雄信息回应 +type ForumWatchHeroResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Hero *DBHero `protobuf:"bytes,1,opt,name=hero,proto3" json:"hero"` +} + +func (x *ForumWatchHeroResp) Reset() { + *x = ForumWatchHeroResp{} + if protoimpl.UnsafeEnabled { + mi := &file_forum_forum_msg_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ForumWatchHeroResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ForumWatchHeroResp) ProtoMessage() {} + +func (x *ForumWatchHeroResp) ProtoReflect() protoreflect.Message { + mi := &file_forum_forum_msg_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ForumWatchHeroResp.ProtoReflect.Descriptor instead. +func (*ForumWatchHeroResp) Descriptor() ([]byte, []int) { + return file_forum_forum_msg_proto_rawDescGZIP(), []int{5} +} + +func (x *ForumWatchHeroResp) GetHero() *DBHero { + if x != nil { + return x.Hero + } + return nil +} + var File_forum_forum_msg_proto protoreflect.FileDescriptor var file_forum_forum_msg_proto_rawDesc = []byte{ 0x0a, 0x15, 0x66, 0x6f, 0x72, 0x75, 0x6d, 0x2f, 0x66, 0x6f, 0x72, 0x75, 0x6d, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x66, 0x6f, 0x72, 0x75, 0x6d, 0x2f, 0x66, - 0x6f, 0x72, 0x75, 0x6d, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x2b, 0x0a, - 0x0f, 0x46, 0x6f, 0x72, 0x75, 0x6d, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, - 0x12, 0x18, 0x0a, 0x07, 0x68, 0x65, 0x72, 0x6f, 0x63, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x07, 0x68, 0x65, 0x72, 0x6f, 0x63, 0x69, 0x64, 0x22, 0x38, 0x0a, 0x10, 0x46, 0x6f, - 0x72, 0x75, 0x6d, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x24, - 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x0a, 0x2e, 0x44, 0x42, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x07, 0x63, 0x6f, 0x6d, - 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x94, 0x01, 0x0a, 0x16, 0x46, 0x6f, 0x72, 0x75, 0x6d, 0x52, 0x65, - 0x6c, 0x65, 0x61, 0x73, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x12, - 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x75, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x75, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, - 0x07, 0x68, 0x65, 0x72, 0x6f, 0x63, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, - 0x68, 0x65, 0x72, 0x6f, 0x63, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x68, 0x65, 0x72, 0x6f, 0x6f, - 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x68, 0x65, 0x72, 0x6f, 0x6f, 0x69, - 0x64, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x22, 0x3f, 0x0a, 0x17, 0x46, - 0x6f, 0x72, 0x75, 0x6d, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x65, - 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x24, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, - 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x44, 0x42, 0x43, 0x6f, 0x6d, 0x6d, - 0x65, 0x6e, 0x74, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x06, 0x5a, 0x04, - 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x72, 0x75, 0x6d, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x12, 0x68, + 0x65, 0x72, 0x6f, 0x2f, 0x68, 0x65, 0x72, 0x6f, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x22, 0x2b, 0x0a, 0x0f, 0x46, 0x6f, 0x72, 0x75, 0x6d, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, + 0x74, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x68, 0x65, 0x72, 0x6f, 0x63, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x68, 0x65, 0x72, 0x6f, 0x63, 0x69, 0x64, 0x22, 0x38, + 0x0a, 0x10, 0x46, 0x6f, 0x72, 0x75, 0x6d, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x12, 0x24, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x44, 0x42, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x52, + 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x94, 0x01, 0x0a, 0x16, 0x46, 0x6f, 0x72, + 0x75, 0x6d, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, + 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x75, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x75, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x18, 0x0a, 0x07, 0x68, 0x65, 0x72, 0x6f, 0x63, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x68, 0x65, 0x72, 0x6f, 0x63, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x68, + 0x65, 0x72, 0x6f, 0x6f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x68, 0x65, + 0x72, 0x6f, 0x6f, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x22, + 0x3f, 0x0a, 0x17, 0x46, 0x6f, 0x72, 0x75, 0x6d, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x43, + 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x24, 0x0a, 0x07, 0x63, 0x6f, + 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x44, 0x42, + 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, + 0x22, 0x6d, 0x0a, 0x11, 0x46, 0x6f, 0x72, 0x75, 0x6d, 0x57, 0x61, 0x74, 0x63, 0x68, 0x48, 0x65, + 0x72, 0x6f, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x74, 0x61, 0x67, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x73, 0x74, 0x61, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x68, + 0x65, 0x72, 0x6f, 0x63, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x68, 0x65, + 0x72, 0x6f, 0x63, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x68, 0x65, 0x72, 0x6f, 0x6f, 0x49, 0x64, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x68, 0x65, 0x72, 0x6f, 0x6f, 0x49, 0x64, 0x22, + 0x31, 0x0a, 0x12, 0x46, 0x6f, 0x72, 0x75, 0x6d, 0x57, 0x61, 0x74, 0x63, 0x68, 0x48, 0x65, 0x72, + 0x6f, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1b, 0x0a, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x04, 0x68, 0x65, + 0x72, 0x6f, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -285,22 +417,26 @@ func file_forum_forum_msg_proto_rawDescGZIP() []byte { return file_forum_forum_msg_proto_rawDescData } -var file_forum_forum_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_forum_forum_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_forum_forum_msg_proto_goTypes = []interface{}{ (*ForumGetListReq)(nil), // 0: ForumGetListReq (*ForumGetListResp)(nil), // 1: ForumGetListResp (*ForumReleaseCommentReq)(nil), // 2: ForumReleaseCommentReq (*ForumReleaseCommentResp)(nil), // 3: ForumReleaseCommentResp - (*DBComment)(nil), // 4: DBComment + (*ForumWatchHeroReq)(nil), // 4: ForumWatchHeroReq + (*ForumWatchHeroResp)(nil), // 5: ForumWatchHeroResp + (*DBComment)(nil), // 6: DBComment + (*DBHero)(nil), // 7: DBHero } var file_forum_forum_msg_proto_depIdxs = []int32{ - 4, // 0: ForumGetListResp.comment:type_name -> DBComment - 4, // 1: ForumReleaseCommentResp.comment:type_name -> DBComment - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 6, // 0: ForumGetListResp.comment:type_name -> DBComment + 6, // 1: ForumReleaseCommentResp.comment:type_name -> DBComment + 7, // 2: ForumWatchHeroResp.hero:type_name -> DBHero + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name } func init() { file_forum_forum_msg_proto_init() } @@ -309,6 +445,7 @@ func file_forum_forum_msg_proto_init() { return } file_forum_forum_db_proto_init() + file_hero_hero_db_proto_init() if !protoimpl.UnsafeEnabled { file_forum_forum_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ForumGetListReq); i { @@ -358,6 +495,30 @@ func file_forum_forum_msg_proto_init() { return nil } } + file_forum_forum_msg_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ForumWatchHeroReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_forum_forum_msg_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ForumWatchHeroResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -365,7 +526,7 @@ func file_forum_forum_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_forum_forum_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 6, NumExtensions: 0, NumServices: 0, }, diff --git a/services/worker/main.go b/services/worker/main.go index 71de9abc2..1887f7b7b 100644 --- a/services/worker/main.go +++ b/services/worker/main.go @@ -5,6 +5,7 @@ import ( "fmt" "go_dreamfactory/modules/chat" "go_dreamfactory/modules/equipment" + "go_dreamfactory/modules/forum" "go_dreamfactory/modules/friend" "go_dreamfactory/modules/gm" "go_dreamfactory/modules/hero" @@ -55,6 +56,7 @@ func main() { notify.NewModule(), chat.NewModule(), gm.NewModule(), + forum.NewModule(), ) } diff --git a/sys/configure/structs/game.msgDistrib.go b/sys/configure/structs/game.msgDistrib.go index 97041dd26..d0a26dea7 100644 --- a/sys/configure/structs/game.msgDistrib.go +++ b/sys/configure/structs/game.msgDistrib.go @@ -21,7 +21,7 @@ func NewGame_msgdistrib(_buf []map[string]interface{}) (*Game_msgdistrib, error) return nil, err2 } else { _dataList = append(_dataList, _v) - dataMap[_v.Mtype] = _v + dataMap[_v.Msgid] = _v } } return &Game_msgdistrib{_dataList:_dataList, _dataMap:dataMap}, nil diff --git a/sys/configure/structs/game.msgDistribData.go b/sys/configure/structs/game.msgDistribData.go index c2bcfb5be..405637d6f 100644 --- a/sys/configure/structs/game.msgDistribData.go +++ b/sys/configure/structs/game.msgDistribData.go @@ -11,9 +11,9 @@ package cfg import "errors" type Game_msgdistribData struct { - Mtype string - Stype string + Msgid string Routrules string + Describe string } func (Game_msgdistribData) GetTypeId() int { @@ -22,8 +22,8 @@ func (Game_msgdistribData) GetTypeId() int { func NewGame_msgdistribData(_buf map[string]interface{}) (_v *Game_msgdistribData, err error) { _v = &Game_msgdistribData{} - { var _ok_ bool; if _v.Mtype, _ok_ = _buf["mtype"].(string); !_ok_ { err = errors.New("mtype error"); return } } - { var _ok_ bool; if _v.Stype, _ok_ = _buf["stype"].(string); !_ok_ { err = errors.New("stype error"); return } } + { var _ok_ bool; if _v.Msgid, _ok_ = _buf["msgid"].(string); !_ok_ { err = errors.New("msgid error"); return } } { var _ok_ bool; if _v.Routrules, _ok_ = _buf["routrules"].(string); !_ok_ { err = errors.New("routrules error"); return } } + { var _ok_ bool; if _v.Describe, _ok_ = _buf["describe"].(string); !_ok_ { err = errors.New("describe error"); return } } return } diff --git a/sys/db/dbconn.go b/sys/db/dbconn.go index d018088d7..f778f174c 100644 --- a/sys/db/dbconn.go +++ b/sys/db/dbconn.go @@ -240,8 +240,8 @@ func (this *DBModel) AddQueues(key string, uplimit int64, data interface{}) (out } pipe.RPushForStringSlice(key, keys...) lcmd := pipe.Llen(key) - pipe.Exec() - if lcmd.Err() == nil { + + if _, err = pipe.Exec(); err == nil { if lcmd.Val() > uplimit*3 { //操作3倍上限移除多余数据 off := uplimit - lcmd.Val() if outkey, err = this.Redis.LRangeToStringSlice(key, 0, int(off-1)).Result(); err != nil { @@ -457,7 +457,7 @@ func (this *DBModel) GetQueues(key string, count int, data interface{}) (err err sliceelemType = sliceelemType.(*reflect2.UnsafePtrType).Elem() pipe := this.Redis.RedisPipe(context.TODO()) - if err = this.Redis.LRange(key, -1*count, -1, keys); err == nil { + if keys, err = this.Redis.LRangeToStringSlice(key, -1*count, -1).Result(); err == nil { result = make([]*redis.StringStringMapCmd, 0) for _, v := range keys { cmd := pipe.HGetAllToMapString(v)