Compare commits
38 Commits
887cb242e3
...
feat/instg
| Author | SHA1 | Date | |
|---|---|---|---|
| acef3423b3 | |||
| 3b36244282 | |||
| c0f6cd90c6 | |||
| 5aeff7c786 | |||
| 73d3361f34 | |||
| ba16c2cce3 | |||
| b76595d164 | |||
| 53cda1ce5e | |||
| 6d5c7e81e9 | |||
| ed80af6ae2 | |||
| 692f65b80f | |||
| f5cbede966 | |||
| 2b583e2249 | |||
| 636008b97d | |||
| 313a93702e | |||
| c4e3365c53 | |||
| 85b0300935 | |||
| 732336c282 | |||
| 7f16b94f9c | |||
| 151517de9b | |||
| a3eb63eea6 | |||
| 9e1889b956 | |||
| 5af027b35c | |||
| 265e522aff | |||
| 2145b07e69 | |||
| bf5d2025a1 | |||
| 9146c7b0b0 | |||
| 6f133f7cdf | |||
| 21eba6d885 | |||
| 5c3ba8e33a | |||
| 7e8803e549 | |||
| da6ecebd52 | |||
| c1470d5f9d | |||
| bfd27b8a6d | |||
| a4f40eca2f | |||
| 5ea74566dd | |||
| 46839cd11b | |||
| 8289e2b4d9 |
59
app/app.go
59
app/app.go
@@ -1,33 +1,41 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"common/discover"
|
||||
"common/log"
|
||||
"fmt"
|
||||
"gateway/config"
|
||||
"git.hlsq.asia/mmorpg/service-common/discover/common"
|
||||
"git.hlsq.asia/mmorpg/service-common/log"
|
||||
"git.hlsq.asia/mmorpg/service-common/module"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/config"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/global"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/grpc_server"
|
||||
"github.com/judwhite/go-svc"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type Program struct {
|
||||
moduleList []Module // 模块列表
|
||||
}
|
||||
|
||||
type Module interface {
|
||||
init() error
|
||||
start() error
|
||||
stop() error
|
||||
moduleList []module.Module // 模块列表
|
||||
}
|
||||
|
||||
func (p *Program) Init(_ svc.Environment) error {
|
||||
p.moduleList = append(p.moduleList, &ModuleBase{})
|
||||
p.moduleList = append(p.moduleList, &ModuleDB{})
|
||||
p.moduleList = append(p.moduleList, &ModulePrometheus{})
|
||||
base := &ModuleBase{}
|
||||
if err := base.Init(); err != nil {
|
||||
return err
|
||||
}
|
||||
p.moduleList = append(p.moduleList, base)
|
||||
p.moduleList = append(p.moduleList, (&module.DB{}).Bind(config.Get().DB, common.KeyDiscoverServiceNameGateway))
|
||||
p.moduleList = append(p.moduleList, &ModuleWebServer{})
|
||||
p.moduleList = append(p.moduleList, &ModuleWebsocketServer{})
|
||||
p.moduleList = append(p.moduleList, &ModuleGrpcServer{})
|
||||
p.moduleList = append(p.moduleList, &ModuleLoginQueue{})
|
||||
p.moduleList = append(p.moduleList, (&module.Grpc{}).Bind(grpc_server.NewServer(config.Get().Serve.Grpc)))
|
||||
p.moduleList = append(p.moduleList, (&module.Prometheus{}).Bind(config.Get().Metric))
|
||||
p.moduleList = append(p.moduleList, (&module.Tracer{}).Bind(config.Get().Metric, common.KeyDiscoverServiceNameGateway))
|
||||
p.moduleList = append(p.moduleList, &module.Discover{})
|
||||
|
||||
for _, module := range p.moduleList {
|
||||
if err := module.init(); err != nil {
|
||||
for i, m := range p.moduleList {
|
||||
if i == 0 {
|
||||
continue
|
||||
}
|
||||
if err := m.Init(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -36,22 +44,29 @@ func (p *Program) Init(_ svc.Environment) error {
|
||||
}
|
||||
|
||||
func (p *Program) Start() error {
|
||||
for _, module := range p.moduleList {
|
||||
if err := module.start(); err != nil {
|
||||
ready := &sync.WaitGroup{}
|
||||
ready.Add(len(p.moduleList))
|
||||
for _, m := range p.moduleList {
|
||||
if err := m.Start(ready); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
discover.Listen()
|
||||
ready.Wait()
|
||||
for _, m := range p.moduleList {
|
||||
if err := m.AfterStart(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
global.ServiceStatus = global.ServiceStatusReady
|
||||
|
||||
log.Infof(fmt.Sprintf("%v Start successful...", config.Get().App.Name))
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Program) Stop() error {
|
||||
discover.Close()
|
||||
for i := len(p.moduleList) - 1; i >= 0; i-- {
|
||||
module := p.moduleList[i]
|
||||
if err := module.stop(); err != nil {
|
||||
m := p.moduleList[i]
|
||||
if err := m.Stop(); err != nil {
|
||||
log.Errorf("module stop error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
18
app/base.go
18
app/base.go
@@ -1,17 +1,19 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"common/log"
|
||||
"common/utils"
|
||||
"gateway/config"
|
||||
"git.hlsq.asia/mmorpg/service-common/log"
|
||||
"git.hlsq.asia/mmorpg/service-common/module"
|
||||
"git.hlsq.asia/mmorpg/service-common/utils"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/config"
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
// ModuleBase 基础模块,或者一些零散的模块
|
||||
type ModuleBase struct {
|
||||
module.DefaultModule
|
||||
}
|
||||
|
||||
func (p *ModuleBase) init() error {
|
||||
func (m *ModuleBase) Init() error {
|
||||
// 配置
|
||||
if err := config.LoadConfig(); err != nil {
|
||||
return err
|
||||
@@ -23,11 +25,3 @@ func (p *ModuleBase) init() error {
|
||||
utils.InitSnowflake(int64(rand.Intn(1000)))
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *ModuleBase) start() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *ModuleBase) stop() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
23
app/db.go
23
app/db.go
@@ -1,23 +0,0 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"common/db"
|
||||
"gateway/config"
|
||||
)
|
||||
|
||||
// ModuleDB 数据库模块
|
||||
type ModuleDB struct {
|
||||
dbModule *db.ModuleDB
|
||||
}
|
||||
|
||||
func (p *ModuleDB) init() error {
|
||||
return p.dbModule.Init(config.Get().DB)
|
||||
}
|
||||
|
||||
func (p *ModuleDB) start() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *ModuleDB) stop() error {
|
||||
return p.dbModule.Stop()
|
||||
}
|
||||
27
app/grpc.go
27
app/grpc.go
@@ -1,27 +0,0 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"common/net/grpc/service"
|
||||
"gateway/config"
|
||||
"gateway/internal/grpc_server/server"
|
||||
)
|
||||
|
||||
// ModuleGrpcServer Grpc服务模块
|
||||
type ModuleGrpcServer struct {
|
||||
server service.IService
|
||||
}
|
||||
|
||||
func (m *ModuleGrpcServer) init() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ModuleGrpcServer) start() error {
|
||||
m.server = server.NewServer(config.Get().Serve.Grpc.TTL)
|
||||
m.server.Init(config.Get().Serve.Grpc.Address, config.Get().Serve.Grpc.Port)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ModuleGrpcServer) stop() error {
|
||||
m.server.Close()
|
||||
return nil
|
||||
}
|
||||
33
app/login_queue.go
Normal file
33
app/login_queue.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/mmorpg/service-common/module"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/global"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/handler/ws_handler/login"
|
||||
"runtime"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// ModuleLoginQueue 登录队列模块
|
||||
type ModuleLoginQueue struct {
|
||||
module.DefaultModule
|
||||
login *login.Login
|
||||
queueUp *login.QueueUp
|
||||
}
|
||||
|
||||
func (m *ModuleLoginQueue) Init() error {
|
||||
m.login = login.NewLoginQueue(global.MaxQueueUpSize)
|
||||
m.queueUp = login.NewQueueUp(global.MaxQueueUpSize)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ModuleLoginQueue) Start(ready *sync.WaitGroup) error {
|
||||
m.login.Start(runtime.NumCPU())
|
||||
ready.Done()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ModuleLoginQueue) Stop() error {
|
||||
m.login.Stop()
|
||||
return nil
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"common/log"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"gateway/config"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"net/http"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// ModulePrometheus 普罗米修斯模块
|
||||
type ModulePrometheus struct {
|
||||
wg *sync.WaitGroup
|
||||
server *http.Server
|
||||
}
|
||||
|
||||
func (m *ModulePrometheus) init() error {
|
||||
m.wg = &sync.WaitGroup{}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ModulePrometheus) start() error {
|
||||
m.wg.Add(1)
|
||||
go func() {
|
||||
defer m.wg.Done()
|
||||
m.server = &http.Server{
|
||||
Addr: fmt.Sprintf("%v:%v", config.Get().Metric.Prometheus.Address, config.Get().Metric.Prometheus.Port),
|
||||
Handler: promhttp.Handler(),
|
||||
}
|
||||
if err := m.server.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||
log.Errorf("prometheus server failed: %v", err.Error())
|
||||
}
|
||||
log.Infof("prometheus server stop.")
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ModulePrometheus) stop() error {
|
||||
if err := m.server.Shutdown(context.Background()); err != nil {
|
||||
log.Errorf("stop prometheus server failed: %v", err)
|
||||
}
|
||||
m.wg.Wait()
|
||||
return nil
|
||||
}
|
||||
15
app/web.go
15
app/web.go
@@ -1,28 +1,30 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"common/log"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"gateway/config"
|
||||
"gateway/internal/net/http_gateway"
|
||||
"git.hlsq.asia/mmorpg/service-common/log"
|
||||
"git.hlsq.asia/mmorpg/service-common/module"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/config"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/net/http_gateway"
|
||||
"net/http"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// ModuleWebServer Web服务模块
|
||||
type ModuleWebServer struct {
|
||||
module.DefaultModule
|
||||
wg *sync.WaitGroup
|
||||
server *http.Server
|
||||
}
|
||||
|
||||
func (m *ModuleWebServer) init() error {
|
||||
func (m *ModuleWebServer) Init() error {
|
||||
m.wg = &sync.WaitGroup{}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ModuleWebServer) start() error {
|
||||
func (m *ModuleWebServer) Start(ready *sync.WaitGroup) error {
|
||||
m.wg.Add(1)
|
||||
go func() {
|
||||
defer m.wg.Done()
|
||||
@@ -30,6 +32,7 @@ func (m *ModuleWebServer) start() error {
|
||||
Addr: fmt.Sprintf("%v:%v", config.Get().Serve.Http.Address, config.Get().Serve.Http.Port),
|
||||
Handler: http_gateway.InitRouter(),
|
||||
}
|
||||
ready.Done()
|
||||
if err := m.server.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||
log.Errorf("http server failed: %v", err.Error())
|
||||
}
|
||||
@@ -38,7 +41,7 @@ func (m *ModuleWebServer) start() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ModuleWebServer) stop() error {
|
||||
func (m *ModuleWebServer) Stop() error {
|
||||
if err := m.server.Shutdown(context.Background()); err != nil {
|
||||
log.Errorf("stop http server failed: %v", err)
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"common/log"
|
||||
"common/net/socket/websocket"
|
||||
"fmt"
|
||||
"gateway/config"
|
||||
"gateway/internal/net/ws_gateway"
|
||||
"git.hlsq.asia/mmorpg/service-common/log"
|
||||
"git.hlsq.asia/mmorpg/service-common/module"
|
||||
"git.hlsq.asia/mmorpg/service-common/net/socket/websocket"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/config"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/net/ws_gateway"
|
||||
"github.com/panjf2000/gnet/v2"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -13,11 +14,12 @@ import (
|
||||
|
||||
// ModuleWebsocketServer Websocket服务模块
|
||||
type ModuleWebsocketServer struct {
|
||||
module.DefaultModule
|
||||
wg *sync.WaitGroup
|
||||
server *websocket.WSServer
|
||||
}
|
||||
|
||||
func (m *ModuleWebsocketServer) init() error {
|
||||
func (m *ModuleWebsocketServer) Init() error {
|
||||
m.wg = &sync.WaitGroup{}
|
||||
m.server = websocket.NewWSServer(
|
||||
&ws_gateway.GatewayWsServer{},
|
||||
@@ -27,10 +29,11 @@ func (m *ModuleWebsocketServer) init() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ModuleWebsocketServer) start() error {
|
||||
func (m *ModuleWebsocketServer) Start(ready *sync.WaitGroup) error {
|
||||
m.wg.Add(1)
|
||||
go func() {
|
||||
defer m.wg.Done()
|
||||
ready.Done()
|
||||
_ = m.server.Run(
|
||||
fmt.Sprintf("tcp4://0.0.0.0:%v", config.Get().Serve.Socket.Web.Port),
|
||||
true,
|
||||
@@ -47,7 +50,7 @@ func (m *ModuleWebsocketServer) start() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ModuleWebsocketServer) stop() error {
|
||||
func (m *ModuleWebsocketServer) Stop() error {
|
||||
if err := m.server.Stop(); err != nil {
|
||||
log.Errorf("stop websocket server failed: %v", err)
|
||||
}
|
||||
|
||||
@@ -11,32 +11,35 @@ log:
|
||||
metric:
|
||||
prometheus:
|
||||
address: "0.0.0.0"
|
||||
port: 8504
|
||||
port: 18504
|
||||
jaeger:
|
||||
endpoint: "localhost:4317"
|
||||
|
||||
db:
|
||||
etcd:
|
||||
endpoints: [ "10.0.40.9:2379" ]
|
||||
endpoints: [ "localhost:2379" ]
|
||||
redis:
|
||||
addr: "47.108.184.184:6379"
|
||||
addr: "localhost:6379"
|
||||
password: "lQ7aM8oB6lK0iD5k"
|
||||
db: 0
|
||||
|
||||
serve:
|
||||
grpc:
|
||||
address: "10.0.40.199"
|
||||
port: 8500
|
||||
port: 18500
|
||||
ttl: 20
|
||||
socket:
|
||||
web:
|
||||
address: "0.0.0.0"
|
||||
port: 8501
|
||||
port: 18501
|
||||
raw:
|
||||
address: "0.0.0.0"
|
||||
port: 8502
|
||||
port: 18502
|
||||
http:
|
||||
address: "0.0.0.0"
|
||||
port: 8503
|
||||
port: 18503
|
||||
|
||||
auth:
|
||||
secret: "bMa3mU4oCsX2KBex5o7GzwSnACpumFq3SdlDXYZgVTU="
|
||||
expire: 259200
|
||||
shortExpire: 60
|
||||
longExpire: 10080
|
||||
|
||||
@@ -1,17 +1,8 @@
|
||||
package config
|
||||
|
||||
import "common/config"
|
||||
import "git.hlsq.asia/mmorpg/service-common/config"
|
||||
|
||||
const (
|
||||
path = "./config"
|
||||
KeyUserAccessToken = "user:access:%v"
|
||||
KeyUserRefreshToken = "user:refresh:%v"
|
||||
)
|
||||
|
||||
// PublicPaths 不需要鉴权的接口,硬编码注册
|
||||
var PublicPaths = []string{
|
||||
"/user/info",
|
||||
}
|
||||
const path = "./config"
|
||||
|
||||
type Config struct {
|
||||
App *config.AppConfig `yaml:"app"`
|
||||
@@ -19,10 +10,13 @@ type Config struct {
|
||||
Metric *config.MetricConfig `yaml:"metric"`
|
||||
DB *config.DBConfig `yaml:"db"`
|
||||
Serve *config.ServeConfig `yaml:"serve"`
|
||||
Auth *struct {
|
||||
Secret string `yaml:"secret"`
|
||||
Expire int64 `yaml:"expire"`
|
||||
}
|
||||
Auth *AuthConfig `yaml:"auth"`
|
||||
}
|
||||
|
||||
type AuthConfig struct {
|
||||
Secret string `yaml:"secret"`
|
||||
ShortExpire int64 `yaml:"shortExpire"`
|
||||
LongExpire int64 `yaml:"longExpire"`
|
||||
}
|
||||
|
||||
var cfg *Config
|
||||
@@ -37,3 +31,7 @@ func LoadConfig() error {
|
||||
func Get() *Config {
|
||||
return cfg
|
||||
}
|
||||
|
||||
func Set(c *Config) {
|
||||
cfg = c
|
||||
}
|
||||
|
||||
@@ -11,7 +11,9 @@ log:
|
||||
metric:
|
||||
prometheus:
|
||||
address: "0.0.0.0"
|
||||
port: 8504
|
||||
port: 18504
|
||||
jaeger:
|
||||
endpoint: "172.18.28.0:4317"
|
||||
|
||||
db:
|
||||
etcd:
|
||||
@@ -24,19 +26,20 @@ db:
|
||||
serve:
|
||||
grpc:
|
||||
address: "172.18.28.0"
|
||||
port: 8500
|
||||
port: 18500
|
||||
ttl: 20
|
||||
socket:
|
||||
web:
|
||||
address: "0.0.0.0"
|
||||
port: 8501
|
||||
port: 18501
|
||||
raw:
|
||||
address: "0.0.0.0"
|
||||
port: 8502
|
||||
port: 18502
|
||||
http:
|
||||
address: "0.0.0.0"
|
||||
port: 8503
|
||||
port: 18503
|
||||
|
||||
auth:
|
||||
secret: "bMa3mU4oCsX2KBex5o7GzwSnACpumFq3SdlDXYZgVTU="
|
||||
expire: 259200
|
||||
shortExpire: 15
|
||||
longExpire: 10080
|
||||
@@ -1,12 +1,17 @@
|
||||
FROM alpine:3.23.2
|
||||
|
||||
ENV ARMS_ENABLE=true
|
||||
ENV ARMS_APP_NAME=gateway
|
||||
ENV ARMS_REGION_ID=cn-chengdu
|
||||
ENV ARMS_LICENSE_KEY=gys9jv7jqe@144a6fd684976b3
|
||||
|
||||
RUN apk add --no-cache tzdata && \
|
||||
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
||||
echo "Asia/Shanghai" > /etc/timezone
|
||||
|
||||
COPY server-gateway /app/server-gateway
|
||||
COPY ../config /app/config
|
||||
RUN chmod 777 /app/server-gateway
|
||||
COPY service-gateway /app/service-gateway
|
||||
COPY config /app/config
|
||||
RUN chmod 777 /app/service-gateway
|
||||
|
||||
WORKDIR /app
|
||||
CMD ["./server-gateway"]
|
||||
CMD ["./service-gateway"]
|
||||
60
deploy/Jenkinsfile
vendored
60
deploy/Jenkinsfile
vendored
@@ -3,7 +3,7 @@ pipeline {
|
||||
|
||||
environment {
|
||||
// 仓库
|
||||
REPO_URL = 'http://47.108.184.184/gitea/HuXiaoHei/Game.git'
|
||||
REPO_URL = 'https://git.hlsq.asia/mmorpg/service-gateway.git'
|
||||
REPO_CREDENTIALS_ID = '80805ba2-f4ac-4d84-aee6-d4cce5fc0a96'
|
||||
|
||||
// Registry
|
||||
@@ -16,9 +16,10 @@ pipeline {
|
||||
SSH_CREDENTIALS_ID = '10e0830d-4d03-4879-9ee4-03a4c55513ad'
|
||||
|
||||
// 基础信息
|
||||
APP_NAME = 'server-gateway'
|
||||
APP_NAME = 'service-gateway'
|
||||
GO_MOD_CACHE_DIR = '/home/pi/Desktop/docker/jenkins/caches/go-mod'
|
||||
GO_BUILD_CACHE_DIR = '/home/pi/Desktop/docker/jenkins/caches/go-build'
|
||||
INSTGO_CACHE_DIR = '/home/pi/Desktop/docker/jenkins/caches/instgo'
|
||||
}
|
||||
|
||||
options {
|
||||
@@ -51,43 +52,42 @@ pipeline {
|
||||
stage('Build Go Binary') {
|
||||
agent {
|
||||
docker {
|
||||
image 'golang:1.23.1-alpine'
|
||||
image 'golang:1.24.0-alpine'
|
||||
reuseNode true
|
||||
args '-u root:root -v $GO_MOD_CACHE_DIR:/go/pkg/mod -v $GO_BUILD_CACHE_DIR:/root/.cache/go-build'
|
||||
args '-u root:root -v $GO_MOD_CACHE_DIR:/go/pkg/mod -v $GO_BUILD_CACHE_DIR:/root/.cache/go-build -v $INSTGO_CACHE_DIR:/root/instgo-caches'
|
||||
}
|
||||
}
|
||||
steps {
|
||||
dir('Server/gateway') {
|
||||
sh """
|
||||
export GOPROXY=https://goproxy.cn,direct
|
||||
export CGO_ENABLED=0
|
||||
export GOOS=linux
|
||||
export GOARCH=amd64
|
||||
sh """
|
||||
export GOPROXY=https://goproxy.cn,direct
|
||||
export CGO_ENABLED=0
|
||||
export GOOS=linux
|
||||
export GOARCH=amd64
|
||||
export INSTGO_CACHE_DIR=/root/instgo-caches
|
||||
|
||||
go build -o ${env.APP_NAME} .
|
||||
"""
|
||||
}
|
||||
wget "http://arms-apm-cn-chengdu.oss-cn-chengdu.aliyuncs.com/instgo/instgo-linux-arm64" -O instgo
|
||||
chmod +x instgo
|
||||
./instgo set --licenseKey=gys9jv7jqe@144a6fd684976b3
|
||||
./instgo go build -o ${env.APP_NAME} .
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
stage('Push Docker Image') {
|
||||
agent any
|
||||
steps {
|
||||
dir('Server/gateway') {
|
||||
script {
|
||||
withCredentials([usernamePassword(
|
||||
credentialsId: env.REGISTRY_CREDENTIALS_ID,
|
||||
usernameVariable: 'DOCKER_USER',
|
||||
passwordVariable: 'DOCKER_PASS'
|
||||
)]) {
|
||||
sh """
|
||||
echo "$DOCKER_PASS" | docker login --username "$DOCKER_USER" --password-stdin ${env.REGISTRY_URL}
|
||||
docker build -t ${env.IMAGE_TAG} .
|
||||
docker push ${env.IMAGE_TAG}
|
||||
docker rmi ${env.IMAGE_TAG}
|
||||
docker logout ${env.REGISTRY_URL}
|
||||
"""
|
||||
}
|
||||
script {
|
||||
withCredentials([usernamePassword(
|
||||
credentialsId: env.REGISTRY_CREDENTIALS_ID,
|
||||
usernameVariable: 'DOCKER_USER',
|
||||
passwordVariable: 'DOCKER_PASS'
|
||||
)]) {
|
||||
sh """
|
||||
echo "$DOCKER_PASS" | docker login --username "$DOCKER_USER" --password-stdin ${env.REGISTRY_URL}
|
||||
docker buildx build --platform linux/amd64 -t ${env.IMAGE_TAG} -f deploy/Dockerfile . --push
|
||||
docker rmi ${env.IMAGE_TAG}
|
||||
docker logout ${env.REGISTRY_URL}
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,9 +115,9 @@ pipeline {
|
||||
docker run -d \\
|
||||
--name ${env.APP_NAME} \\
|
||||
--restart unless-stopped \\
|
||||
-p 8500-8504:8500-8504 \\
|
||||
-p 18500-18504:18500-18504 \\
|
||||
--env XH_G_ENV=prod \\
|
||||
-v /root/server/logs/gateway_log/:/app/logs \\
|
||||
-v /root/service/logs/gateway_log/:/app/logs \\
|
||||
${env.IMAGE_TAG}
|
||||
docker logout ${env.REGISTRY_URL}
|
||||
"""
|
||||
|
||||
91
go.mod
91
go.mod
@@ -1,50 +1,74 @@
|
||||
module gateway
|
||||
module git.hlsq.asia/mmorpg/service-gateway
|
||||
|
||||
go 1.23.1
|
||||
go 1.24.0
|
||||
|
||||
require (
|
||||
common v0.0.0-00010101000000-000000000000
|
||||
bou.ke/monkey v1.0.2
|
||||
git.hlsq.asia/mmorpg/service-common v0.0.0-20260123132258-4d661d08134e
|
||||
github.com/alicebob/miniredis/v2 v2.35.0
|
||||
github.com/gin-contrib/cors v1.7.6
|
||||
github.com/gin-gonic/gin v1.11.0
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3
|
||||
github.com/golang/mock v1.6.0
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3
|
||||
github.com/judwhite/go-svc v1.2.1
|
||||
github.com/panjf2000/gnet/v2 v2.9.7
|
||||
github.com/prometheus/client_golang v1.20.5
|
||||
github.com/redis/go-redis/v9 v9.10.0
|
||||
github.com/stretchr/testify v1.11.1
|
||||
go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin v0.64.0
|
||||
go.uber.org/zap v1.27.0
|
||||
google.golang.org/grpc v1.71.1
|
||||
google.golang.org/protobuf v1.36.9
|
||||
google.golang.org/grpc v1.77.0
|
||||
google.golang.org/protobuf v1.36.10
|
||||
)
|
||||
|
||||
require (
|
||||
filippo.io/edwards25519 v1.1.0 // indirect
|
||||
github.com/IBM/sarama v1.46.3 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bwmarrin/snowflake v0.3.0 // indirect
|
||||
github.com/bytedance/sonic v1.14.0 // indirect
|
||||
github.com/bytedance/sonic/loader v0.3.0 // indirect
|
||||
github.com/bytedance/gopkg v0.1.3 // indirect
|
||||
github.com/bytedance/sonic v1.14.2 // indirect
|
||||
github.com/bytedance/sonic/loader v0.4.0 // indirect
|
||||
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/cloudwego/base64x v0.1.6 // indirect
|
||||
github.com/coreos/go-semver v0.3.1 // indirect
|
||||
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/eapache/go-resiliency v1.7.0 // indirect
|
||||
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect
|
||||
github.com/eapache/queue v1.1.0 // indirect
|
||||
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.9 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.11 // indirect
|
||||
github.com/gin-contrib/sse v1.1.0 // indirect
|
||||
github.com/go-logr/logr v1.4.3 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.27.0 // indirect
|
||||
github.com/go-playground/validator/v10 v10.28.0 // indirect
|
||||
github.com/go-sql-driver/mysql v1.8.1 // indirect
|
||||
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
|
||||
github.com/gobwas/httphead v0.1.0 // indirect
|
||||
github.com/gobwas/pool v0.2.1 // indirect
|
||||
github.com/gobwas/ws v1.4.0 // indirect
|
||||
github.com/goccy/go-json v0.10.5 // indirect
|
||||
github.com/goccy/go-yaml v1.18.0 // indirect
|
||||
github.com/goccy/go-yaml v1.19.0 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang-jwt/jwt/v5 v5.3.0 // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/hashicorp/go-uuid v1.0.3 // indirect
|
||||
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
|
||||
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
|
||||
github.com/jcmturner/gofork v1.7.6 // indirect
|
||||
github.com/jcmturner/gokrb5/v8 v8.4.4 // indirect
|
||||
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/compress v1.17.9 // indirect
|
||||
github.com/klauspost/compress v1.18.1 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
@@ -53,14 +77,15 @@ require (
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/natefinch/lumberjack v2.0.0+incompatible // indirect
|
||||
github.com/panjf2000/ants/v2 v2.11.3 // indirect
|
||||
github.com/panjf2000/gnet/v2 v2.9.7 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||
github.com/pierrec/lz4/v4 v4.1.22 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/prometheus/client_model v0.6.1 // indirect
|
||||
github.com/prometheus/common v0.62.0 // indirect
|
||||
github.com/prometheus/procfs v0.15.1 // indirect
|
||||
github.com/quic-go/qpack v0.5.1 // indirect
|
||||
github.com/quic-go/quic-go v0.54.0 // indirect
|
||||
github.com/redis/go-redis/v9 v9.10.0 // indirect
|
||||
github.com/quic-go/qpack v0.6.0 // indirect
|
||||
github.com/quic-go/quic-go v0.57.1 // indirect
|
||||
github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9 // indirect
|
||||
github.com/sagikazarmark/locafero v0.11.0 // indirect
|
||||
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect
|
||||
github.com/spf13/afero v1.15.0 // indirect
|
||||
@@ -69,27 +94,33 @@ require (
|
||||
github.com/spf13/viper v1.21.0 // indirect
|
||||
github.com/subosito/gotenv v1.6.0 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.3.0 // indirect
|
||||
github.com/ugorji/go/codec v1.3.1 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/yuin/gopher-lua v1.1.1 // indirect
|
||||
go.etcd.io/etcd/api/v3 v3.6.1 // indirect
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.6.1 // indirect
|
||||
go.etcd.io/etcd/client/v3 v3.6.1 // indirect
|
||||
go.uber.org/mock v0.5.0 // indirect
|
||||
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.64.0 // indirect
|
||||
go.opentelemetry.io/otel v1.39.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.39.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.39.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.39.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.39.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.39.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v1.9.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go.yaml.in/yaml/v3 v3.0.4 // indirect
|
||||
golang.org/x/arch v0.20.0 // indirect
|
||||
golang.org/x/crypto v0.40.0 // indirect
|
||||
golang.org/x/mod v0.26.0 // indirect
|
||||
golang.org/x/net v0.42.0 // indirect
|
||||
golang.org/x/sync v0.16.0 // indirect
|
||||
golang.org/x/sys v0.35.0 // indirect
|
||||
golang.org/x/text v0.28.0 // indirect
|
||||
golang.org/x/tools v0.35.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb // indirect
|
||||
golang.org/x/arch v0.23.0 // indirect
|
||||
golang.org/x/crypto v0.45.0 // indirect
|
||||
golang.org/x/net v0.47.0 // indirect
|
||||
golang.org/x/sync v0.18.0 // indirect
|
||||
golang.org/x/sys v0.39.0 // indirect
|
||||
golang.org/x/text v0.31.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
gorm.io/driver/mysql v1.6.0 // indirect
|
||||
gorm.io/gorm v1.31.1 // indirect
|
||||
)
|
||||
|
||||
replace common => ../common
|
||||
|
||||
221
go.sum
221
go.sum
@@ -1,7 +1,15 @@
|
||||
bou.ke/monkey v1.0.2 h1:kWcnsrCNUatbxncxR/ThdYqbytgOIArtYWqcQLQzKLI=
|
||||
bou.ke/monkey v1.0.2/go.mod h1:OqickVX3tNx6t33n1xvtTtu85YN5s6cKwVug+oHMaIA=
|
||||
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||
git.hlsq.asia/mmorpg/service-common v0.0.0-20260123132258-4d661d08134e h1:jcDwaL280D5BVGCfcIC3mQCjmwPz5fxX7NO1qf6nAIo=
|
||||
git.hlsq.asia/mmorpg/service-common v0.0.0-20260123132258-4d661d08134e/go.mod h1:mMhZcumphj6gaVTppVYsMTkd+5HupmQgAc53Pd4MH9I=
|
||||
github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
|
||||
github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/IBM/sarama v1.46.3 h1:njRsX6jNlnR+ClJ8XmkO+CM4unbrNr/2vB5KK6UA+IE=
|
||||
github.com/IBM/sarama v1.46.3/go.mod h1:GTUYiF9DMOZVe3FwyGT+dtSPceGFIgA+sPc5u6CBwko=
|
||||
github.com/alicebob/miniredis/v2 v2.35.0 h1:QwLphYqCEAo1eu1TqPRN2jgVMPBweeQcR21jeqDCONI=
|
||||
github.com/alicebob/miniredis/v2 v2.35.0/go.mod h1:TcL7YfarKPGDAthEtl5NBeHZfeUQj6OXMm/+iu5cLMM=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
||||
@@ -10,10 +18,14 @@ github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
||||
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
|
||||
github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0=
|
||||
github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE=
|
||||
github.com/bytedance/sonic v1.14.0 h1:/OfKt8HFw0kh2rj8N0F6C/qPGRESq0BbaNZgcNXXzQQ=
|
||||
github.com/bytedance/sonic v1.14.0/go.mod h1:WoEbx8WTcFJfzCe0hbmyTGrfjt8PzNEBdxlNUO24NhA=
|
||||
github.com/bytedance/sonic/loader v0.3.0 h1:dskwH8edlzNMctoruo8FPTJDF3vLtDT0sXZwvZJyqeA=
|
||||
github.com/bytedance/sonic/loader v0.3.0/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
|
||||
github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M=
|
||||
github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM=
|
||||
github.com/bytedance/sonic v1.14.2 h1:k1twIoe97C1DtYUo+fZQy865IuHia4PR5RPiuGPPIIE=
|
||||
github.com/bytedance/sonic v1.14.2/go.mod h1:T80iDELeHiHKSc0C9tubFygiuXoGzrkjKzX2quAx980=
|
||||
github.com/bytedance/sonic/loader v0.4.0 h1:olZ7lEqcxtZygCK9EKYKADnpQoYkRQxaeY2NYzevs+o=
|
||||
github.com/bytedance/sonic/loader v0.4.0/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo=
|
||||
github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
|
||||
github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M=
|
||||
@@ -27,20 +39,29 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
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/eapache/go-resiliency v1.7.0 h1:n3NRTnBn5N0Cbi/IeOHuQn9s2UwVUH7Ga0ZWcP+9JTA=
|
||||
github.com/eapache/go-resiliency v1.7.0/go.mod h1:5yPzW0MIvSe0JDsv0v+DvcjEv2FyD6iZYSs1ZI+iQho=
|
||||
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 h1:Oy0F4ALJ04o5Qqpdz8XLIpNA3WM/iSIXqxtqo7UGVws=
|
||||
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3/go.mod h1:YvSRo5mw33fLEx1+DlK6L2VV43tJt5Eyel9n9XBcR+0=
|
||||
github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc=
|
||||
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
|
||||
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
|
||||
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
|
||||
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
||||
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
||||
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
|
||||
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
||||
github.com/gabriel-vasile/mimetype v1.4.9 h1:5k+WDwEsD9eTLL8Tz3L0VnmVh9QxGjRmjBvAG7U/oYY=
|
||||
github.com/gabriel-vasile/mimetype v1.4.9/go.mod h1:WnSQhFKJuBlRyLiKohA/2DtIlPFAbguNaG7QCHcyGok=
|
||||
github.com/gabriel-vasile/mimetype v1.4.11 h1:AQvxbp830wPhHTqc1u7nzoLT+ZFxGY7emj5DR5DYFik=
|
||||
github.com/gabriel-vasile/mimetype v1.4.11/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
|
||||
github.com/gin-contrib/cors v1.7.6 h1:3gQ8GMzs1Ylpf70y8bMw4fVpycXIeX1ZemuSQIsnQQY=
|
||||
github.com/gin-contrib/cors v1.7.6/go.mod h1:Ulcl+xN4jel9t1Ry8vqph23a60FwH9xVLd+3ykmTjOk=
|
||||
github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w=
|
||||
github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM=
|
||||
github.com/gin-gonic/gin v1.11.0 h1:OW/6PLjyusp2PPXtyxKHU0RbX6I/l28FTdDlae5ueWk=
|
||||
github.com/gin-gonic/gin v1.11.0/go.mod h1:+iq/FyxlGzII0KHiBGjuNn4UNENUlKbGlNmc+W50Dls=
|
||||
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
||||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
|
||||
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
@@ -49,8 +70,8 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.27.0 h1:w8+XrWVMhGkxOaaowyKH35gFydVHOvC0/uWoy2Fzwn4=
|
||||
github.com/go-playground/validator/v10 v10.27.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo=
|
||||
github.com/go-playground/validator/v10 v10.28.0 h1:Q7ibns33JjyW48gHkuFT91qX48KG0ktULL6FgHdG688=
|
||||
github.com/go-playground/validator/v10 v10.28.0/go.mod h1:GoI6I1SjPBh9p7ykNE/yj3fFYbyDOpwMn5KXd+m2hUU=
|
||||
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
|
||||
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
|
||||
github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs=
|
||||
@@ -63,22 +84,43 @@ github.com/gobwas/ws v1.4.0 h1:CTaoG1tojrh4ucGPcoJFiAQUAsEWekEWvLy7GsVNqGs=
|
||||
github.com/gobwas/ws v1.4.0/go.mod h1:G3gNqMNtPppf5XUz7O4shetPpcZ1VJ7zt18dlUeakrc=
|
||||
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
||||
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||
github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw=
|
||||
github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
|
||||
github.com/goccy/go-yaml v1.19.0 h1:EmkZ9RIsX+Uq4DYFowegAuJo8+xdX3T/2dwNPXbxEYE=
|
||||
github.com/goccy/go-yaml v1.19.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||
github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo=
|
||||
github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
|
||||
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
|
||||
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
|
||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
|
||||
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 h1:5ZPtiqj0JL5oKWmcsq4VMaAW5ukBEgSGXEN89zeH1Jo=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3/go.mod h1:ndYquD05frm2vACXE1nsccT4oJzjhw2arTS2cpUD1PI=
|
||||
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
|
||||
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 h1:NmZ1PKzSTQbuGHw9DGPFomqkkLWMC+vZCkfs+FHv1Vg=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3/go.mod h1:zQrxl1YP88HQlA6i9c63DSVPFklWpGX4OWAc9bFuaH4=
|
||||
github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
|
||||
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8=
|
||||
github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs=
|
||||
github.com/jcmturner/dnsutils/v2 v2.0.0 h1:lltnkeZGL0wILNvrNiVCR6Ro5PGU/SeBvVO/8c/iPbo=
|
||||
github.com/jcmturner/dnsutils/v2 v2.0.0/go.mod h1:b0TnjGOvI/n42bZa+hmXL+kFJZsFT7G4t3HTlQ184QM=
|
||||
github.com/jcmturner/gofork v1.7.6 h1:QH0l3hzAU1tfT3rZCnW5zXl+orbkNMMRGJfdJjHVETg=
|
||||
github.com/jcmturner/gofork v1.7.6/go.mod h1:1622LH6i/EZqLloHfE7IeZ0uEJwMSUyQ/nDd82IeqRo=
|
||||
github.com/jcmturner/goidentity/v6 v6.0.1 h1:VKnZd2oEIMorCTsFBnJWbExfNN7yZr3EhJAxwOkZg6o=
|
||||
github.com/jcmturner/goidentity/v6 v6.0.1/go.mod h1:X1YW3bgtvwAXju7V3LCIMpY0Gbxyjn/mY9zx4tFonSg=
|
||||
github.com/jcmturner/gokrb5/v8 v8.4.4 h1:x1Sv4HaTpepFkXbt2IkL29DXRf8sOfZXo8eRKh687T8=
|
||||
github.com/jcmturner/gokrb5/v8 v8.4.4/go.mod h1:1btQEpgT6k+unzCwX1KdWMEwPPkkgBtP+F6aCACiMrs=
|
||||
github.com/jcmturner/rpc/v2 v2.0.3 h1:7FXXj8Ti1IaVFpSAziCZWNzbNuZmnvw/i6CqLNdWfZY=
|
||||
github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc=
|
||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
@@ -89,8 +131,8 @@ github.com/judwhite/go-svc v1.2.1 h1:a7fsJzYUa33sfDJRF2N/WXhA+LonCEEY8BJb1tuS5tA
|
||||
github.com/judwhite/go-svc v1.2.1/go.mod h1:mo/P2JNX8C07ywpP9YtO2gnBgnUiFTHqtsZekJrUuTk=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
|
||||
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
||||
github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co=
|
||||
github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0=
|
||||
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
|
||||
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
@@ -114,12 +156,12 @@ github.com/natefinch/lumberjack v2.0.0+incompatible h1:4QJd3OLAMgj7ph+yZTuX13Ld4
|
||||
github.com/natefinch/lumberjack v2.0.0+incompatible/go.mod h1:Wi9p2TTF5DG5oU+6YfsmYQpsTIOm0B1VNzQg9Mw6nPk=
|
||||
github.com/panjf2000/ants/v2 v2.11.3 h1:AfI0ngBoXJmYOpDh9m516vjqoUu2sLrIVgppI9TZVpg=
|
||||
github.com/panjf2000/ants/v2 v2.11.3/go.mod h1:8u92CYMUc6gyvTIw8Ru7Mt7+/ESnJahz5EVtqfrilek=
|
||||
github.com/panjf2000/gnet/v2 v2.9.1 h1:bKewICy/0xnQ9PMzNaswpe/Ah14w1TrRk91LHTcbIlA=
|
||||
github.com/panjf2000/gnet/v2 v2.9.1/go.mod h1:WQTxDWYuQ/hz3eccH0FN32IVuvZ19HewEWx0l62fx7E=
|
||||
github.com/panjf2000/gnet/v2 v2.9.7 h1:6zW7Jl3oAfXwSuh1PxHLndoL2MQRWx0AJR6aaQjxUgA=
|
||||
github.com/panjf2000/gnet/v2 v2.9.7/go.mod h1:WQTxDWYuQ/hz3eccH0FN32IVuvZ19HewEWx0l62fx7E=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||
github.com/pierrec/lz4/v4 v4.1.22 h1:cKFw6uJDK+/gfw5BcDL0JL5aBsAFdsIT18eRtLj7VIU=
|
||||
github.com/pierrec/lz4/v4 v4.1.22/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
|
||||
@@ -130,14 +172,16 @@ github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ
|
||||
github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I=
|
||||
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
||||
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
||||
github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI=
|
||||
github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg=
|
||||
github.com/quic-go/quic-go v0.54.0 h1:6s1YB9QotYI6Ospeiguknbp2Znb/jZYjZLRXn9kMQBg=
|
||||
github.com/quic-go/quic-go v0.54.0/go.mod h1:e68ZEaCdyviluZmy44P6Iey98v/Wfz6HCjQEm+l8zTY=
|
||||
github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8=
|
||||
github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII=
|
||||
github.com/quic-go/quic-go v0.57.1 h1:25KAAR9QR8KZrCZRThWMKVAwGoiHIrNbT72ULHTuI10=
|
||||
github.com/quic-go/quic-go v0.57.1/go.mod h1:ly4QBAjHA2VhdnxhojRsCUOeJwKYg+taDlos92xb1+s=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9 h1:bsUq1dX0N8AOIL7EB/X911+m4EHsnWEHeJ0c+3TTBrg=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||
github.com/redis/go-redis/v9 v9.10.0 h1:FxwK3eV8p/CQa0Ch276C7u2d0eNC9kCmAYQ7mCXCzVs=
|
||||
github.com/redis/go-redis/v9 v9.10.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw=
|
||||
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
|
||||
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
|
||||
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
||||
github.com/sagikazarmark/locafero v0.11.0 h1:1iurJgmM9G3PA/I+wWYIOw/5SyBtxapeHDcg+AAIFXc=
|
||||
github.com/sagikazarmark/locafero v0.11.0/go.mod h1:nVIGvgyzw595SUSUE6tvCp3YYTeHs15MvlmU87WwIik=
|
||||
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 h1:+jumHNA0Wrelhe64i8F6HNlS8pkoyMv5sreGx2Ry5Rw=
|
||||
@@ -153,106 +197,155 @@ github.com/spf13/viper v1.21.0/go.mod h1:P0lhsswPGWD/1lZJ9ny3fYnVqxiegrlNrEmgLjb
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
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.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
|
||||
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
github.com/ugorji/go/codec v1.3.0 h1:Qd2W2sQawAfG8XSvzwhBeoGq71zXOC/Q1E9y/wUcsUA=
|
||||
github.com/ugorji/go/codec v1.3.0/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
|
||||
github.com/ugorji/go/codec v1.3.1 h1:waO7eEiFDwidsBN6agj1vJQ4AG7lh2yqXyOXqhgQuyY=
|
||||
github.com/ugorji/go/codec v1.3.1/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
|
||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M=
|
||||
github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
|
||||
go.etcd.io/etcd/api/v3 v3.6.1 h1:yJ9WlDih9HT457QPuHt/TH/XtsdN2tubyxyQHSHPsEo=
|
||||
go.etcd.io/etcd/api/v3 v3.6.1/go.mod h1:lnfuqoGsXMlZdTJlact3IB56o3bWp1DIlXPIGKRArto=
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.6.1 h1:CxDVv8ggphmamrXM4Of8aCC8QHzDM4tGcVr9p2BSoGk=
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.6.1/go.mod h1:aTkCp+6ixcVTZmrJGa7/Mc5nMNs59PEgBbq+HCmWyMc=
|
||||
go.etcd.io/etcd/client/v3 v3.6.1 h1:KelkcizJGsskUXlsxjVrSmINvMMga0VWwFF0tSPGEP0=
|
||||
go.etcd.io/etcd/client/v3 v3.6.1/go.mod h1:fCbPUdjWNLfx1A6ATo9syUmFVxqHH9bCnPLBZmnLmMY=
|
||||
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
|
||||
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
|
||||
go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY=
|
||||
go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI=
|
||||
go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ=
|
||||
go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE=
|
||||
go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7Wr1A=
|
||||
go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w=
|
||||
go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k=
|
||||
go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE=
|
||||
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
|
||||
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
|
||||
go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin v0.64.0 h1:7IKZbAYwlwLXAdu7SVPhzTjDjogWZxP4MIa7rovY+PU=
|
||||
go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin v0.64.0/go.mod h1:+TF5nf3NIv2X8PGxqfYOaRnAoMM43rUA2C3XsN2DoWA=
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.64.0 h1:RN3ifU8y4prNWeEnQp2kRRHz8UwonAEYZl8tUzHEXAk=
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.64.0/go.mod h1:habDz3tEWiFANTo6oUE99EmaFUrCNYAAg3wiVmusm70=
|
||||
go.opentelemetry.io/contrib/propagators/b3 v1.39.0 h1:PI7pt9pkSnimWcp5sQhUA9OzLbc3Ba4sL+VEUTNsxrk=
|
||||
go.opentelemetry.io/contrib/propagators/b3 v1.39.0/go.mod h1:5gV/EzPnfYIwjzj+6y8tbGW2PKWhcsz5e/7twptRVQY=
|
||||
go.opentelemetry.io/otel v1.39.0 h1:8yPrr/S0ND9QEfTfdP9V+SiwT4E0G7Y5MO7p85nis48=
|
||||
go.opentelemetry.io/otel v1.39.0/go.mod h1:kLlFTywNWrFyEdH0oj2xK0bFYZtHRYUdv1NklR/tgc8=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.39.0 h1:f0cb2XPmrqn4XMy9PNliTgRKJgS5WcL/u0/WRYGz4t0=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.39.0/go.mod h1:vnakAaFckOMiMtOIhFI2MNH4FYrZzXCYxmb1LlhoGz8=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.39.0 h1:in9O8ESIOlwJAEGTkkf34DesGRAc/Pn8qJ7k3r/42LM=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.39.0/go.mod h1:Rp0EXBm5tfnv0WL+ARyO/PHBEaEAT8UUHQ6AGJcSq6c=
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.39.0 h1:8UPA4IbVZxpsD76ihGOQiFml99GPAEZLohDXvqHdi6U=
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.39.0/go.mod h1:MZ1T/+51uIVKlRzGw1Fo46KEWThjlCBZKl2LzY5nv4g=
|
||||
go.opentelemetry.io/otel/metric v1.39.0 h1:d1UzonvEZriVfpNKEVmHXbdf909uGTOQjA0HF0Ls5Q0=
|
||||
go.opentelemetry.io/otel/metric v1.39.0/go.mod h1:jrZSWL33sD7bBxg1xjrqyDjnuzTUB0x1nBERXd7Ftcs=
|
||||
go.opentelemetry.io/otel/sdk v1.39.0 h1:nMLYcjVsvdui1B/4FRkwjzoRVsMK8uL/cj0OyhKzt18=
|
||||
go.opentelemetry.io/otel/sdk v1.39.0/go.mod h1:vDojkC4/jsTJsE+kh+LXYQlbL8CgrEcwmt1ENZszdJE=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.39.0 h1:cXMVVFVgsIf2YL6QkRF4Urbr/aMInf+2WKg+sEJTtB8=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.39.0/go.mod h1:xq9HEVH7qeX69/JnwEfp6fVq5wosJsY1mt4lLfYdVew=
|
||||
go.opentelemetry.io/otel/trace v1.39.0 h1:2d2vfpEDmCJ5zVYz7ijaJdOF59xLomrvj7bjt6/qCJI=
|
||||
go.opentelemetry.io/otel/trace v1.39.0/go.mod h1:88w4/PnZSazkGzz/w84VHpQafiU4EtqqlVdxWy+rNOA=
|
||||
go.opentelemetry.io/proto/otlp v1.9.0 h1:l706jCMITVouPOqEnii2fIAuO3IVGBRPV5ICjceRb/A=
|
||||
go.opentelemetry.io/proto/otlp v1.9.0/go.mod h1:xE+Cx5E/eEHw+ISFkwPLwCZefwVjY+pqKg1qcK03+/4=
|
||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||
go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU=
|
||||
go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM=
|
||||
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
|
||||
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
|
||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
||||
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
||||
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
|
||||
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
||||
golang.org/x/arch v0.20.0 h1:dx1zTU0MAE98U+TQ8BLl7XsJbgze2WnNKF/8tGp/Q6c=
|
||||
golang.org/x/arch v0.20.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk=
|
||||
golang.org/x/arch v0.23.0 h1:lKF64A2jF6Zd8L0knGltUnegD62JMFBiCPBmQpToHhg=
|
||||
golang.org/x/arch v0.23.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM=
|
||||
golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
|
||||
golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
|
||||
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.26.0 h1:EGMPT//Ezu+ylkCijjPc+f4Aih7sZvaAr+O3EHBxvZg=
|
||||
golang.org/x/mod v0.26.0/go.mod h1:/j6NAhSk8iQ723BGAUyoAcn7SlD7s15Dp9Nd/SfeaFQ=
|
||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
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-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs=
|
||||
golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
|
||||
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
|
||||
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I=
|
||||
golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/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-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
|
||||
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
|
||||
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
|
||||
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
|
||||
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
|
||||
golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
|
||||
golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.35.0 h1:mBffYraMEf7aa0sB+NuKnuCy8qI/9Bughn8dC2Gu5r0=
|
||||
golang.org/x/tools v0.35.0/go.mod h1:NKdj5HkL/73byiZSJjqJgKn3ep7KjFkBOkR/Hps3VPw=
|
||||
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/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/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb h1:p31xT4yrYrSM/G4Sn2+TNUkVhFCbG9y8itM2S6Th950=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb/go.mod h1:jbe3Bkdp+Dh2IrslsFCklNhweNTBgSYanP1UXhJDhKg=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb h1:TLPQVbx1GJ8VKZxz52VAxl1EBgKXXbTiU9Fc5fZeLn4=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb/go.mod h1:LuRYeWDFV6WOn90g357N17oMCaxpgCnbi/44qJvDn2I=
|
||||
google.golang.org/grpc v1.71.1 h1:ffsFWr7ygTUscGPI0KKK6TLrGz0476KUvvsbqWK0rPI=
|
||||
google.golang.org/grpc v1.71.1/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec=
|
||||
google.golang.org/protobuf v1.36.9 h1:w2gp2mA27hUeUzj9Ex9FBjsBm40zfaDtEWow293U7Iw=
|
||||
google.golang.org/protobuf v1.36.9/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
|
||||
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
|
||||
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 h1:fCvbg86sFXwdrl5LgVcTEvNC+2txB5mgROGmRL5mrls=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217/go.mod h1:+rXWjjaukWZun3mLfjmVnQi18E1AsFbDN9QdJ5YXLto=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 h1:gRkg/vSppuSQoDjxyiGfN4Upv/h/DQmIR10ZU8dh4Ww=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk=
|
||||
google.golang.org/grpc v1.77.0 h1:wVVY6/8cGA6vvffn+wWK5ToddbgdU3d8MNENr4evgXM=
|
||||
google.golang.org/grpc v1.77.0/go.mod h1:z0BY1iVj0q8E1uSQCjL9cppRj+gnZjzDnzV0dHhrNig=
|
||||
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
|
||||
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
||||
26
internal/global/global.go
Normal file
26
internal/global/global.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package global
|
||||
|
||||
var ServiceStatus = ServiceStatusStarting
|
||||
|
||||
type ServiceStatusCode int32
|
||||
|
||||
const (
|
||||
ServiceStatusStarting ServiceStatusCode = iota // 启动中
|
||||
ServiceStatusReady // 就绪
|
||||
ServiceStatusStopping // 停止中
|
||||
)
|
||||
|
||||
var GatewaySID string
|
||||
|
||||
const (
|
||||
KeyGatewayAccessToken = "gateway:token:access:%v"
|
||||
KeyGatewayRefreshToken = "gateway:token:refresh:%v"
|
||||
|
||||
KeyGatewayInfo = "gateway:info:%v"
|
||||
HFieldInfoGatewaySID = "gateway_sid"
|
||||
)
|
||||
|
||||
const (
|
||||
MaxOnlineSize = 100 // 最大在线人数
|
||||
MaxQueueUpSize = 100 // 最大排队人数
|
||||
)
|
||||
24
internal/global/metric.go
Normal file
24
internal/global/metric.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package global
|
||||
|
||||
import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
var (
|
||||
OnlineUsersGauge prometheus.Gauge
|
||||
FlowCounter prometheus.Counter
|
||||
)
|
||||
|
||||
func init() {
|
||||
OnlineUsersGauge = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Name: "gateway_online_users",
|
||||
Help: "Total number of online users",
|
||||
})
|
||||
prometheus.MustRegister(OnlineUsersGauge)
|
||||
|
||||
FlowCounter = prometheus.NewCounter(prometheus.CounterOpts{
|
||||
Name: "gateway_flow_counter",
|
||||
Help: "Total number of flow",
|
||||
})
|
||||
prometheus.MustRegister(FlowCounter)
|
||||
}
|
||||
70
internal/grpc_server/server.go
Normal file
70
internal/grpc_server/server.go
Normal file
@@ -0,0 +1,70 @@
|
||||
package grpc_server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.hlsq.asia/mmorpg/service-common/log"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/ss/ss_pb"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/global"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/handler/ws_handler/client"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"sync"
|
||||
)
|
||||
|
||||
func (s *Server) ToClient(server grpc_pb.Gateway_ToClientServer) error {
|
||||
wg := &sync.WaitGroup{}
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
log.Errorf("ToClient panic: %v", err)
|
||||
}
|
||||
}()
|
||||
for {
|
||||
if args, err := server.Recv(); err != nil {
|
||||
return
|
||||
} else {
|
||||
if args.USN == "" {
|
||||
|
||||
//utils.WorkerPool(ws_handler.UserMgr.GetAllInterface(), func(task interface{}) {
|
||||
// client := task.(*ws_handler.Client)
|
||||
// client.WriteBytes(ss_pb.MessageID(args.MessageID), args.Payload)
|
||||
//})
|
||||
|
||||
data, err := proto.Marshal(&ss_pb.Message{
|
||||
ID: ss_pb.MessageID(args.MessageID),
|
||||
Payload: args.Payload,
|
||||
})
|
||||
if err != nil {
|
||||
log.Errorf("ToClient proto.Marshal error: %v", err)
|
||||
continue
|
||||
}
|
||||
dataLen := float64(len(data))
|
||||
for _, cli := range client.UserMgr.GetAll() {
|
||||
cli.WriteBytesPreMarshal(data)
|
||||
global.FlowCounter.Add(dataLen)
|
||||
}
|
||||
|
||||
//for _, client := range ws_handler.UserMgr.GetAll() {
|
||||
// client.WriteBytes(ss_pb.MessageID(args.MessageID), args.Payload)
|
||||
//}
|
||||
} else {
|
||||
if cli := client.UserMgr.GetByUSN(args.USN); cli != nil {
|
||||
cli.WriteBytes(ss_pb.MessageID(args.MessageID), args.Payload)
|
||||
global.FlowCounter.Add(float64(len(args.Payload)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
wg.Wait()
|
||||
return server.SendAndClose(&grpc_pb.ToClientResp{})
|
||||
}
|
||||
|
||||
func (s *Server) KickUser(ctx context.Context, req *grpc_pb.KickUserReq) (*grpc_pb.KickUserResp, error) {
|
||||
if cli := client.UserMgr.GetByUSN(req.USN); cli != nil {
|
||||
cli.CloseClient()
|
||||
}
|
||||
return &grpc_pb.KickUserResp{}, nil
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"common/log"
|
||||
"common/proto/sc/sc_pb"
|
||||
"common/proto/ss/grpc_pb"
|
||||
"gateway/internal/handler/ws_handler"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"sync"
|
||||
)
|
||||
|
||||
func (s *Server) ToClient(server grpc_pb.Gateway_ToClientServer) error {
|
||||
wg := &sync.WaitGroup{}
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
log.Errorf("Action panic: %v", err)
|
||||
}
|
||||
}()
|
||||
for {
|
||||
if args, err := server.Recv(); err != nil {
|
||||
return
|
||||
} else {
|
||||
if args.USN == -1 {
|
||||
|
||||
//utils.WorkerPool(ws_handler.UserMgr.GetAllInterface(), func(task interface{}) {
|
||||
// client := task.(*ws_handler.Client)
|
||||
// client.WriteBytes(sc_pb.MessageID(args.MessageID), args.Payload)
|
||||
//})
|
||||
|
||||
data, err := proto.Marshal(&sc_pb.Message{
|
||||
ID: sc_pb.MessageID(args.MessageID),
|
||||
Payload: args.Payload,
|
||||
})
|
||||
if err != nil {
|
||||
log.Errorf("ToClient proto.Marshal error: %v", err)
|
||||
continue
|
||||
}
|
||||
for _, client := range ws_handler.UserMgr.GetAll() {
|
||||
client.WriteBytesPreMarshal(data)
|
||||
}
|
||||
|
||||
//for _, client := range ws_handler.UserMgr.GetAll() {
|
||||
// client.WriteBytes(sc_pb.MessageID(args.MessageID), args.Payload)
|
||||
//}
|
||||
} else {
|
||||
if client := ws_handler.UserMgr.GetByUSN(args.USN); client != nil {
|
||||
client.WriteBytes(sc_pb.MessageID(args.MessageID), args.Payload)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
wg.Wait()
|
||||
return server.SendAndClose(&grpc_pb.ToClientResp{})
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"common/discover/common"
|
||||
"common/net/grpc/service"
|
||||
"common/proto/ss/grpc_pb"
|
||||
"gateway/internal/handler/ws_handler"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
grpc_pb.UnimplementedGatewayServer
|
||||
service.Base
|
||||
}
|
||||
|
||||
func NewServer(ttl int64) *Server {
|
||||
s := &Server{
|
||||
Base: service.Base{
|
||||
Target: common.KeyDiscoverGateway,
|
||||
EtcdTTL: ttl,
|
||||
},
|
||||
}
|
||||
s.Base.OnInit = s.OnInit
|
||||
s.Base.OnClose = s.OnClose
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *Server) OnInit(serve *grpc.Server) {
|
||||
ws_handler.GatewaySID = s.SID
|
||||
grpc_pb.RegisterGatewayServer(serve, s)
|
||||
}
|
||||
|
||||
func (s *Server) OnClose() {
|
||||
}
|
||||
41
internal/grpc_server/server_init.go
Normal file
41
internal/grpc_server/server_init.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package grpc_server
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/mmorpg/service-common/config"
|
||||
"git.hlsq.asia/mmorpg/service-common/discover/common"
|
||||
"git.hlsq.asia/mmorpg/service-common/net/grpc/service"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/global"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
grpc_pb.UnimplementedGatewayServer
|
||||
service.Base
|
||||
}
|
||||
|
||||
func NewServer(cfg *config.GrpcConfig) *Server {
|
||||
s := &Server{
|
||||
Base: service.Base{
|
||||
Target: common.KeyDiscoverGateway,
|
||||
ServiceName: common.KeyDiscoverServiceNameGateway,
|
||||
Cfg: cfg,
|
||||
},
|
||||
}
|
||||
s.Base.OnCustomGrpcServerOption = s.OnCustomGrpcServerOption
|
||||
s.Base.OnInit = s.OnInit
|
||||
s.Base.OnClose = s.OnClose
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *Server) OnCustomGrpcServerOption() []grpc.ServerOption {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Server) OnInit(serve *grpc.Server) {
|
||||
global.GatewaySID = s.SID
|
||||
grpc_pb.RegisterGatewayServer(serve, s)
|
||||
}
|
||||
|
||||
func (s *Server) OnClose() {
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
package stream_client
|
||||
|
||||
import (
|
||||
"common/log"
|
||||
"common/net/grpc/service"
|
||||
"context"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
var sceneServerM map[int64]map[SceneFun]grpc.ClientStream // map[sid]map[方法名]流连接
|
||||
|
||||
type SceneFun int
|
||||
|
||||
const (
|
||||
FunAction SceneFun = iota
|
||||
)
|
||||
|
||||
func init() {
|
||||
sceneServerM = make(map[int64]map[SceneFun]grpc.ClientStream)
|
||||
}
|
||||
|
||||
func findSceneBySID(sid int64, fun SceneFun) (grpc.ClientStream, error) {
|
||||
g := sceneServerM[sid]
|
||||
if g == nil {
|
||||
g = make(map[SceneFun]grpc.ClientStream)
|
||||
sceneServerM[sid] = g
|
||||
}
|
||||
sceneLink := g[fun]
|
||||
if sceneLink == nil {
|
||||
sceneClient, err := service.SceneNewClient(sid)
|
||||
if err != nil {
|
||||
log.Errorf("cannot find sceneClient: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
var link grpc.ClientStream
|
||||
switch fun {
|
||||
case FunAction:
|
||||
link, err = sceneClient.Action(context.Background())
|
||||
}
|
||||
if err != nil {
|
||||
log.Errorf("findSceneBySID %v err: %v, sid: %v", fun, err, sid)
|
||||
return nil, err
|
||||
}
|
||||
g[fun] = link
|
||||
sceneLink = link
|
||||
}
|
||||
return sceneLink, nil
|
||||
}
|
||||
|
||||
func SendMessageToScene(sid int64, fun SceneFun, msg proto.Message, re ...bool) error {
|
||||
stream, err := findSceneBySID(sid, fun)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err = stream.SendMsg(msg); err != nil {
|
||||
if re == nil || !re[0] {
|
||||
_ = stream.CloseSend()
|
||||
delete(sceneServerM[sid], fun)
|
||||
return SendMessageToScene(sid, fun, msg, true)
|
||||
}
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1,15 +1,16 @@
|
||||
package http_handler
|
||||
|
||||
import (
|
||||
"common/db/redis"
|
||||
"common/log"
|
||||
"common/net/grpc/service"
|
||||
"common/net/http/http_resp"
|
||||
"common/proto/ss/grpc_pb"
|
||||
"common/utils"
|
||||
"context"
|
||||
"fmt"
|
||||
"gateway/config"
|
||||
"git.hlsq.asia/mmorpg/service-common/db/redis"
|
||||
"git.hlsq.asia/mmorpg/service-common/log"
|
||||
"git.hlsq.asia/mmorpg/service-common/net/grpc/grpc_client"
|
||||
"git.hlsq.asia/mmorpg/service-common/net/http/http_resp"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
|
||||
"git.hlsq.asia/mmorpg/service-common/utils"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/config"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/global"
|
||||
"github.com/gin-gonic/gin"
|
||||
"time"
|
||||
)
|
||||
@@ -17,12 +18,13 @@ import (
|
||||
// 这个模块处理用户登录
|
||||
|
||||
type LoginReq struct {
|
||||
Phone string `json:"phone" binding:"required,min=1"`
|
||||
Code string `json:"code" binding:"required,min=1"`
|
||||
Phone string `json:"phone"` // 手机号
|
||||
Code string `json:"code"` // 验证码
|
||||
WxMiniCode string `json:"wxMiniCode"` // 微信小程序登录
|
||||
}
|
||||
|
||||
type LoginResp struct {
|
||||
USN int64 `json:"usn"`
|
||||
USN string `json:"usn"`
|
||||
Name string `json:"name"`
|
||||
AccessToken string `json:"accessToken"`
|
||||
RefreshToken string `json:"refreshToken"`
|
||||
@@ -34,26 +36,45 @@ func Login(c *gin.Context) {
|
||||
http_resp.JsonBadRequest(c)
|
||||
return
|
||||
}
|
||||
client, err := service.UserNewClientLB()
|
||||
client, err := grpc_client.UserNewClientLB()
|
||||
if err != nil {
|
||||
log.Errorf("Login UserNewClientLB error: %v", err)
|
||||
http_resp.JsonOK(c, http_resp.Error(http_resp.Failed))
|
||||
return
|
||||
}
|
||||
login, err := client.Login(c, &grpc_pb.LoginReq{
|
||||
Phone: req.Phone,
|
||||
Code: req.Code,
|
||||
})
|
||||
if err != nil {
|
||||
log.Errorf("Login Login error: %v", err)
|
||||
http_resp.JsonOK(c, http_resp.Error(http_resp.Failed))
|
||||
|
||||
usn, name := "", ""
|
||||
if req.Phone != "" {
|
||||
// TODO 校验验证码
|
||||
login, err := client.PhoneLogin(c, &grpc_pb.PhoneLoginReq{
|
||||
Phone: req.Phone,
|
||||
Code: req.Code,
|
||||
})
|
||||
if err != nil {
|
||||
log.Errorf("Login PhoneLogin error: %v", err)
|
||||
http_resp.JsonOK(c, http_resp.Error(http_resp.Failed))
|
||||
return
|
||||
}
|
||||
usn, name = login.USN, login.Name
|
||||
} else if req.WxMiniCode != "" {
|
||||
login, err := client.WxMiniLogin(c, &grpc_pb.WxMiniLoginReq{
|
||||
Code: req.WxMiniCode,
|
||||
})
|
||||
if err != nil {
|
||||
log.Errorf("Login WxMiniLogin error: %v", err)
|
||||
http_resp.JsonOK(c, http_resp.Error(http_resp.Failed))
|
||||
return
|
||||
}
|
||||
usn, name = login.USN, login.Name
|
||||
} else {
|
||||
http_resp.JsonBadRequest(c)
|
||||
return
|
||||
}
|
||||
|
||||
at, rt, err := genToken(c, login.USN)
|
||||
at, rt, err := genToken(c, usn)
|
||||
http_resp.JsonOK(c, http_resp.Success(&LoginResp{
|
||||
USN: login.USN,
|
||||
Name: login.Name,
|
||||
USN: usn,
|
||||
Name: name,
|
||||
AccessToken: at,
|
||||
RefreshToken: rt,
|
||||
}))
|
||||
@@ -76,11 +97,11 @@ func RefreshToken(c *gin.Context) {
|
||||
}
|
||||
claims, err := utils.ParseToken(req.RefreshToken, config.Get().Auth.Secret)
|
||||
if err != nil {
|
||||
http_resp.JsonOK(c, http_resp.Error(http_resp.TokenInvalid))
|
||||
http_resp.JsonUnauthorized(c)
|
||||
return
|
||||
}
|
||||
if redis.GetClient().Get(c, fmt.Sprintf(config.KeyUserRefreshToken, claims.USN)).String() != req.RefreshToken {
|
||||
http_resp.JsonOK(c, http_resp.Error(http_resp.TokenInvalid))
|
||||
if redis.GetClient().Get(c, fmt.Sprintf(global.KeyGatewayRefreshToken, claims.USN)).Val() != req.RefreshToken {
|
||||
http_resp.JsonUnauthorized(c)
|
||||
return
|
||||
}
|
||||
at, rt, err := genToken(c, claims.USN)
|
||||
@@ -96,20 +117,20 @@ func RefreshToken(c *gin.Context) {
|
||||
}))
|
||||
}
|
||||
|
||||
func genToken(ctx context.Context, usn int64) (string, string, error) {
|
||||
at, err := genTokenOne(ctx, config.KeyUserAccessToken, usn, 2*time.Hour)
|
||||
func genToken(ctx context.Context, usn string) (string, string, error) {
|
||||
at, err := genTokenOne(ctx, global.KeyGatewayAccessToken, usn, time.Duration(config.Get().Auth.ShortExpire)*time.Minute)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
rt, err := genTokenOne(ctx, config.KeyUserRefreshToken, usn, 3*24*time.Hour)
|
||||
rt, err := genTokenOne(ctx, global.KeyGatewayRefreshToken, usn, time.Duration(config.Get().Auth.LongExpire)*time.Minute)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
return at, rt, nil
|
||||
}
|
||||
|
||||
func genTokenOne(ctx context.Context, key string, usn int64, ttl time.Duration) (string, error) {
|
||||
token, err := utils.GenToken(usn, config.Get().Auth.Secret, time.Duration(config.Get().Auth.Expire)*time.Second)
|
||||
func genTokenOne(ctx context.Context, key string, usn string, ttl time.Duration) (string, error) {
|
||||
token, err := utils.GenToken(usn, config.Get().Auth.Secret, ttl)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
172
internal/handler/http_handler/login_test.go
Normal file
172
internal/handler/http_handler/login_test.go
Normal file
@@ -0,0 +1,172 @@
|
||||
package http_handler
|
||||
|
||||
import (
|
||||
"bou.ke/monkey"
|
||||
"context"
|
||||
"fmt"
|
||||
"git.hlsq.asia/mmorpg/service-common/db/redis"
|
||||
"git.hlsq.asia/mmorpg/service-common/net/grpc/grpc_client"
|
||||
"git.hlsq.asia/mmorpg/service-common/net/http/http_resp"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb/mocks"
|
||||
"git.hlsq.asia/mmorpg/service-common/utils"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/global"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/testutil"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/golang/mock/gomock"
|
||||
redis2 "github.com/redis/go-redis/v9"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type LoginTestSuite struct {
|
||||
testutil.TestSuite
|
||||
}
|
||||
|
||||
func (ts *LoginTestSuite) TestGenToken() {
|
||||
usn := utils.RandInt(1, 100000000)
|
||||
at, rt, err := genToken(context.Background(), strconv.Itoa(usn))
|
||||
ts.Assert().NoError(err)
|
||||
|
||||
redisAt := redis.GetClient().Get(context.Background(), fmt.Sprintf(global.KeyGatewayAccessToken, usn)).Val()
|
||||
ts.Assert().Equal(at, redisAt)
|
||||
redisRt := redis.GetClient().Get(context.Background(), fmt.Sprintf(global.KeyGatewayRefreshToken, usn)).Val()
|
||||
ts.Assert().Equal(rt, redisRt)
|
||||
}
|
||||
|
||||
func (ts *LoginTestSuite) TestLogin() {
|
||||
gin.SetMode(gin.TestMode)
|
||||
|
||||
ts.Run("ShouldBindJSON Failed", func() {
|
||||
w, c := utils.CreateTestContext("POST", "/", &LoginReq{
|
||||
Phone: "",
|
||||
Code: "",
|
||||
})
|
||||
Login(c)
|
||||
utils.AssertResponse(&ts.Suite, w, http.StatusBadRequest, http_resp.ParamError)
|
||||
})
|
||||
|
||||
ts.Run("UserNewClientLB Failed", func() {
|
||||
monkey.Patch(grpc_client.UserNewClientLB, func() (grpc_pb.UserClient, error) {
|
||||
return nil, assert.AnError
|
||||
})
|
||||
defer monkey.Unpatch(grpc_client.UserNewClientLB)
|
||||
|
||||
w, c := utils.CreateTestContext("POST", "/", &LoginReq{
|
||||
Phone: "13800000000",
|
||||
Code: "1234",
|
||||
})
|
||||
Login(c)
|
||||
utils.AssertResponse(&ts.Suite, w, http.StatusOK, http_resp.Failed)
|
||||
})
|
||||
|
||||
ts.Run("Login Failed", func() {
|
||||
ctrl := gomock.NewController(ts.T())
|
||||
defer ctrl.Finish()
|
||||
client := mocks.NewMockUserClient(ctrl)
|
||||
client.EXPECT().
|
||||
PhoneLogin(gomock.Any(), gomock.Any()).
|
||||
Return(nil, fmt.Errorf("gRPC failed"))
|
||||
|
||||
monkey.Patch(grpc_client.UserNewClientLB, func() (grpc_pb.UserClient, error) {
|
||||
return client, nil
|
||||
})
|
||||
defer monkey.Unpatch(grpc_client.UserNewClientLB)
|
||||
|
||||
w, c := utils.CreateTestContext("POST", "/", &LoginReq{
|
||||
Phone: "13800000000",
|
||||
Code: "1234",
|
||||
})
|
||||
Login(c)
|
||||
utils.AssertResponse(&ts.Suite, w, http.StatusOK, http_resp.Failed)
|
||||
})
|
||||
|
||||
ts.Run("OK", func() {
|
||||
ctrl := gomock.NewController(ts.T())
|
||||
defer ctrl.Finish()
|
||||
client := mocks.NewMockUserClient(ctrl)
|
||||
client.EXPECT().
|
||||
PhoneLogin(gomock.Any(), gomock.Any()).
|
||||
Return(&grpc_pb.PhoneLoginResp{USN: "1", Name: "hh"}, nil)
|
||||
|
||||
monkey.Patch(grpc_client.UserNewClientLB, func() (grpc_pb.UserClient, error) {
|
||||
return client, nil
|
||||
})
|
||||
defer monkey.Unpatch(grpc_client.UserNewClientLB)
|
||||
|
||||
w, c := utils.CreateTestContext("POST", "/", &LoginReq{
|
||||
Phone: "13800000000",
|
||||
Code: "1234",
|
||||
})
|
||||
Login(c)
|
||||
utils.AssertResponse(&ts.Suite, w, http.StatusOK, http_resp.OK)
|
||||
})
|
||||
}
|
||||
|
||||
func (ts *LoginTestSuite) TestRefreshToken() {
|
||||
gin.SetMode(gin.TestMode)
|
||||
|
||||
ts.Run("ShouldBindJSON Failed", func() {
|
||||
w, c := utils.CreateTestContext("POST", "/", &RefreshTokenReq{
|
||||
RefreshToken: "",
|
||||
})
|
||||
RefreshToken(c)
|
||||
utils.AssertResponse(&ts.Suite, w, http.StatusBadRequest, http_resp.ParamError)
|
||||
})
|
||||
|
||||
ts.Run("ParseToken Failed", func() {
|
||||
monkey.Patch(utils.ParseToken, func(tokenString string, secret string) (*utils.Claims, error) {
|
||||
return nil, assert.AnError
|
||||
})
|
||||
defer monkey.Unpatch(utils.ParseToken)
|
||||
|
||||
w, c := utils.CreateTestContext("POST", "/", &RefreshTokenReq{
|
||||
RefreshToken: "abc",
|
||||
})
|
||||
RefreshToken(c)
|
||||
utils.AssertResponse(&ts.Suite, w, http.StatusOK, http_resp.TokenInvalid)
|
||||
})
|
||||
|
||||
ts.Run("Redis Get Failed", func() {
|
||||
monkey.Patch(utils.ParseToken, func(tokenString string, secret string) (*utils.Claims, error) {
|
||||
if tokenString == "abc" {
|
||||
return &utils.Claims{USN: "1"}, nil
|
||||
}
|
||||
return nil, assert.AnError
|
||||
})
|
||||
defer monkey.Unpatch(utils.ParseToken)
|
||||
|
||||
redis.GetClient().Set(context.Background(), fmt.Sprintf(global.KeyGatewayRefreshToken, 1), "ab", redis2.KeepTTL)
|
||||
|
||||
w, c := utils.CreateTestContext("POST", "/", &RefreshTokenReq{
|
||||
RefreshToken: "abc",
|
||||
})
|
||||
RefreshToken(c)
|
||||
utils.AssertResponse(&ts.Suite, w, http.StatusOK, http_resp.TokenInvalid)
|
||||
})
|
||||
|
||||
ts.Run("OK", func() {
|
||||
monkey.Patch(utils.ParseToken, func(tokenString string, secret string) (*utils.Claims, error) {
|
||||
if tokenString == "abc" {
|
||||
return &utils.Claims{USN: "1"}, nil
|
||||
}
|
||||
return nil, assert.AnError
|
||||
})
|
||||
defer monkey.Unpatch(utils.ParseToken)
|
||||
|
||||
redis.GetClient().Set(context.Background(), fmt.Sprintf(global.KeyGatewayRefreshToken, 1), "abc", redis2.KeepTTL)
|
||||
|
||||
w, c := utils.CreateTestContext("POST", "/", &RefreshTokenReq{
|
||||
RefreshToken: "abc",
|
||||
})
|
||||
RefreshToken(c)
|
||||
utils.AssertResponse(&ts.Suite, w, http.StatusOK, http_resp.OK)
|
||||
})
|
||||
}
|
||||
|
||||
func TestLoginTestSuite(t *testing.T) {
|
||||
suite.Run(t, &LoginTestSuite{})
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package http_handler
|
||||
|
||||
import (
|
||||
"common/net/http/http_resp"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// 这个模块处理用户登录
|
||||
|
||||
type TestReq struct {
|
||||
}
|
||||
|
||||
type TestResp struct {
|
||||
Info string `json:"info"`
|
||||
}
|
||||
|
||||
func Test(c *gin.Context) {
|
||||
req := &TestReq{}
|
||||
if err := c.ShouldBindJSON(req); err != nil {
|
||||
http_resp.JsonBadRequest(c)
|
||||
return
|
||||
}
|
||||
|
||||
http_resp.JsonOK(c, http_resp.Success(&TestResp{
|
||||
Info: "成功了",
|
||||
}))
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
package ws_handler
|
||||
package client
|
||||
|
||||
import (
|
||||
"common/log"
|
||||
"common/net/socket"
|
||||
"context"
|
||||
"fmt"
|
||||
"git.hlsq.asia/mmorpg/service-common/db/redis"
|
||||
"git.hlsq.asia/mmorpg/service-common/log"
|
||||
"git.hlsq.asia/mmorpg/service-common/net/socket"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/global"
|
||||
"go.uber.org/zap"
|
||||
"runtime/debug"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
var GatewaySID int64
|
||||
|
||||
type Client struct {
|
||||
sync.WaitGroup
|
||||
conn socket.ISocketConn // Socket
|
||||
@@ -22,13 +22,14 @@ type Client struct {
|
||||
cancel context.CancelFunc // 取消上下文
|
||||
heartBeat time.Time // 最后一次心跳
|
||||
|
||||
USN int64 // 用户ID
|
||||
SceneSID int64 // 场景服ID
|
||||
InstanceID int32 // 副本ID,副本类型
|
||||
UniqueNo int64 // 副本唯一编号
|
||||
Status int32 // 状态:0 登陆中 1 正常 2 离线
|
||||
USN string // 用户ID
|
||||
SceneSID string // 场景服ID
|
||||
InstanceID int32 // 副本ID,副本类型
|
||||
UniqueNo string // 副本唯一编号
|
||||
}
|
||||
|
||||
func NewClient(usn int64, conn socket.ISocketConn) *Client {
|
||||
func NewClient(usn string, conn socket.ISocketConn) *Client {
|
||||
client := &Client{
|
||||
USN: usn,
|
||||
conn: conn,
|
||||
@@ -100,7 +101,9 @@ func (c *Client) onClose() {
|
||||
close(c.mailChan)
|
||||
c.mailChan = nil
|
||||
}
|
||||
c.Status = 2
|
||||
UserMgr.Delete(c.USN)
|
||||
redis.GetClient().HDel(c.ctx, fmt.Sprintf(global.KeyGatewayInfo, c.USN), global.HFieldInfoGatewaySID)
|
||||
c.onLeave()
|
||||
c.Done()
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package ws_handler
|
||||
package client
|
||||
|
||||
type Event interface {
|
||||
}
|
||||
@@ -11,3 +11,7 @@ type ClientEvent struct {
|
||||
type PongEvent struct {
|
||||
Event
|
||||
}
|
||||
|
||||
type SystemLoginSuccessEvent struct {
|
||||
Event
|
||||
}
|
||||
@@ -1,10 +1,13 @@
|
||||
package ws_handler
|
||||
package client
|
||||
|
||||
import (
|
||||
"common/net/grpc/service"
|
||||
"common/proto/sc/sc_pb"
|
||||
"common/proto/ss/grpc_pb"
|
||||
"gateway/internal/grpc_server/stream_client"
|
||||
"context"
|
||||
"fmt"
|
||||
"git.hlsq.asia/mmorpg/service-common/db/redis"
|
||||
"git.hlsq.asia/mmorpg/service-common/net/grpc/grpc_client"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/ss/ss_pb"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/global"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"time"
|
||||
)
|
||||
@@ -12,23 +15,23 @@ import (
|
||||
func (c *Client) handle(event Event) {
|
||||
switch e := event.(type) {
|
||||
case *ClientEvent:
|
||||
msg := &sc_pb.Message{}
|
||||
msg := &ss_pb.Message{}
|
||||
if err := proto.Unmarshal(e.Msg, msg); err != nil {
|
||||
c.logger.Errorf("handle event proto.Unmarshal err: %v", err)
|
||||
c.cancel()
|
||||
return
|
||||
}
|
||||
switch msg.ID {
|
||||
case sc_pb.MessageID_MESSAGE_ID_ENTER_INSTANCE:
|
||||
m := &sc_pb.C2S_EnterInstance{}
|
||||
case ss_pb.MessageID_MESSAGE_ID_ENTER_INSTANCE:
|
||||
m := &ss_pb.C2S_EnterInstance{}
|
||||
if err := proto.Unmarshal(msg.Payload, m); err != nil {
|
||||
c.logger.Errorf("handle event proto.Unmarshal err: %v", err)
|
||||
c.cancel()
|
||||
return
|
||||
}
|
||||
c.onEnter(m)
|
||||
case sc_pb.MessageID_MESSAGE_ID_ACTION:
|
||||
m := &sc_pb.C2S_Action{}
|
||||
case ss_pb.MessageID_MESSAGE_ID_ACTION:
|
||||
m := &ss_pb.C2S_Action{}
|
||||
if err := proto.Unmarshal(msg.Payload, m); err != nil {
|
||||
c.logger.Errorf("handle event proto.Unmarshal err: %v", err)
|
||||
c.cancel()
|
||||
@@ -38,18 +41,27 @@ func (c *Client) handle(event Event) {
|
||||
}
|
||||
case *PongEvent:
|
||||
c.heartBeat = time.Now()
|
||||
case *SystemLoginSuccessEvent:
|
||||
if c.Status == 0 {
|
||||
c.Status = 1
|
||||
UserMgr.Add(c.USN, c)
|
||||
redis.GetClient().HSet(c.ctx, fmt.Sprintf(global.KeyGatewayInfo, c.USN), global.HFieldInfoGatewaySID, global.GatewaySID)
|
||||
c.WriteMessage(ss_pb.MessageID_MESSAGE_ID_LOGIN_SUCCESS, &ss_pb.S2C_LoginSuccess{
|
||||
InstanceID: 1,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) onEnter(msg *sc_pb.C2S_EnterInstance) {
|
||||
client, err := service.SceneNewClientLB()
|
||||
func (c *Client) onEnter(msg *ss_pb.C2S_EnterInstance) {
|
||||
client, err := grpc_client.SceneNewClientLB()
|
||||
if err != nil {
|
||||
c.logger.Errorf("SceneNewClient err: %v", err)
|
||||
return
|
||||
}
|
||||
resp, err := client.Enter(c.ctx, &grpc_pb.EnterReq{
|
||||
USN: c.USN,
|
||||
GatewaySID: GatewaySID,
|
||||
GatewaySID: global.GatewaySID,
|
||||
InstanceID: msg.InstanceID,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -59,20 +71,21 @@ func (c *Client) onEnter(msg *sc_pb.C2S_EnterInstance) {
|
||||
c.SceneSID = resp.SceneSID
|
||||
c.UniqueNo = resp.UniqueNo
|
||||
c.InstanceID = msg.InstanceID
|
||||
c.WriteBytes(sc_pb.MessageID(resp.MessageID), resp.Payload)
|
||||
c.WriteBytes(ss_pb.MessageID(resp.MessageID), resp.Payload)
|
||||
}
|
||||
|
||||
func (c *Client) onLeave() {
|
||||
client, err := service.SceneNewClient(c.SceneSID)
|
||||
if c.SceneSID == "" {
|
||||
return
|
||||
}
|
||||
client, err := grpc_client.SceneNewClient(c.SceneSID)
|
||||
if err != nil {
|
||||
c.logger.Errorf("SceneNewClient err: %v", err)
|
||||
return
|
||||
}
|
||||
_, err = client.Leave(c.ctx, &grpc_pb.LeaveReq{
|
||||
USN: c.USN,
|
||||
GatewaySID: GatewaySID,
|
||||
InstanceID: c.InstanceID,
|
||||
UniqueNo: c.UniqueNo,
|
||||
_, err = client.Leave(context.Background(), &grpc_pb.LeaveReq{
|
||||
USN: c.USN,
|
||||
UniqueNo: c.UniqueNo,
|
||||
})
|
||||
if err != nil {
|
||||
c.logger.Errorf("leave err: %v", err)
|
||||
@@ -80,11 +93,11 @@ func (c *Client) onLeave() {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) onAction(msg *sc_pb.C2S_Action) {
|
||||
if c.SceneSID == 0 {
|
||||
func (c *Client) onAction(msg *ss_pb.C2S_Action) {
|
||||
if c.SceneSID == "" {
|
||||
return
|
||||
}
|
||||
if err := stream_client.SendMessageToScene(c.SceneSID, stream_client.FunAction, &grpc_pb.ActionReq{
|
||||
if err := grpc_client.SendMessageToScene(c.SceneSID, grpc_client.FunAction, &grpc_pb.ActionReq{
|
||||
UniqueNo: c.UniqueNo,
|
||||
USN: c.USN,
|
||||
Action: int32(msg.Action),
|
||||
@@ -93,5 +106,6 @@ func (c *Client) onAction(msg *sc_pb.C2S_Action) {
|
||||
SkillID: msg.SkillID,
|
||||
}); err != nil {
|
||||
c.logger.Errorf("send action err: %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package ws_handler
|
||||
package client
|
||||
|
||||
import (
|
||||
"common/proto/sc/sc_pb"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/ss/ss_pb"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// WriteMessage 向客户端发送消息
|
||||
func (c *Client) WriteMessage(id sc_pb.MessageID, data proto.Message) {
|
||||
func (c *Client) WriteMessage(id ss_pb.MessageID, data proto.Message) {
|
||||
if c.conn == nil || c.conn.IsClose() {
|
||||
return
|
||||
}
|
||||
@@ -15,7 +15,7 @@ func (c *Client) WriteMessage(id sc_pb.MessageID, data proto.Message) {
|
||||
c.logger.Errorf("WriteMessage proto.Marshal err: %v", err)
|
||||
return
|
||||
}
|
||||
m, err := proto.Marshal(&sc_pb.Message{
|
||||
m, err := proto.Marshal(&ss_pb.Message{
|
||||
ID: id,
|
||||
Payload: d,
|
||||
})
|
||||
@@ -29,11 +29,11 @@ func (c *Client) WriteMessage(id sc_pb.MessageID, data proto.Message) {
|
||||
}
|
||||
|
||||
// WriteBytes 向客户端发送字节数据
|
||||
func (c *Client) WriteBytes(id sc_pb.MessageID, data []byte) {
|
||||
func (c *Client) WriteBytes(id ss_pb.MessageID, data []byte) {
|
||||
if c.conn == nil || c.conn.IsClose() {
|
||||
return
|
||||
}
|
||||
m, err := proto.Marshal(&sc_pb.Message{
|
||||
m, err := proto.Marshal(&ss_pb.Message{
|
||||
ID: id,
|
||||
Payload: data,
|
||||
})
|
||||
@@ -1,39 +1,42 @@
|
||||
package ws_handler
|
||||
package client
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/global"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var UserMgr *userManager
|
||||
|
||||
type userManager struct {
|
||||
userMap map[int64]*Client
|
||||
userMap map[string]*Client
|
||||
sync.RWMutex
|
||||
}
|
||||
|
||||
func init() {
|
||||
UserMgr = &userManager{
|
||||
userMap: make(map[int64]*Client),
|
||||
userMap: make(map[string]*Client),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *userManager) Add(usn int64, client *Client) {
|
||||
func (m *userManager) Add(usn string, client *Client) {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
m.userMap[usn] = client
|
||||
global.OnlineUsersGauge.Inc()
|
||||
}
|
||||
|
||||
func (m *userManager) Delete(usn int64) {
|
||||
func (m *userManager) Delete(usn string) {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
delete(m.userMap, usn)
|
||||
global.OnlineUsersGauge.Dec()
|
||||
}
|
||||
|
||||
func (m *userManager) GetAll() map[int64]*Client {
|
||||
func (m *userManager) GetAll() map[string]*Client {
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
|
||||
copyMap := make(map[int64]*Client, len(m.userMap))
|
||||
copyMap := make(map[string]*Client, len(m.userMap))
|
||||
for k, v := range m.userMap {
|
||||
copyMap[k] = v
|
||||
}
|
||||
@@ -51,8 +54,14 @@ func (m *userManager) GetAllInterface() []interface{} {
|
||||
return r
|
||||
}
|
||||
|
||||
func (m *userManager) GetByUSN(usn int64) *Client {
|
||||
func (m *userManager) GetByUSN(usn string) *Client {
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
return m.userMap[usn]
|
||||
}
|
||||
|
||||
func (m *userManager) GetSize() int32 {
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
return int32(len(m.userMap))
|
||||
}
|
||||
181
internal/handler/ws_handler/login/login.go
Normal file
181
internal/handler/ws_handler/login/login.go
Normal file
@@ -0,0 +1,181 @@
|
||||
package login
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"git.hlsq.asia/mmorpg/service-common/db/redis"
|
||||
"git.hlsq.asia/mmorpg/service-common/log"
|
||||
"git.hlsq.asia/mmorpg/service-common/net/grpc/grpc_client"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/ss/ss_pb"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/global"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/handler/ws_handler/client"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
var loginQueue *Login
|
||||
|
||||
// Login 登录队列结构
|
||||
type Login struct {
|
||||
queue chan *User // 用户队列
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc
|
||||
wg sync.WaitGroup
|
||||
}
|
||||
|
||||
type User struct {
|
||||
Cli *client.Client
|
||||
Token string
|
||||
}
|
||||
|
||||
func NewLoginQueue(maxSize int) *Login {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
loginQueue = &Login{
|
||||
queue: make(chan *User, maxSize),
|
||||
ctx: ctx,
|
||||
cancel: cancel,
|
||||
}
|
||||
return loginQueue
|
||||
}
|
||||
|
||||
func GetLoginQueue() *Login {
|
||||
return loginQueue
|
||||
}
|
||||
|
||||
// AddToLoginQueue 添加到登录队列
|
||||
func (l *Login) AddToLoginQueue(user *User) bool {
|
||||
select {
|
||||
case l.queue <- user:
|
||||
return true
|
||||
default:
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (l *Login) Start(num int) {
|
||||
for i := 0; i < num; i++ {
|
||||
l.wg.Add(1)
|
||||
go func() {
|
||||
defer l.wg.Done()
|
||||
for {
|
||||
select {
|
||||
case <-l.ctx.Done():
|
||||
return
|
||||
case user, ok := <-l.queue:
|
||||
if ok {
|
||||
l.StartLogin(user)
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
// 定时从排队的队列中取用户
|
||||
l.wg.Add(1)
|
||||
go func() {
|
||||
defer l.wg.Done()
|
||||
tick := time.NewTicker(1 * time.Second)
|
||||
for {
|
||||
select {
|
||||
case <-tick.C:
|
||||
for {
|
||||
if client.UserMgr.GetSize() < global.MaxOnlineSize {
|
||||
cli, err := GetQueueUp().Dequeue()
|
||||
if err != nil {
|
||||
log.Errorf("dequeue err: %v", err)
|
||||
return
|
||||
}
|
||||
if cli == nil {
|
||||
break
|
||||
}
|
||||
l.LoginSuccess(cli)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
case <-l.ctx.Done():
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func (l *Login) Stop() {
|
||||
l.cancel()
|
||||
l.wg.Wait()
|
||||
}
|
||||
|
||||
// StartLogin 开始登录流程
|
||||
func (l *Login) StartLogin(user *User) {
|
||||
if !l.CheckToken(user) {
|
||||
user.Cli.WriteMessage(ss_pb.MessageID_MESSAGE_ID_KICK_OUT, &ss_pb.S2C_KickOut{
|
||||
ID: ss_pb.KickOutID_KICK_OUT_ID_TOKEN_INVALID,
|
||||
})
|
||||
user.Cli.CloseClient()
|
||||
return
|
||||
}
|
||||
if gatewaySID := l.CheckOnline(user); len(gatewaySID) > 0 {
|
||||
// 如果在线就要踢,如果踢失败了就返回服务器繁忙,一般不应该走到这里
|
||||
if !l.KickUser(user.Cli.SceneSID, user.Cli.USN) {
|
||||
user.Cli.WriteMessage(ss_pb.MessageID_MESSAGE_ID_KICK_OUT, &ss_pb.S2C_KickOut{
|
||||
ID: ss_pb.KickOutID_KICK_OUT_ID_SERVER_BUSY,
|
||||
})
|
||||
user.Cli.CloseClient()
|
||||
return
|
||||
}
|
||||
}
|
||||
if client.UserMgr.GetSize() >= global.MaxOnlineSize {
|
||||
// 如果人数满了就排队
|
||||
if err := GetQueueUp().Enqueue(user.Cli); err != nil {
|
||||
user.Cli.WriteMessage(ss_pb.MessageID_MESSAGE_ID_KICK_OUT, &ss_pb.S2C_KickOut{
|
||||
ID: ss_pb.KickOutID_KICK_OUT_ID_QUEUE_UP_FULL,
|
||||
})
|
||||
user.Cli.CloseClient()
|
||||
return
|
||||
}
|
||||
// 告诉客户端正在排队
|
||||
position, ok := GetQueueUp().GetPosition(user.Cli.USN)
|
||||
if !ok {
|
||||
user.Cli.WriteMessage(ss_pb.MessageID_MESSAGE_ID_KICK_OUT, &ss_pb.S2C_KickOut{
|
||||
ID: ss_pb.KickOutID_KICK_OUT_ID_SERVER_BUSY,
|
||||
})
|
||||
user.Cli.CloseClient()
|
||||
return
|
||||
}
|
||||
user.Cli.WriteMessage(ss_pb.MessageID_MESSAGE_ID_QUEUE_UP, &ss_pb.S2C_QueueUp{
|
||||
QueueUpCount: int32(position),
|
||||
})
|
||||
} else {
|
||||
l.LoginSuccess(user.Cli)
|
||||
}
|
||||
}
|
||||
|
||||
// CheckToken 校验Token是否有效
|
||||
func (l *Login) CheckToken(user *User) bool {
|
||||
return redis.GetClient().Get(l.ctx, fmt.Sprintf(global.KeyGatewayAccessToken, user.Cli.USN)).Val() == user.Token
|
||||
}
|
||||
|
||||
// CheckOnline 校验是否在线
|
||||
func (l *Login) CheckOnline(user *User) string {
|
||||
return redis.GetClient().HGet(l.ctx, fmt.Sprintf(global.KeyGatewayInfo, user.Cli.USN), global.HFieldInfoGatewaySID).Val()
|
||||
}
|
||||
|
||||
// KickUser 把玩家踢下线
|
||||
func (l *Login) KickUser(gatewaySID string, usn string) bool {
|
||||
gc, err := grpc_client.GatewayNewClient(gatewaySID)
|
||||
if err != nil {
|
||||
log.Errorf("KickUser cannot find gateway client: %v, sid: %v", err, gatewaySID)
|
||||
return false
|
||||
}
|
||||
_, err = gc.KickUser(l.ctx, &grpc_pb.KickUserReq{USN: usn})
|
||||
if err != nil {
|
||||
log.Errorf("KickUser err: %v, sid: %v, usn: %v", err, gatewaySID, usn)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// LoginSuccess 登录成功
|
||||
func (l *Login) LoginSuccess(user *client.Client) {
|
||||
user.OnEvent(&client.SystemLoginSuccessEvent{})
|
||||
}
|
||||
104
internal/handler/ws_handler/login/queue_up.go
Normal file
104
internal/handler/ws_handler/login/queue_up.go
Normal file
@@ -0,0 +1,104 @@
|
||||
package login
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/handler/ws_handler/client"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
var queueUp *QueueUp
|
||||
|
||||
// QueueUp 排队队列结构
|
||||
type QueueUp struct {
|
||||
queue chan *QueueUser // 用户队列
|
||||
waiting sync.Map // map[usn]*QueueUser
|
||||
minTicket atomic.Int64 // 最小的Ticket
|
||||
maxTicket atomic.Int64 // 最大的Ticket
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc
|
||||
}
|
||||
|
||||
type QueueUser struct {
|
||||
Cli *client.Client
|
||||
Ticket int64
|
||||
}
|
||||
|
||||
func NewQueueUp(maxSize int) *QueueUp {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
queueUp = &QueueUp{
|
||||
queue: make(chan *QueueUser, maxSize),
|
||||
ctx: ctx,
|
||||
cancel: cancel,
|
||||
}
|
||||
return queueUp
|
||||
}
|
||||
|
||||
func GetQueueUp() *QueueUp {
|
||||
return queueUp
|
||||
}
|
||||
|
||||
// Enqueue 将用户加入排队队列
|
||||
func (q *QueueUp) Enqueue(cli *client.Client) error {
|
||||
select {
|
||||
case <-q.ctx.Done():
|
||||
return errors.New("queue stopped")
|
||||
default:
|
||||
}
|
||||
|
||||
ticket := q.maxTicket.Add(1)
|
||||
item := &QueueUser{Cli: cli, Ticket: ticket}
|
||||
|
||||
select {
|
||||
case q.queue <- item:
|
||||
q.waiting.Store(cli.USN, item)
|
||||
return nil
|
||||
default:
|
||||
return errors.New("queue is full")
|
||||
}
|
||||
}
|
||||
|
||||
// Dequeue 从排队队列中取出下一个有效用户
|
||||
func (q *QueueUp) Dequeue() (*client.Client, error) {
|
||||
select {
|
||||
case item, ok := <-q.queue:
|
||||
if ok {
|
||||
q.minTicket.Store(item.Ticket)
|
||||
if _, loaded := q.waiting.LoadAndDelete(item.Cli.USN); loaded {
|
||||
return item.Cli, nil
|
||||
}
|
||||
return q.Dequeue()
|
||||
}
|
||||
case <-q.ctx.Done():
|
||||
return nil, q.ctx.Err()
|
||||
default:
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// GetPosition 返回用户前面还有多少人在排队
|
||||
func (q *QueueUp) GetPosition(usn string) (int64, bool) {
|
||||
val, ok := q.waiting.Load(usn)
|
||||
if !ok {
|
||||
return 0, false
|
||||
}
|
||||
user := val.(*QueueUser)
|
||||
return user.Ticket - q.minTicket.Load() - 1, true
|
||||
}
|
||||
|
||||
// RemoveUser 安全移除用户(标记为取消)
|
||||
func (q *QueueUp) RemoveUser(usn string) bool {
|
||||
_, loaded := q.waiting.LoadAndDelete(usn)
|
||||
return loaded
|
||||
}
|
||||
|
||||
// GetQueueSize 获取当前排队人数
|
||||
func (q *QueueUp) GetQueueSize() int {
|
||||
return len(q.queue)
|
||||
}
|
||||
|
||||
// Stop 停止整个队列服务
|
||||
func (q *QueueUp) Stop() {
|
||||
q.cancel()
|
||||
}
|
||||
@@ -1,14 +1,13 @@
|
||||
package http_gateway
|
||||
|
||||
import (
|
||||
"common/net/http/http_resp"
|
||||
"common/utils"
|
||||
"fmt"
|
||||
"gateway/config"
|
||||
"git.hlsq.asia/mmorpg/service-common/net/http/http_resp"
|
||||
"git.hlsq.asia/mmorpg/service-common/utils"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/config"
|
||||
"github.com/gin-contrib/cors"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@@ -29,9 +28,11 @@ func ginLogger(logger *zap.SugaredLogger) gin.HandlerFunc {
|
||||
path := c.Request.URL.Path
|
||||
c.Next()
|
||||
cost := time.Since(start)
|
||||
usn, _ := c.Get("usn")
|
||||
|
||||
logger.Infof(fmt.Sprintf(
|
||||
"HTTP Method:%v Code:%v Time:%v IP:%v Path:%v",
|
||||
"[usn:%v] Method:%v Code:%v Time:%v IP:%v Path:%v",
|
||||
usn,
|
||||
c.Request.Method,
|
||||
c.Writer.Status(),
|
||||
cost,
|
||||
@@ -43,14 +44,14 @@ func ginLogger(logger *zap.SugaredLogger) gin.HandlerFunc {
|
||||
|
||||
func authJwt() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
// 如果是Public接口,有Token就读,没有就算了
|
||||
public := false
|
||||
for _, path := range config.PublicPaths {
|
||||
if strings.HasPrefix(c.Request.URL.Path, path) {
|
||||
public = true
|
||||
break
|
||||
}
|
||||
pList := strings.SplitN(c.Request.URL.Path, "/", 4)
|
||||
if len(pList) < 4 || pList[2] == "" {
|
||||
http_resp.JsonNotFound(c)
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
// 如果是Public接口,有Token就读,没有就算了
|
||||
public := pList[2] == "open"
|
||||
|
||||
token := strings.TrimPrefix(c.GetHeader("Authorization"), "Bearer ")
|
||||
if token == "" {
|
||||
@@ -58,21 +59,21 @@ func authJwt() gin.HandlerFunc {
|
||||
c.Next()
|
||||
return
|
||||
}
|
||||
http_resp.AbortUnauthorized(c)
|
||||
http_resp.JsonUnauthorized(c)
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
claims, err := utils.ParseToken(token, config.Get().Auth.Secret)
|
||||
if err != nil {
|
||||
if public {
|
||||
c.Next()
|
||||
return
|
||||
}
|
||||
http_resp.AbortUnauthorized(c)
|
||||
http_resp.JsonUnauthorized(c)
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
// 这里将Header写到请求中,grpc-gateway框架会读取然后传给grpc服务
|
||||
c.Request.Header.Set("X-Usn", strconv.Itoa(int(claims.USN)))
|
||||
c.Request.Header.Set("X-Usn", claims.USN)
|
||||
// 这里写到上下文中,打日志
|
||||
c.Set("usn", claims.USN)
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
package http_gateway
|
||||
|
||||
import (
|
||||
"common/log"
|
||||
"common/net/grpc/service"
|
||||
"common/net/http/http_resp"
|
||||
"common/proto/ss/grpc_pb"
|
||||
"context"
|
||||
"gateway/internal/handler/http_handler"
|
||||
"gateway/internal/net/http_gateway/wrapper"
|
||||
"git.hlsq.asia/mmorpg/service-common/discover/common"
|
||||
"git.hlsq.asia/mmorpg/service-common/log"
|
||||
"git.hlsq.asia/mmorpg/service-common/net/grpc/grpc_client"
|
||||
"git.hlsq.asia/mmorpg/service-common/net/http/http_resp"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/handler/http_handler"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/net/http_gateway/wrapper"
|
||||
"github.com/gin-contrib/cors"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
"go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
)
|
||||
|
||||
@@ -47,37 +49,41 @@ func InitRouter() *gin.Engine {
|
||||
gin.Recovery(),
|
||||
ginLogger(log.GetLogger().Named("GIN")),
|
||||
cors.New(corsConfig()),
|
||||
otelgin.Middleware(common.KeyDiscoverServiceNameGateway),
|
||||
)
|
||||
|
||||
r.HandleMethodNotAllowed = true
|
||||
r.NoMethod(func(c *gin.Context) {
|
||||
http_resp.JsonMethodNotAllowed(c)
|
||||
c.Abort()
|
||||
})
|
||||
r.NoRoute(func(c *gin.Context) {
|
||||
http_resp.JsonNotFound(c)
|
||||
c.Abort()
|
||||
})
|
||||
|
||||
initBaseRoute(r.Group("/"))
|
||||
|
||||
auth := r.Group("/")
|
||||
auth.Use(authJwt())
|
||||
|
||||
// 网关
|
||||
initBaseRoute(auth)
|
||||
// 用户中心
|
||||
initUserPath(auth)
|
||||
// 奇怪的知识-服务端
|
||||
initQgdzsPath(auth)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func initBaseRoute(r *gin.RouterGroup) {
|
||||
g := r.Group("/gw")
|
||||
g.POST("/login", http_handler.Login)
|
||||
g.POST("/refresh_token", http_handler.RefreshToken)
|
||||
g.GET("/test", http_handler.Test)
|
||||
g.POST("/open/login", http_handler.Login)
|
||||
g.POST("/open/refresh_token", http_handler.RefreshToken)
|
||||
}
|
||||
|
||||
func initUserPath(r *gin.RouterGroup) {
|
||||
g := r.Group("/user")
|
||||
client, err := service.UserNewClientLB()
|
||||
client, err := grpc_client.UserNewClientLB()
|
||||
if err != nil {
|
||||
log.Errorf("get user conn failed: %v", err)
|
||||
return
|
||||
@@ -91,3 +97,20 @@ func initUserPath(r *gin.RouterGroup) {
|
||||
|
||||
g.Any("/*path", gin.WrapH(gwMux))
|
||||
}
|
||||
|
||||
func initQgdzsPath(r *gin.RouterGroup) {
|
||||
g := r.Group("/qgdzs")
|
||||
client, err := grpc_client.QgdzsNewClientLB()
|
||||
if err != nil {
|
||||
log.Errorf("get qgdzs conn failed: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
gwMux := InitServeMux()
|
||||
if err = grpc_pb.RegisterQgdzsHandlerClient(context.Background(), gwMux, client); err != nil {
|
||||
log.Errorf("RegisterQgdzsHandlerClient err: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
g.Any("/*path", gin.WrapH(gwMux))
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package wrapper
|
||||
|
||||
import (
|
||||
"common/net/http/http_resp"
|
||||
"common/proto/ss/ss_common"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"git.hlsq.asia/mmorpg/service-common/net/http/http_resp"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/rs/rs_common"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
@@ -23,7 +23,7 @@ func ErrorHandler(_ context.Context, _ *runtime.ServeMux, _ runtime.Marshaler, w
|
||||
|
||||
code, msg := 0, ""
|
||||
for _, detail := range st.Details() {
|
||||
if errorInfo, ok := detail.(*ss_common.ErrorInfo); ok {
|
||||
if errorInfo, ok := detail.(*rs_common.ErrorInfo); ok {
|
||||
code = int(errorInfo.Code)
|
||||
msg = errorInfo.Msg
|
||||
break
|
||||
@@ -33,11 +33,12 @@ func ErrorHandler(_ context.Context, _ *runtime.ServeMux, _ runtime.Marshaler, w
|
||||
code = http_resp.Failed.Code()
|
||||
msg = http_resp.Failed.Error()
|
||||
}
|
||||
if st.Code() == codes.Unknown ||
|
||||
st.Code() == codes.Unimplemented ||
|
||||
st.Code() == codes.NotFound {
|
||||
if st.Code() == codes.Unknown || st.Code() == codes.Unimplemented || st.Code() == codes.NotFound {
|
||||
msg = st.Message()
|
||||
}
|
||||
if st.Code() == codes.NotFound {
|
||||
code = http_resp.NotFound.Code()
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(grpcCodeToHTTPCode(st.Code()))
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package wrapper
|
||||
|
||||
import (
|
||||
"common/net/http/http_resp"
|
||||
"encoding/json"
|
||||
"git.hlsq.asia/mmorpg/service-common/net/http/http_resp"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
"io"
|
||||
)
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
package ws_gateway
|
||||
|
||||
import (
|
||||
"common/log"
|
||||
"common/net/socket"
|
||||
"common/utils"
|
||||
"fmt"
|
||||
"gateway/internal/handler/ws_handler"
|
||||
"git.hlsq.asia/mmorpg/service-common/log"
|
||||
"git.hlsq.asia/mmorpg/service-common/net/socket"
|
||||
"git.hlsq.asia/mmorpg/service-common/utils"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/config"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/handler/ws_handler/client"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/handler/ws_handler/login"
|
||||
"go.uber.org/zap"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -20,49 +21,42 @@ func (g *GatewayWsServer) OnOpen(conn socket.ISocketConn) ([]byte, socket.Action
|
||||
return nil, socket.None
|
||||
}
|
||||
|
||||
func (g *GatewayWsServer) OnHandShake(conn socket.ISocketConn, bytes []byte, callback func(conn socket.ISocketConn, bytes []byte)) socket.Action {
|
||||
func (g *GatewayWsServer) OnHandShake(conn socket.ISocketConn) socket.Action {
|
||||
token, ok := conn.GetParam("token").(string)
|
||||
if !ok {
|
||||
g.logger.Warnf("token is not string")
|
||||
g.logger.Warnf("token is invalid")
|
||||
return socket.Close
|
||||
}
|
||||
//claims, err := utils.ParseToken(token, config.Get().Auth.Secret)
|
||||
//if err != nil {
|
||||
// g.logger.Warnf("token is invalid")
|
||||
// return socket.Close
|
||||
//}
|
||||
|
||||
t, _ := strconv.Atoi(token)
|
||||
claims := utils.Claims{
|
||||
USN: int64(t),
|
||||
claims, err := utils.ParseToken(token, config.Get().Auth.Secret)
|
||||
if err != nil {
|
||||
g.logger.Warnf("token is invalid")
|
||||
return socket.Close
|
||||
}
|
||||
|
||||
cli := client.NewClient(claims.USN, conn)
|
||||
conn.SetParam("client", cli)
|
||||
if !login.GetLoginQueue().AddToLoginQueue(&login.User{Cli: cli, Token: token}) {
|
||||
g.logger.Warnf("AddToLoginQueue err, login queue full, usn: %v", claims.USN)
|
||||
return socket.Close
|
||||
}
|
||||
go func(shResp []byte) {
|
||||
if oldClient := ws_handler.UserMgr.GetByUSN(claims.USN); oldClient != nil {
|
||||
oldClient.CloseClient()
|
||||
}
|
||||
client := ws_handler.NewClient(claims.USN, conn)
|
||||
ws_handler.UserMgr.Add(claims.USN, client)
|
||||
conn.SetParam("client", client)
|
||||
callback(conn, shResp)
|
||||
}(bytes)
|
||||
return socket.None
|
||||
}
|
||||
|
||||
func (g *GatewayWsServer) OnMessage(conn socket.ISocketConn, bytes []byte) socket.Action {
|
||||
client, ok := conn.GetParam("client").(*ws_handler.Client)
|
||||
if !ok || client.USN == 0 {
|
||||
cli, ok := conn.GetParam("client").(*client.Client)
|
||||
if !ok || cli.USN == "" || cli.Status != 1 {
|
||||
return socket.Close
|
||||
}
|
||||
client.OnEvent(&ws_handler.ClientEvent{Msg: bytes})
|
||||
cli.OnEvent(&client.ClientEvent{Msg: bytes})
|
||||
return socket.None
|
||||
}
|
||||
|
||||
func (g *GatewayWsServer) OnPong(conn socket.ISocketConn) {
|
||||
client, ok := conn.GetParam("client").(*ws_handler.Client)
|
||||
if !ok || client.USN == 0 {
|
||||
cli, ok := conn.GetParam("client").(*client.Client)
|
||||
if !ok || cli.USN == "" {
|
||||
return
|
||||
}
|
||||
client.OnEvent(&ws_handler.PongEvent{})
|
||||
cli.OnEvent(&client.PongEvent{})
|
||||
}
|
||||
|
||||
func (g *GatewayWsServer) OnClose(_ socket.ISocketConn, _ error) socket.Action {
|
||||
|
||||
53
internal/testutil/suite.go
Normal file
53
internal/testutil/suite.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package testutil
|
||||
|
||||
import (
|
||||
config2 "git.hlsq.asia/mmorpg/service-common/config"
|
||||
"git.hlsq.asia/mmorpg/service-common/db/redis"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/config"
|
||||
"github.com/alicebob/miniredis/v2"
|
||||
"github.com/stretchr/testify/suite"
|
||||
)
|
||||
|
||||
type TestSuite struct {
|
||||
suite.Suite
|
||||
redis *miniredis.Miniredis
|
||||
}
|
||||
|
||||
// SetupSuite 在整个测试套件开始前运行一次
|
||||
func (ts *TestSuite) SetupSuite() {
|
||||
// Redis
|
||||
r, err := miniredis.Run()
|
||||
ts.Require().NoError(err)
|
||||
ts.redis = r
|
||||
|
||||
// Config
|
||||
config.Set(&config.Config{
|
||||
DB: &config2.DBConfig{
|
||||
Redis: &config2.RedisConfig{
|
||||
Addr: r.Addr(),
|
||||
},
|
||||
},
|
||||
Auth: &config.AuthConfig{
|
||||
Secret: "test",
|
||||
ShortExpire: 15,
|
||||
LongExpire: 10080,
|
||||
},
|
||||
})
|
||||
|
||||
ts.Require().NoError(redis.Init(config.Get().DB.Redis))
|
||||
}
|
||||
|
||||
// TearDownSuite 在整个测试套件结束后运行一次
|
||||
func (ts *TestSuite) TearDownSuite() {
|
||||
if ts.redis != nil {
|
||||
ts.redis.Close()
|
||||
}
|
||||
}
|
||||
|
||||
// SetupTest 在每个测试用例前运行
|
||||
func (ts *TestSuite) SetupTest() {
|
||||
}
|
||||
|
||||
// TearDownTest 在每个测试用例后运行
|
||||
func (ts *TestSuite) TearDownTest() {
|
||||
}
|
||||
Reference in New Issue
Block a user