Compare commits
48 Commits
3350d7b759
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| fc9b32b115 | |||
| ec4c3c0413 | |||
| 456f1970eb | |||
| b1dfb88f71 | |||
| a7266f4bfa | |||
| 2ea538995a | |||
| 174cd09ba6 | |||
| 62ebfa17ea | |||
| 8de7ab4a67 | |||
| 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 | |||
| 887cb242e3 | |||
| ebeb244e1e |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.idea
|
||||
*/.idea
|
||||
70
app/app.go
Normal file
70
app/app.go
Normal file
@@ -0,0 +1,70 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"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.Module // 模块列表
|
||||
}
|
||||
|
||||
func (p *Program) Init(_ svc.Environment) error {
|
||||
p.moduleList = append(p.moduleList, &module.Log{Cfg: config.Get().Log})
|
||||
p.moduleList = append(p.moduleList, &module.DB{Cfg: config.Get().DB, AppName: config.Get().App.Name})
|
||||
p.moduleList = append(p.moduleList, &module.Snowflake{})
|
||||
p.moduleList = append(p.moduleList, &ModuleWebServer{})
|
||||
p.moduleList = append(p.moduleList, &ModuleWebsocketServer{})
|
||||
p.moduleList = append(p.moduleList, &ModuleLoginQueue{})
|
||||
p.moduleList = append(p.moduleList, &module.Grpc{Server: grpc_server.NewServer(config.Get().Serve.Grpc)})
|
||||
p.moduleList = append(p.moduleList, &module.Prometheus{Cfg: config.Get().Metric})
|
||||
p.moduleList = append(p.moduleList, &module.Tracer{Cfg: config.Get().Metric, ServiceName: common.KeyDiscoverServiceNameGateway})
|
||||
p.moduleList = append(p.moduleList, &module.Discover{})
|
||||
|
||||
for _, m := range p.moduleList {
|
||||
if err := m.Init(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
log.Infof(fmt.Sprintf("%v Init successful...", config.Get().App.Name))
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Program) Start() error {
|
||||
ready := &sync.WaitGroup{}
|
||||
ready.Add(len(p.moduleList))
|
||||
for _, m := range p.moduleList {
|
||||
if err := m.Start(ready); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
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 {
|
||||
for i := len(p.moduleList) - 1; i >= 0; i-- {
|
||||
m := p.moduleList[i]
|
||||
if err := m.Stop(); err != nil {
|
||||
log.Errorf("module stop error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
log.Infof(fmt.Sprintf("%v Stop successful...", config.Get().App.Name))
|
||||
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
|
||||
}
|
||||
50
app/web.go
Normal file
50
app/web.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"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 {
|
||||
m.wg = &sync.WaitGroup{}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ModuleWebServer) Start(ready *sync.WaitGroup) error {
|
||||
m.wg.Add(1)
|
||||
go func() {
|
||||
defer m.wg.Done()
|
||||
m.server = &http.Server{
|
||||
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())
|
||||
}
|
||||
log.Infof("http server stop.")
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ModuleWebServer) Stop() error {
|
||||
if err := m.server.Shutdown(context.Background()); err != nil {
|
||||
log.Errorf("stop http server failed: %v", err)
|
||||
}
|
||||
m.wg.Wait()
|
||||
return nil
|
||||
}
|
||||
59
app/websocket.go
Normal file
59
app/websocket.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"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"
|
||||
)
|
||||
|
||||
// ModuleWebsocketServer Websocket服务模块
|
||||
type ModuleWebsocketServer struct {
|
||||
module.DefaultModule
|
||||
wg *sync.WaitGroup
|
||||
server *websocket.WSServer
|
||||
}
|
||||
|
||||
func (m *ModuleWebsocketServer) Init() error {
|
||||
m.wg = &sync.WaitGroup{}
|
||||
m.server = websocket.NewWSServer(
|
||||
&ws_gateway.GatewayWsServer{},
|
||||
log.GetLogger().Named("ws_server"),
|
||||
5*time.Second,
|
||||
)
|
||||
return nil
|
||||
}
|
||||
|
||||
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,
|
||||
0,
|
||||
gnet.TCPNoDelay,
|
||||
64*1024,
|
||||
64*1024,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
log.GetLogger().Named("GNET"),
|
||||
)
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ModuleWebsocketServer) Stop() error {
|
||||
if err := m.server.Stop(); err != nil {
|
||||
log.Errorf("stop websocket server failed: %v", err)
|
||||
}
|
||||
m.wg.Wait()
|
||||
return nil
|
||||
}
|
||||
44
config/config.dev.yaml
Normal file
44
config/config.dev.yaml
Normal file
@@ -0,0 +1,44 @@
|
||||
app:
|
||||
name: "gateway-dev"
|
||||
|
||||
log:
|
||||
debug: true
|
||||
level: "debug"
|
||||
maxSize: 10
|
||||
maxBackups: 100
|
||||
maxAge: 7
|
||||
|
||||
metric:
|
||||
prometheus:
|
||||
address: "0.0.0.0"
|
||||
port: 18504
|
||||
jaeger:
|
||||
endpoint: "127.0.0.1:4317"
|
||||
|
||||
db:
|
||||
etcd:
|
||||
endpoints: [ "127.0.0.1:2379" ]
|
||||
redis:
|
||||
addr: "127.0.0.1:6379"
|
||||
password: "lQ7aM8oB6lK0iD5k"
|
||||
db: 0
|
||||
|
||||
serve:
|
||||
grpc:
|
||||
address: "127.0.0.1"
|
||||
port: 18500
|
||||
ttl: 20
|
||||
socket:
|
||||
web:
|
||||
address: "0.0.0.0"
|
||||
port: 18501
|
||||
raw:
|
||||
address: "0.0.0.0"
|
||||
port: 18502
|
||||
http:
|
||||
address: "0.0.0.0"
|
||||
port: 18503
|
||||
|
||||
auth:
|
||||
shortExpire: 3600
|
||||
longExpire: 604800
|
||||
36
config/config.go
Normal file
36
config/config.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package config
|
||||
|
||||
import "git.hlsq.asia/mmorpg/service-common/config"
|
||||
|
||||
const path = "./config"
|
||||
|
||||
type Config struct {
|
||||
App *config.AppConfig `yaml:"app"`
|
||||
Log *config.LogConfig `yaml:"log"`
|
||||
Metric *config.MetricConfig `yaml:"metric"`
|
||||
DB *config.DBConfig `yaml:"db"`
|
||||
Serve *config.ServeConfig `yaml:"serve"`
|
||||
Auth *AuthConfig `yaml:"auth"`
|
||||
}
|
||||
|
||||
type AuthConfig struct {
|
||||
ShortExpire int64 `yaml:"shortExpire"`
|
||||
LongExpire int64 `yaml:"longExpire"`
|
||||
}
|
||||
|
||||
var cfg *Config
|
||||
|
||||
// LoadConfig 加载应用配置
|
||||
func LoadConfig() error {
|
||||
c, err := config.LoadConfig(path, cfg)
|
||||
cfg = c
|
||||
return err
|
||||
}
|
||||
|
||||
func Get() *Config {
|
||||
return cfg
|
||||
}
|
||||
|
||||
func Set(c *Config) {
|
||||
cfg = c
|
||||
}
|
||||
44
config/config.prod.yaml
Normal file
44
config/config.prod.yaml
Normal file
@@ -0,0 +1,44 @@
|
||||
app:
|
||||
name: "gateway-prod"
|
||||
|
||||
log:
|
||||
debug: false
|
||||
level: "debug"
|
||||
maxSize: 10
|
||||
maxBackups: 100
|
||||
maxAge: 7
|
||||
|
||||
metric:
|
||||
prometheus:
|
||||
address: "0.0.0.0"
|
||||
port: 18504
|
||||
jaeger:
|
||||
endpoint: "172.18.28.0:4317"
|
||||
|
||||
db:
|
||||
etcd:
|
||||
endpoints: [ "172.18.28.0:2379" ]
|
||||
redis:
|
||||
addr: "172.18.28.0:6379"
|
||||
password: "lQ7aM8oB6lK0iD5k"
|
||||
db: 0
|
||||
|
||||
serve:
|
||||
grpc:
|
||||
address: "172.18.28.0"
|
||||
port: 18500
|
||||
ttl: 20
|
||||
socket:
|
||||
web:
|
||||
address: "0.0.0.0"
|
||||
port: 18501
|
||||
raw:
|
||||
address: "0.0.0.0"
|
||||
port: 18502
|
||||
http:
|
||||
address: "0.0.0.0"
|
||||
port: 18503
|
||||
|
||||
auth:
|
||||
shortExpire: 3600
|
||||
longExpire: 604800
|
||||
12
deploy/Dockerfile
Normal file
12
deploy/Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
||||
FROM alpine:3.23.2
|
||||
|
||||
RUN apk add --no-cache tzdata && \
|
||||
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
||||
echo "Asia/Shanghai" > /etc/timezone
|
||||
|
||||
COPY service-gateway /app/service-gateway
|
||||
COPY config /app/config
|
||||
RUN chmod 777 /app/service-gateway
|
||||
|
||||
WORKDIR /app
|
||||
CMD ["./service-gateway"]
|
||||
134
deploy/Jenkinsfile
vendored
Normal file
134
deploy/Jenkinsfile
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
pipeline {
|
||||
agent none
|
||||
|
||||
environment {
|
||||
// 仓库
|
||||
REPO_URL = 'https://git.hlsq.asia/mmorpg/service-gateway.git'
|
||||
REPO_CREDENTIALS_ID = '80805ba2-f4ac-4d84-aee6-d4cce5fc0a96'
|
||||
|
||||
// Registry
|
||||
REGISTRY_URL = 'registry.hlsq.asia'
|
||||
REGISTRY_CREDENTIALS_ID = '0d79fc0b-a150-470b-bd0d-2639b2826031'
|
||||
|
||||
// 部署目标服务器
|
||||
SERVER_HOST = 'www.hlsq.asia'
|
||||
SERVER_USER = 'root'
|
||||
SSH_CREDENTIALS_ID = '10e0830d-4d03-4879-9ee4-03a4c55513ad'
|
||||
|
||||
// 基础信息
|
||||
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'
|
||||
}
|
||||
|
||||
options {
|
||||
skipDefaultCheckout true
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Checkout') {
|
||||
agent any
|
||||
steps {
|
||||
checkout([
|
||||
$class: 'GitSCM',
|
||||
branches: [[name: '*/master']],
|
||||
doGenerateSubmoduleConfigurations: false,
|
||||
extensions: [],
|
||||
userRemoteConfigs: [[
|
||||
credentialsId: env.REPO_CREDENTIALS_ID,
|
||||
url: env.REPO_URL
|
||||
]]
|
||||
])
|
||||
// 立刻保存Git的Commit,避免并发问题
|
||||
script {
|
||||
def shortCommit = sh(script: 'git rev-parse --short=8 HEAD', returnStdout: true).trim()
|
||||
env.IMAGE_TAG = "${env.REGISTRY_URL}/${env.APP_NAME}:${shortCommit}"
|
||||
echo "Checked out commit: ${env.IMAGE_TAG}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build Go Binary') {
|
||||
agent {
|
||||
docker {
|
||||
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'
|
||||
}
|
||||
}
|
||||
steps {
|
||||
sh """
|
||||
export GOPROXY=https://goproxy.cn,direct
|
||||
export CGO_ENABLED=0
|
||||
export GOOS=linux
|
||||
export GOARCH=amd64
|
||||
|
||||
go build -o ${env.APP_NAME} .
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
stage('Push Docker Image') {
|
||||
agent any
|
||||
steps {
|
||||
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}
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Deploy to Server') {
|
||||
agent any
|
||||
steps {
|
||||
script {
|
||||
withCredentials([
|
||||
usernamePassword(
|
||||
credentialsId: env.REGISTRY_CREDENTIALS_ID,
|
||||
usernameVariable: 'DOCKER_USER',
|
||||
passwordVariable: 'DOCKER_PASS'
|
||||
)
|
||||
]) {
|
||||
sshagent (credentials: [env.SSH_CREDENTIALS_ID]) {
|
||||
sh """
|
||||
ssh -o StrictHostKeyChecking=no ${env.SERVER_USER}@${env.SERVER_HOST} << EOF
|
||||
set -e
|
||||
echo '${DOCKER_PASS}' | docker login --username '${DOCKER_USER}' --password-stdin ${env.REGISTRY_URL}
|
||||
docker pull ${env.IMAGE_TAG}
|
||||
docker stop ${env.APP_NAME} 2>/dev/null || true
|
||||
docker rm ${env.APP_NAME} 2>/dev/null || true
|
||||
docker run -d \\
|
||||
--name ${env.APP_NAME} \\
|
||||
--restart unless-stopped \\
|
||||
-p 18500-18504:18500-18504 \\
|
||||
--env XH_G_ENV=prod \\
|
||||
-v /root/service/logs/gateway_log/:/app/logs \\
|
||||
${env.IMAGE_TAG}
|
||||
docker logout ${env.REGISTRY_URL}
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
success {
|
||||
echo '✅ 构建、推送镜像与部署成功!'
|
||||
}
|
||||
failure {
|
||||
echo '❌ 构建失败,请检查日志。'
|
||||
}
|
||||
}
|
||||
}
|
||||
126
go.mod
Normal file
126
go.mod
Normal file
@@ -0,0 +1,126 @@
|
||||
module git.hlsq.asia/mmorpg/service-gateway
|
||||
|
||||
go 1.24.0
|
||||
|
||||
require (
|
||||
bou.ke/monkey v1.0.2
|
||||
git.hlsq.asia/mmorpg/service-common v0.0.0-20260207051302-0ca8a0ccbb14
|
||||
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/golang/mock v1.6.0
|
||||
github.com/google/uuid 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/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.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/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.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.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.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/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.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
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
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/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.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/redis/go-redis/v9 v9.10.0 // 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
|
||||
github.com/spf13/cast v1.10.0 // indirect
|
||||
github.com/spf13/pflag v1.0.10 // indirect
|
||||
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.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.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.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
|
||||
)
|
||||
357
go.sum
Normal file
357
go.sum
Normal file
@@ -0,0 +1,357 @@
|
||||
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-20260207051302-0ca8a0ccbb14 h1:4r3tNWRzGVY3Xx6UiGjJJnwoMoWlVqbyGrljxl5d/nQ=
|
||||
git.hlsq.asia/mmorpg/service-common v0.0.0-20260207051302-0ca8a0ccbb14/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=
|
||||
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
|
||||
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/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=
|
||||
github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU=
|
||||
github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4=
|
||||
github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec=
|
||||
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
|
||||
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
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.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.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=
|
||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
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.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=
|
||||
github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
|
||||
github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU=
|
||||
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
|
||||
github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og=
|
||||
github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
|
||||
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.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/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=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
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.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=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||
github.com/natefinch/lumberjack v2.0.0+incompatible h1:4QJd3OLAMgj7ph+yZTuX13Ld4UpgHp07nNdFX7mqFfM=
|
||||
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.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=
|
||||
github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
|
||||
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
|
||||
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
||||
github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ2Io=
|
||||
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.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.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=
|
||||
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8/go.mod h1:3n1Cwaq1E1/1lhQhtRK2ts/ZwZEhjcQeJQ1RuC6Q/8U=
|
||||
github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I=
|
||||
github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg=
|
||||
github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY=
|
||||
github.com/spf13/cast v1.10.0/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo=
|
||||
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
|
||||
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/viper v1.21.0 h1:x5S+0EU27Lbphp4UKm1C+1oQO+rKx36vfCoaVebLFSU=
|
||||
github.com/spf13/viper v1.21.0/go.mod h1:P0lhsswPGWD/1lZJ9ny3fYnVqxiegrlNrEmgLjbTCAY=
|
||||
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.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.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.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.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.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.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.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.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.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.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.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=
|
||||
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=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gorm.io/driver/mysql v1.6.0 h1:eNbLmNTpPpTOVZi8MMxCi2aaIm0ZpInbORNXDwyLGvg=
|
||||
gorm.io/driver/mysql v1.6.0/go.mod h1:D/oCC2GWK3M/dqoLxnOlaNKmXz8WNTfcS9y5ovaSqKo=
|
||||
gorm.io/gorm v1.31.1 h1:7CA8FTFz/gRfgqgpeKIBcervUn3xSyPUmr6B2WXJ7kg=
|
||||
gorm.io/gorm v1.31.1/go.mod h1:XyQVbO2k6YkOis7C2437jSit3SsDK72s7n7rsSHd+Gs=
|
||||
27
internal/global/global.go
Normal file
27
internal/global/global.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package global
|
||||
|
||||
var ServiceStatus = ServiceStatusStarting
|
||||
|
||||
type ServiceStatusCode int32
|
||||
|
||||
const (
|
||||
ServiceStatusStarting ServiceStatusCode = iota // 启动中
|
||||
ServiceStatusReady // 就绪
|
||||
ServiceStatusStopping // 停止中
|
||||
)
|
||||
|
||||
var GatewaySID int64
|
||||
|
||||
const (
|
||||
KeyGatewayAccessToken = "gateway:token:access:"
|
||||
KeyGatewayRefreshToken = "gateway:token:refresh:"
|
||||
KeyGatewaySession = "gateway:session:"
|
||||
|
||||
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 == -1 {
|
||||
|
||||
//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
|
||||
}
|
||||
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() {
|
||||
}
|
||||
155
internal/handler/http_handler/login.go
Normal file
155
internal/handler/http_handler/login.go
Normal file
@@ -0,0 +1,155 @@
|
||||
package http_handler
|
||||
|
||||
import (
|
||||
"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/internal/global"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// 这个模块处理用户登录
|
||||
|
||||
type LoginReq struct {
|
||||
Phone string `json:"phone"` // 手机号
|
||||
Code string `json:"code"` // 验证码
|
||||
WxMiniCode string `json:"wxMiniCode"` // 微信小程序登录
|
||||
}
|
||||
|
||||
type LoginResp struct {
|
||||
USN int64 `json:"usn"`
|
||||
Name string `json:"name"`
|
||||
AccessToken string `json:"accessToken"`
|
||||
RefreshToken string `json:"refreshToken"`
|
||||
}
|
||||
|
||||
func Login(c *gin.Context) {
|
||||
req := &LoginReq{}
|
||||
if err := c.ShouldBindJSON(req); err != nil {
|
||||
http_resp.JsonBadRequest(c)
|
||||
return
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
usn, name := int64(0), ""
|
||||
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 := sessionLogin(c, usn)
|
||||
if err != nil {
|
||||
log.Errorf("Login sessionLogin error: %v, usn: %v", err, usn)
|
||||
http_resp.JsonOK(c, http_resp.Error(http_resp.Failed))
|
||||
return
|
||||
}
|
||||
http_resp.JsonOK(c, http_resp.Success(&LoginResp{
|
||||
USN: usn,
|
||||
Name: name,
|
||||
AccessToken: at,
|
||||
RefreshToken: rt,
|
||||
}))
|
||||
}
|
||||
|
||||
type RefreshTokenReq struct {
|
||||
RefreshToken string `json:"refreshToken"`
|
||||
}
|
||||
|
||||
type RefreshTokenResp struct {
|
||||
AccessToken string `json:"accessToken"`
|
||||
RefreshToken string `json:"refreshToken"`
|
||||
}
|
||||
|
||||
func RefreshToken(c *gin.Context) {
|
||||
req := &RefreshTokenReq{}
|
||||
if err := c.ShouldBindJSON(req); err != nil {
|
||||
http_resp.JsonBadRequest(c)
|
||||
return
|
||||
}
|
||||
if req.RefreshToken == "" {
|
||||
cookie, err := c.Cookie("refresh_token")
|
||||
if err != nil {
|
||||
http_resp.JsonUnauthorized(c)
|
||||
return
|
||||
}
|
||||
req.RefreshToken = cookie
|
||||
}
|
||||
|
||||
usn, _ := redis.GetClient().HGet(c, global.KeyGatewayRefreshToken+req.RefreshToken, (&utils.UserSession{}).GetUsnKey()).Int64()
|
||||
if usn == 0 {
|
||||
http_resp.JsonUnauthorized(c)
|
||||
return
|
||||
}
|
||||
|
||||
if err := sessionLogout(c, req.RefreshToken); err != nil {
|
||||
log.Errorf("RefreshToken sessionLogout error: %v, usn: %v", err, usn)
|
||||
}
|
||||
at, rt, err := sessionLogin(c, usn)
|
||||
if err != nil {
|
||||
log.Errorf("RefreshToken sessionLogin error: %v, usn: %v", err, usn)
|
||||
http_resp.JsonOK(c, http_resp.Error(http_resp.Failed))
|
||||
return
|
||||
}
|
||||
|
||||
http_resp.JsonOK(c, http_resp.Success(&RefreshTokenResp{
|
||||
AccessToken: at,
|
||||
RefreshToken: rt,
|
||||
}))
|
||||
}
|
||||
|
||||
type LogoutReq struct {
|
||||
RefreshToken string `json:"refreshToken"`
|
||||
}
|
||||
|
||||
type LogoutResp struct {
|
||||
}
|
||||
|
||||
func Logout(c *gin.Context) {
|
||||
req := &LogoutReq{}
|
||||
if err := c.ShouldBindJSON(req); err != nil {
|
||||
http_resp.JsonBadRequest(c)
|
||||
return
|
||||
}
|
||||
if req.RefreshToken == "" {
|
||||
cookie, err := c.Cookie("refresh_token")
|
||||
if err != nil {
|
||||
http_resp.JsonUnauthorized(c)
|
||||
return
|
||||
}
|
||||
req.RefreshToken = cookie
|
||||
}
|
||||
if err := sessionLogout(c, req.RefreshToken); err != nil {
|
||||
log.Errorf("Logout sessionLogout error: %v", err)
|
||||
}
|
||||
http_resp.JsonOK(c, http_resp.Success(&LogoutResp{}))
|
||||
}
|
||||
156
internal/handler/http_handler/login_test.go
Normal file
156
internal/handler/http_handler/login_test.go
Normal file
@@ -0,0 +1,156 @@
|
||||
package http_handler
|
||||
|
||||
import (
|
||||
"bou.ke/monkey"
|
||||
"fmt"
|
||||
"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/testutil"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type LoginTestSuite struct {
|
||||
testutil.TestSuite
|
||||
}
|
||||
|
||||
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(), 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{})
|
||||
}
|
||||
108
internal/handler/http_handler/session.go
Normal file
108
internal/handler/http_handler/session.go
Normal file
@@ -0,0 +1,108 @@
|
||||
package http_handler
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/mmorpg/service-common/db/redis"
|
||||
"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"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
var (
|
||||
scriptLoginSha1 string
|
||||
scriptLogin = `
|
||||
local at_key = KEYS[1] .. ARGV[1]
|
||||
local rt_key = KEYS[2] .. ARGV[2]
|
||||
local session_key = KEYS[3] .. ARGV[3]
|
||||
|
||||
redis.call("HSET", at_key,
|
||||
"usn", ARGV[3],
|
||||
"ip", ARGV[6],
|
||||
"ua", ARGV[7],
|
||||
"rt", ARGV[2]
|
||||
)
|
||||
redis.call("EXPIRE", at_key, tonumber(ARGV[4]))
|
||||
|
||||
redis.call("HSET", rt_key,
|
||||
"usn", ARGV[3],
|
||||
"ip", ARGV[6],
|
||||
"ua", ARGV[7],
|
||||
"at", ARGV[1]
|
||||
)
|
||||
redis.call("EXPIRE", rt_key, tonumber(ARGV[5]))
|
||||
|
||||
local all_rts = redis.call("SMEMBERS", session_key)
|
||||
-- 只允许最大10个会话,多了的随机踢掉
|
||||
if #all_rts >= 10 then
|
||||
local rk = KEYS[2] .. all_rts[1]
|
||||
local ak = KEYS[1] .. redis.call("HGET", rk, "at")
|
||||
redis.call("DEL", rk)
|
||||
redis.call("DEL", ak)
|
||||
end
|
||||
-- 清理已经失效的会话
|
||||
for i, rt in ipairs(all_rts) do
|
||||
if redis.call("EXISTS", KEYS[2] .. rt) == 0 then
|
||||
redis.call("SREM", session_key, rt)
|
||||
end
|
||||
end
|
||||
|
||||
redis.call("SADD", session_key, ARGV[2])
|
||||
redis.call("EXPIRE", session_key, tonumber(ARGV[5]) + 600)
|
||||
|
||||
return 1
|
||||
`
|
||||
)
|
||||
|
||||
func sessionLogin(c *gin.Context, usn int64) (string, string, error) {
|
||||
if scriptLoginSha1 == "" {
|
||||
scriptLoginSha1 = redis.GetClient().ScriptLoad(c, scriptLogin).Val()
|
||||
}
|
||||
at := uuid.New().String()
|
||||
rt := uuid.New().String()
|
||||
err := redis.GetClient().EvalSha(
|
||||
c, scriptLoginSha1,
|
||||
[]string{global.KeyGatewayAccessToken, global.KeyGatewayRefreshToken, global.KeyGatewaySession},
|
||||
at,
|
||||
rt,
|
||||
usn,
|
||||
config.Get().Auth.ShortExpire,
|
||||
config.Get().Auth.LongExpire,
|
||||
c.RemoteIP(),
|
||||
c.GetHeader("User-Agent"),
|
||||
).Err()
|
||||
if err != nil {
|
||||
return "", "", utils.ErrorsWrap(err)
|
||||
}
|
||||
c.SetCookie("refresh_token", rt, int(config.Get().Auth.LongExpire), "/", ".hlsq.asia", true, true)
|
||||
|
||||
return at, rt, nil
|
||||
}
|
||||
|
||||
var (
|
||||
scriptLogoutSha1 string
|
||||
scriptLogout = `
|
||||
local rt_key = KEYS[2] .. ARGV[1]
|
||||
local usn = redis.call("HGET", rt_key, "usn")
|
||||
local at = redis.call("HGET", rt_key, "at")
|
||||
local at_key = KEYS[1] .. at
|
||||
local session_key = KEYS[3] .. usn
|
||||
|
||||
redis.call("DEL", at_key)
|
||||
redis.call("DEL", rt_key)
|
||||
redis.call("SREM", session_key, ARGV[1])
|
||||
|
||||
return 1
|
||||
`
|
||||
)
|
||||
|
||||
func sessionLogout(c *gin.Context, rt string) error {
|
||||
if scriptLogoutSha1 == "" {
|
||||
scriptLogoutSha1 = redis.GetClient().ScriptLoad(c, scriptLogout).Val()
|
||||
}
|
||||
return redis.GetClient().EvalSha(
|
||||
c, scriptLogoutSha1,
|
||||
[]string{global.KeyGatewayAccessToken, global.KeyGatewayRefreshToken, global.KeyGatewaySession},
|
||||
rt,
|
||||
).Err()
|
||||
}
|
||||
113
internal/handler/ws_handler/client/client.go
Normal file
113
internal/handler/ws_handler/client/client.go
Normal file
@@ -0,0 +1,113 @@
|
||||
package client
|
||||
|
||||
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/socket"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/global"
|
||||
"go.uber.org/zap"
|
||||
"runtime/debug"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
sync.WaitGroup
|
||||
conn socket.ISocketConn // Socket
|
||||
mailChan chan Event // 邮箱队列
|
||||
logger *zap.SugaredLogger // 日志
|
||||
ctx context.Context // 上下文
|
||||
cancel context.CancelFunc // 取消上下文
|
||||
heartBeat time.Time // 最后一次心跳
|
||||
|
||||
Status int32 // 状态:0 登陆中 1 正常 2 离线
|
||||
USN int64 // 用户ID
|
||||
SceneSID int64 // 场景服ID
|
||||
InstanceID int32 // 副本ID,副本类型
|
||||
UniqueNo int64 // 副本唯一编号
|
||||
}
|
||||
|
||||
func NewClient(conn socket.ISocketConn) *Client {
|
||||
client := &Client{
|
||||
conn: conn,
|
||||
logger: log.GetLogger(),
|
||||
heartBeat: time.Now(),
|
||||
mailChan: make(chan Event, 1024),
|
||||
}
|
||||
client.ctx, client.cancel = context.WithCancel(context.Background())
|
||||
client.Add(1)
|
||||
go client.Loop()
|
||||
return client
|
||||
}
|
||||
|
||||
func (c *Client) SetUSN(usn int64) {
|
||||
c.USN = usn
|
||||
c.logger = log.GetLogger().Named(fmt.Sprintf("usn:%v", usn))
|
||||
}
|
||||
|
||||
func (c *Client) Loop() {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
c.logger.Errorf("Client Loop err: %v", err)
|
||||
debug.PrintStack()
|
||||
}
|
||||
}()
|
||||
defer c.onClose()
|
||||
t := time.NewTicker(20 * time.Second)
|
||||
defer t.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-c.ctx.Done():
|
||||
return
|
||||
case evt, ok := <-c.mailChan:
|
||||
if ok {
|
||||
c.handle(evt)
|
||||
}
|
||||
case <-t.C:
|
||||
_ = c.conn.Ping()
|
||||
if time.Now().Sub(c.heartBeat) > 60*time.Second {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) OnEvent(event Event) {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
c.logger.Warnf(fmt.Sprintf("send event chan error: %v", err))
|
||||
}
|
||||
}()
|
||||
select {
|
||||
case c.mailChan <- event:
|
||||
default:
|
||||
c.logger.Warnf("Client mailChan full")
|
||||
}
|
||||
}
|
||||
|
||||
// CloseClient 关闭客户端(同步,会等待onClose执行完成)
|
||||
func (c *Client) CloseClient() {
|
||||
if c.cancel != nil {
|
||||
c.cancel()
|
||||
c.Wait()
|
||||
}
|
||||
}
|
||||
|
||||
// onClose 客户端关闭自动触发
|
||||
func (c *Client) onClose() {
|
||||
if c.conn != nil {
|
||||
_ = c.conn.Close()
|
||||
c.conn = nil
|
||||
}
|
||||
if c.mailChan != nil {
|
||||
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()
|
||||
}
|
||||
17
internal/handler/ws_handler/client/client_event.go
Normal file
17
internal/handler/ws_handler/client/client_event.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package client
|
||||
|
||||
type Event interface {
|
||||
}
|
||||
|
||||
type ClientEvent struct {
|
||||
Event
|
||||
Msg []byte
|
||||
}
|
||||
|
||||
type PongEvent struct {
|
||||
Event
|
||||
}
|
||||
|
||||
type SystemLoginSuccessEvent struct {
|
||||
Event
|
||||
}
|
||||
111
internal/handler/ws_handler/client/client_handler.go
Normal file
111
internal/handler/ws_handler/client/client_handler.go
Normal file
@@ -0,0 +1,111 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"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"
|
||||
)
|
||||
|
||||
func (c *Client) handle(event Event) {
|
||||
switch e := event.(type) {
|
||||
case *ClientEvent:
|
||||
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 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 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()
|
||||
return
|
||||
}
|
||||
c.onAction(m)
|
||||
}
|
||||
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 *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: global.GatewaySID,
|
||||
InstanceID: msg.InstanceID,
|
||||
})
|
||||
if err != nil {
|
||||
c.logger.Errorf("enter err: %v", err)
|
||||
return
|
||||
}
|
||||
c.SceneSID = resp.SceneSID
|
||||
c.UniqueNo = resp.UniqueNo
|
||||
c.InstanceID = msg.InstanceID
|
||||
c.WriteBytes(ss_pb.MessageID(resp.MessageID), resp.Payload)
|
||||
}
|
||||
|
||||
func (c *Client) onLeave() {
|
||||
if c.SceneSID == 0 {
|
||||
return
|
||||
}
|
||||
client, err := grpc_client.SceneNewClient(c.SceneSID)
|
||||
if err != nil {
|
||||
c.logger.Errorf("SceneNewClient err: %v", err)
|
||||
return
|
||||
}
|
||||
_, err = client.Leave(context.Background(), &grpc_pb.LeaveReq{
|
||||
USN: c.USN,
|
||||
UniqueNo: c.UniqueNo,
|
||||
})
|
||||
if err != nil {
|
||||
c.logger.Errorf("leave err: %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) onAction(msg *ss_pb.C2S_Action) {
|
||||
if c.SceneSID == 0 {
|
||||
return
|
||||
}
|
||||
if err := grpc_client.SendMessageToScene(c.SceneSID, grpc_client.FunAction, &grpc_pb.ActionReq{
|
||||
UniqueNo: c.UniqueNo,
|
||||
USN: c.USN,
|
||||
Action: int32(msg.Action),
|
||||
DirX: msg.DirX,
|
||||
DirY: msg.DirY,
|
||||
SkillID: msg.SkillID,
|
||||
}); err != nil {
|
||||
c.logger.Errorf("send action err: %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
57
internal/handler/ws_handler/client/client_write.go
Normal file
57
internal/handler/ws_handler/client/client_write.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/ss/ss_pb"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// WriteMessage 向客户端发送消息
|
||||
func (c *Client) WriteMessage(id ss_pb.MessageID, data proto.Message) {
|
||||
if c.conn == nil || c.conn.IsClose() {
|
||||
return
|
||||
}
|
||||
d, err := proto.Marshal(data)
|
||||
if err != nil {
|
||||
c.logger.Errorf("WriteMessage proto.Marshal err: %v", err)
|
||||
return
|
||||
}
|
||||
m, err := proto.Marshal(&ss_pb.Message{
|
||||
ID: id,
|
||||
Payload: d,
|
||||
})
|
||||
if err != nil {
|
||||
c.logger.Errorf("WriteMessage proto.Marshal err: %v", err)
|
||||
return
|
||||
}
|
||||
if err = c.conn.Write(m); err != nil {
|
||||
c.logger.Errorf("WriteMessage err: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// WriteBytes 向客户端发送字节数据
|
||||
func (c *Client) WriteBytes(id ss_pb.MessageID, data []byte) {
|
||||
if c.conn == nil || c.conn.IsClose() {
|
||||
return
|
||||
}
|
||||
m, err := proto.Marshal(&ss_pb.Message{
|
||||
ID: id,
|
||||
Payload: data,
|
||||
})
|
||||
if err != nil {
|
||||
c.logger.Errorf("WriteBytes proto.Marshal err: %v", err)
|
||||
return
|
||||
}
|
||||
if err = c.conn.Write(m); err != nil {
|
||||
c.logger.Errorf("WriteBytes err: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// WriteBytesPreMarshal 向客户端发送字节数据(需要预先打包,适合广播相同数据)
|
||||
func (c *Client) WriteBytesPreMarshal(data []byte) {
|
||||
if c.conn == nil || c.conn.IsClose() {
|
||||
return
|
||||
}
|
||||
if err := c.conn.Write(data); err != nil {
|
||||
c.logger.Errorf("WriteBytes err: %v", err)
|
||||
}
|
||||
}
|
||||
67
internal/handler/ws_handler/client/manager.go
Normal file
67
internal/handler/ws_handler/client/manager.go
Normal file
@@ -0,0 +1,67 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/global"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var UserMgr *userManager
|
||||
|
||||
type userManager struct {
|
||||
userMap map[int64]*Client
|
||||
sync.RWMutex
|
||||
}
|
||||
|
||||
func init() {
|
||||
UserMgr = &userManager{
|
||||
userMap: make(map[int64]*Client),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *userManager) Add(usn int64, client *Client) {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
m.userMap[usn] = client
|
||||
global.OnlineUsersGauge.Inc()
|
||||
}
|
||||
|
||||
func (m *userManager) Delete(usn int64) {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
delete(m.userMap, usn)
|
||||
global.OnlineUsersGauge.Dec()
|
||||
}
|
||||
|
||||
func (m *userManager) GetAll() map[int64]*Client {
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
|
||||
copyMap := make(map[int64]*Client, len(m.userMap))
|
||||
for k, v := range m.userMap {
|
||||
copyMap[k] = v
|
||||
}
|
||||
return copyMap
|
||||
}
|
||||
|
||||
func (m *userManager) GetAllInterface() []interface{} {
|
||||
m.RLock()
|
||||
defer m.RUnlock()
|
||||
|
||||
r := make([]interface{}, 0)
|
||||
for _, v := range m.userMap {
|
||||
r = append(r, v)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (m *userManager) GetByUSN(usn int64) *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))
|
||||
}
|
||||
184
internal/handler/ws_handler/login/login.go
Normal file
184
internal/handler/ws_handler/login/login.go
Normal file
@@ -0,0 +1,184 @@
|
||||
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-common/utils"
|
||||
"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 {
|
||||
usn, _ := redis.GetClient().HGet(context.Background(), global.KeyGatewayAccessToken+user.Token, (&utils.UserSession{}).GetUsnKey()).Int64()
|
||||
user.Cli.SetUSN(usn)
|
||||
return usn > 0
|
||||
}
|
||||
|
||||
// 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 int64, usn int64) 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 int64) (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 int64) 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()
|
||||
}
|
||||
81
internal/net/http_gateway/middleward.go
Normal file
81
internal/net/http_gateway/middleward.go
Normal file
@@ -0,0 +1,81 @@
|
||||
package http_gateway
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.hlsq.asia/mmorpg/service-common/db/redis"
|
||||
"git.hlsq.asia/mmorpg/service-common/net/http/http_resp"
|
||||
"git.hlsq.asia/mmorpg/service-common/utils"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/internal/global"
|
||||
"github.com/gin-contrib/cors"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func corsConfig() cors.Config {
|
||||
return cors.Config{
|
||||
AllowMethods: []string{"GET", "POST", "OPTIONS"},
|
||||
AllowHeaders: []string{"Content-Type", "Authorization"},
|
||||
AllowCredentials: false,
|
||||
AllowAllOrigins: true,
|
||||
MaxAge: 12 * time.Hour,
|
||||
}
|
||||
}
|
||||
|
||||
func ginLogger(logger *zap.SugaredLogger) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
start := time.Now()
|
||||
path := c.Request.URL.Path
|
||||
c.Next()
|
||||
cost := time.Since(start)
|
||||
usn, _ := c.Get("usn")
|
||||
|
||||
logger.Infof(fmt.Sprintf(
|
||||
"[usn:%v] Method:%v Code:%v Time:%v IP:%v Path:%v",
|
||||
usn,
|
||||
c.Request.Method,
|
||||
c.Writer.Status(),
|
||||
cost,
|
||||
c.ClientIP(),
|
||||
path),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func authJwt() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
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 == "" {
|
||||
if public {
|
||||
c.Next()
|
||||
return
|
||||
}
|
||||
http_resp.JsonUnauthorized(c)
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
usn, _ := redis.GetClient().HGet(c, global.KeyGatewayAccessToken+token, (&utils.UserSession{}).GetUsnKey()).Int64()
|
||||
if usn == 0 {
|
||||
http_resp.JsonUnauthorized(c)
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
// 这里将Header写到请求中,grpc-gateway框架会读取然后传给grpc服务
|
||||
c.Request.Header.Set("X-Usn", utils.Int64ToString(usn))
|
||||
// 这里写到上下文中,打日志
|
||||
c.Set("usn", usn)
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
127
internal/net/http_gateway/router.go
Normal file
127
internal/net/http_gateway/router.go
Normal file
@@ -0,0 +1,127 @@
|
||||
package http_gateway
|
||||
|
||||
import (
|
||||
"context"
|
||||
"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"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func InitServeMux() *runtime.ServeMux {
|
||||
baseMarshaler := &runtime.JSONPb{
|
||||
MarshalOptions: protojson.MarshalOptions{
|
||||
UseProtoNames: false,
|
||||
EmitUnpopulated: true,
|
||||
},
|
||||
UnmarshalOptions: protojson.UnmarshalOptions{
|
||||
DiscardUnknown: true,
|
||||
},
|
||||
}
|
||||
unifiedMarshaler := wrapper.NewWrappedMarshaler(baseMarshaler)
|
||||
|
||||
mux := runtime.NewServeMux(
|
||||
runtime.WithMarshalerOption(runtime.MIMEWildcard, unifiedMarshaler),
|
||||
runtime.WithErrorHandler(wrapper.ErrorHandler),
|
||||
runtime.WithIncomingHeaderMatcher(func(header string) (string, bool) {
|
||||
if header == "X-Usn" {
|
||||
return "X-Usn", true
|
||||
}
|
||||
return runtime.DefaultHeaderMatcher(header)
|
||||
}),
|
||||
)
|
||||
return mux
|
||||
}
|
||||
|
||||
func InitRouter() *gin.Engine {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
|
||||
r := gin.New()
|
||||
r.Use(
|
||||
gin.Recovery(),
|
||||
ginLogger(log.GetLogger().Named("GIN")),
|
||||
cors.New(corsConfig()),
|
||||
otelgin.Middleware(
|
||||
common.KeyDiscoverServiceNameGateway,
|
||||
otelgin.WithSpanNameFormatter(func(c *gin.Context) string {
|
||||
method := strings.ToUpper(c.Request.Method)
|
||||
return method + " " + c.Request.URL.Path
|
||||
}),
|
||||
),
|
||||
)
|
||||
|
||||
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()
|
||||
})
|
||||
|
||||
auth := r.Group("/")
|
||||
auth.Use(authJwt())
|
||||
|
||||
// 网关
|
||||
initGatewayPath(auth)
|
||||
// 用户中心
|
||||
initUserPath(auth)
|
||||
// 奇怪的知识-服务端
|
||||
initQgdzsPath(auth)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func initGatewayPath(r *gin.RouterGroup) {
|
||||
g := r.Group("/" + common.KeyDiscoverServiceNameGateway)
|
||||
|
||||
g.POST("/open/login", http_handler.Login)
|
||||
g.POST("/open/refresh_token", http_handler.RefreshToken)
|
||||
g.POST("/open/logout", http_handler.Logout)
|
||||
}
|
||||
|
||||
func initUserPath(r *gin.RouterGroup) {
|
||||
g := r.Group("/" + common.KeyDiscoverServiceNameUser)
|
||||
|
||||
client, err := grpc_client.UserNewClientLB()
|
||||
if err != nil {
|
||||
log.Errorf("get user conn failed: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
gwMux := InitServeMux()
|
||||
if err = grpc_pb.RegisterUserHandlerClient(context.Background(), gwMux, client); err != nil {
|
||||
log.Errorf("RegisterUserHandlerClient err: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
g.Any("/*path", gin.WrapH(gwMux))
|
||||
}
|
||||
|
||||
func initQgdzsPath(r *gin.RouterGroup) {
|
||||
g := r.Group("/" + common.KeyDiscoverServiceNameQgdzs)
|
||||
|
||||
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))
|
||||
}
|
||||
58
internal/net/http_gateway/wrapper/error_handler.go
Normal file
58
internal/net/http_gateway/wrapper/error_handler.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package wrapper
|
||||
|
||||
import (
|
||||
"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"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// ErrorHandler 将 gRPC 错误转为统一 JSON 格式
|
||||
func ErrorHandler(_ context.Context, _ *runtime.ServeMux, _ runtime.Marshaler, w http.ResponseWriter, _ *http.Request, err error) {
|
||||
st, ok := status.FromError(err)
|
||||
if !ok {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
_ = json.NewEncoder(w).Encode(http_resp.Error(http_resp.Failed))
|
||||
return
|
||||
}
|
||||
|
||||
code, msg := 0, ""
|
||||
for _, detail := range st.Details() {
|
||||
if errorInfo, ok := detail.(*rs_common.ErrorInfo); ok {
|
||||
code = int(errorInfo.Code)
|
||||
msg = errorInfo.Msg
|
||||
break
|
||||
}
|
||||
}
|
||||
if code == 0 {
|
||||
code = http_resp.Failed.Code()
|
||||
msg = http_resp.Failed.Error()
|
||||
}
|
||||
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()))
|
||||
_ = json.NewEncoder(w).Encode(http_resp.Error(http_resp.NewCode(code, msg)))
|
||||
}
|
||||
|
||||
// 这里定义 Internal 属于业务错误,其他的属于 500 报错
|
||||
func grpcCodeToHTTPCode(c codes.Code) int {
|
||||
switch c {
|
||||
case codes.OK, codes.Unknown:
|
||||
return http.StatusOK
|
||||
case codes.Unimplemented, codes.NotFound:
|
||||
return http.StatusNotFound
|
||||
default:
|
||||
return http.StatusInternalServerError
|
||||
}
|
||||
}
|
||||
42
internal/net/http_gateway/wrapper/marshal.go
Normal file
42
internal/net/http_gateway/wrapper/marshal.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package wrapper
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"git.hlsq.asia/mmorpg/service-common/net/http/http_resp"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
"io"
|
||||
)
|
||||
|
||||
// WrappedMarshaler 自动包装响应为 { code, message, data }
|
||||
type WrappedMarshaler struct {
|
||||
inner runtime.Marshaler
|
||||
}
|
||||
|
||||
func NewWrappedMarshaler(inner runtime.Marshaler) *WrappedMarshaler {
|
||||
return &WrappedMarshaler{inner: inner}
|
||||
}
|
||||
|
||||
// Marshal 将 gRPC 响应包装成统一格式
|
||||
func (w *WrappedMarshaler) Marshal(v interface{}) ([]byte, error) {
|
||||
dataBytes, err := w.inner.Marshal(v)
|
||||
if err != nil {
|
||||
return json.Marshal(http_resp.Error(http_resp.Failed))
|
||||
}
|
||||
return json.Marshal(http_resp.Success(json.RawMessage(dataBytes)))
|
||||
}
|
||||
|
||||
func (w *WrappedMarshaler) Unmarshal(data []byte, v interface{}) error {
|
||||
return w.inner.Unmarshal(data, v)
|
||||
}
|
||||
|
||||
func (w *WrappedMarshaler) NewDecoder(r io.Reader) runtime.Decoder {
|
||||
return w.inner.NewDecoder(r)
|
||||
}
|
||||
|
||||
func (w *WrappedMarshaler) NewEncoder(wr io.Writer) runtime.Encoder {
|
||||
return w.inner.NewEncoder(wr)
|
||||
}
|
||||
|
||||
func (w *WrappedMarshaler) ContentType(v interface{}) string {
|
||||
return "application/json"
|
||||
}
|
||||
61
internal/net/ws_gateway/server.go
Normal file
61
internal/net/ws_gateway/server.go
Normal file
@@ -0,0 +1,61 @@
|
||||
package ws_gateway
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.hlsq.asia/mmorpg/service-common/log"
|
||||
"git.hlsq.asia/mmorpg/service-common/net/socket"
|
||||
"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"
|
||||
"time"
|
||||
)
|
||||
|
||||
type GatewayWsServer struct {
|
||||
logger *zap.SugaredLogger
|
||||
}
|
||||
|
||||
func (g *GatewayWsServer) OnOpen(conn socket.ISocketConn) ([]byte, socket.Action) {
|
||||
g.logger = log.GetLogger().Named(fmt.Sprintf("addr:%v", conn.RemoteAddr()))
|
||||
return nil, socket.None
|
||||
}
|
||||
|
||||
func (g *GatewayWsServer) OnHandShake(conn socket.ISocketConn) socket.Action {
|
||||
token, ok := conn.GetParam("token").(string)
|
||||
if !ok {
|
||||
g.logger.Warnf("token is invalid")
|
||||
return socket.Close
|
||||
}
|
||||
|
||||
cli := client.NewClient(conn)
|
||||
conn.SetParam("client", cli)
|
||||
if !login.GetLoginQueue().AddToLoginQueue(&login.User{Cli: cli, Token: token}) {
|
||||
g.logger.Warnf("AddToLoginQueue err, login queue full")
|
||||
return socket.Close
|
||||
}
|
||||
return socket.None
|
||||
}
|
||||
|
||||
func (g *GatewayWsServer) OnMessage(conn socket.ISocketConn, bytes []byte) socket.Action {
|
||||
cli, ok := conn.GetParam("client").(*client.Client)
|
||||
if !ok || cli.USN == 0 || cli.Status != 1 {
|
||||
return socket.Close
|
||||
}
|
||||
cli.OnEvent(&client.ClientEvent{Msg: bytes})
|
||||
return socket.None
|
||||
}
|
||||
|
||||
func (g *GatewayWsServer) OnPong(conn socket.ISocketConn) {
|
||||
cli, ok := conn.GetParam("client").(*client.Client)
|
||||
if !ok || cli.USN == 0 {
|
||||
return
|
||||
}
|
||||
cli.OnEvent(&client.PongEvent{})
|
||||
}
|
||||
|
||||
func (g *GatewayWsServer) OnClose(_ socket.ISocketConn, _ error) socket.Action {
|
||||
return socket.Close
|
||||
}
|
||||
|
||||
func (g *GatewayWsServer) OnTick() (time.Duration, socket.Action) {
|
||||
return 5 * time.Second, socket.None
|
||||
}
|
||||
52
internal/testutil/suite.go
Normal file
52
internal/testutil/suite.go
Normal file
@@ -0,0 +1,52 @@
|
||||
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{
|
||||
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() {
|
||||
}
|
||||
18
main.go
Normal file
18
main.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/app"
|
||||
"git.hlsq.asia/mmorpg/service-gateway/config"
|
||||
"github.com/judwhite/go-svc"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := config.LoadConfig(); err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
if err := svc.Run(&app.Program{}, syscall.SIGINT, syscall.SIGTERM, syscall.SIGKILL); err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user