Compare commits

..

62 Commits

Author SHA1 Message Date
6ffe49ff5b feat 初始化 2026-10-29 11:28:42 +08:00
09c1df8a22 feat 初始化 2026-10-29 10:12:22 +08:00
332d812347 feat 修改包路径 2026-10-28 16:21:44 +08:00
c39cea8656 feat 修改包路径 2026-10-28 15:58:42 +08:00
9439be8a60 feat 自定义问答 2026-03-11 20:17:58 +08:00
558677bc3a feat 包命名规范 2026-02-11 14:48:21 +08:00
0ca8a0ccbb feat 基础模块拆分为雪花和日志模块 2026-02-07 13:13:02 +08:00
5a0f4b71d4 feat 模块删除bind函数 2026-02-06 22:51:47 +08:00
44ebbe4449 feat 废弃jwt 2026-02-06 22:22:43 +08:00
5dc5391b07 feat sn 改成 int64 2026-01-30 11:53:20 +08:00
427fca7ed1 feat kafka 改版 2 2026-01-30 10:53:00 +08:00
a2251b9cb7 feat kafka 改版 1 2026-01-29 16:20:29 +08:00
be7b922cbf feat qgdzs协议 2026-01-28 10:13:22 +08:00
a93b5fd1aa feat kafka 2026-01-27 17:14:05 +08:00
7271181501 feat 协议 2026-01-26 01:02:04 +08:00
f22d22cbdc feat tracer 2026-01-25 17:16:51 +08:00
81e422d304 feat kafka 2026-01-24 22:46:15 +08:00
b45df9c4ee feat kafka 2026-01-24 21:46:14 +08:00
4d661d0813 feat kafka 2026-01-23 21:22:58 +08:00
1edebb439c feat 默认模块 2026-01-20 12:07:18 +08:00
a47557920c feat grpc模块 2026-01-19 10:53:13 +08:00
22d48542a8 feat 服务发现模块 2026-01-18 00:06:58 +08:00
3de703eb83 feat 自定义拦截器 2026-01-16 23:50:14 +08:00
d944729ad0 feat Prometheus 2026-01-16 22:34:17 +08:00
e59d106700 feat 链路追踪 2026-01-16 22:01:35 +08:00
7cb057fc91 feat 协议 2026-01-14 19:03:46 +08:00
7aaa54403b feat 协议 2026-01-14 18:50:48 +08:00
da4b2dff49 feat 协议 2026-01-14 18:45:56 +08:00
695f5e7b04 feat 删除-拦截器取usn 2026-01-14 18:09:22 +08:00
a2025e8901 feat 拦截器取usn 2026-01-14 16:00:26 +08:00
53d4e4513e feat 协议 2026-01-14 15:32:42 +08:00
8e2d96844e feat 协议 2026-01-14 15:27:26 +08:00
9518f3da5f feat grpc客户端整理 2026-01-14 14:44:49 +08:00
29d5444082 feat 协议 2026-01-14 14:33:22 +08:00
1c90e21050 feat 错误码 2026-01-14 14:21:41 +08:00
6aefdaf650 feat 协议 2026-01-14 12:01:42 +08:00
34b2e45e3d feat 协议 2026-01-13 17:54:15 +08:00
7812a3c669 feat 协议 2026-01-13 09:46:17 +08:00
faf46e2bba feat 协议 2026-01-13 00:09:30 +08:00
b678307d61 feat 协议 2026-01-12 20:32:58 +08:00
d502d615fe feat 协议 2026-01-12 16:57:32 +08:00
8e4dc3e339 feat 拆出qgdzs 2026-01-12 16:53:40 +08:00
b1e7d33940 feat 增加grpc客户端 2026-01-12 16:22:58 +08:00
375b41c245 feat 定义服务 2026-01-12 16:10:03 +08:00
479282ccfd feat 协议 2026-01-12 15:57:05 +08:00
d433cd03a9 feat sc改名ss 2026-01-12 12:06:22 +08:00
ec291d4332 feat ss改名rs 2026-01-12 11:53:11 +08:00
8c09b125a4 feat ss改名rs 2026-01-12 11:46:51 +08:00
0be254c6a2 feat 协议 2026-01-10 23:30:08 +08:00
015e333b88 feat usn sid 改成string 2026-01-10 16:13:19 +08:00
8c6614578b feat usn sid 改成string 2026-01-10 16:02:23 +08:00
e209ec64af feat 协议 2026-01-10 15:33:11 +08:00
4b8db63ba4 feat 协议 2026-01-10 10:44:06 +08:00
a73797b3bc feat 协议 2026-01-10 10:11:25 +08:00
f312ac4f3c feat 协议 2026-01-10 10:04:10 +08:00
c5d30adafd feat 协议 2026-01-10 00:21:53 +08:00
4d8501c3a9 feat 协议 2026-01-09 21:31:28 +08:00
f381510a0d feat 协议 2026-01-09 14:08:41 +08:00
69e82ec0fe feat redis 增加 HDel 2026-01-08 22:45:40 +08:00
e02e56781e feat 修改model名称 2026-01-07 14:10:47 +08:00
97c7813a24 feat 排队 2026-01-06 18:36:17 +08:00
6523820cf6 feat 单元测试 2026-01-05 00:32:24 +08:00
90 changed files with 3081 additions and 3203 deletions

23
PORTS.md Normal file
View File

@@ -0,0 +1,23 @@
# Ports
端口分配记录
---
gateway 18500-18599
---
third-party 18600-18699
---
scene 18700-18799
---
user 18800-18899
---
post 18900-18999
---
notice 19000-19099
---
admin 19200-19299
---
timer 19400-19499
---
qgdzs 1 // TODO
---

View File

@@ -169,3 +169,25 @@ user-service/
> 🌟 **好的微服务架构不是设计出来的,而是在约束和实践中演化出来的。** > 🌟 **好的微服务架构不是设计出来的,而是在约束和实践中演化出来的。**
--- ---
# 增加服务器步骤
代码
1. go module 命名:`git.hlsq.asia/alex/service-${服务名}`
2. `deploy、config` 修改
common
1. 在 `discover\common\define.go` 定义服务发现
2. 在 `net\grpc\grpcclient` 实现客户端发现
public
1. 在 `Proto\RpcServer\sources` 定义gRPC服务
db
1. 创建独立db,命名为`${服务名}_db`
quickly
1. `MySQL Model` 增加数据库配置
gateway
1. 在 `internal\net\httpgateway\router.go` 定义路由

View File

@@ -17,6 +17,10 @@ type MetricConfig struct {
Address string `yaml:"address"` Address string `yaml:"address"`
Port int32 `yaml:"port"` Port int32 `yaml:"port"`
} `yaml:"prometheus"` } `yaml:"prometheus"`
Jaeger *struct {
Endpoint string `yaml:"endpoint"`
SamplingRate float64 `yaml:"samplingRate"`
} `yaml:"jaeger"`
} }
type DBConfig struct { type DBConfig struct {
@@ -24,6 +28,7 @@ type DBConfig struct {
MySQL map[string]*MySQLConfig `yaml:"mysql"` MySQL map[string]*MySQLConfig `yaml:"mysql"`
Mongo map[string]*MongoConfig `yaml:"mongo"` Mongo map[string]*MongoConfig `yaml:"mongo"`
Redis *RedisConfig `yaml:"redis"` Redis *RedisConfig `yaml:"redis"`
Kafka *KafkaConfig `yaml:"kafka"`
} }
type EtcdConfig struct { type EtcdConfig struct {
@@ -49,12 +54,12 @@ type RedisConfig struct {
DB int `yaml:"db"` DB int `yaml:"db"`
} }
type KafkaConfig struct {
Brokers []string `yaml:"brokers"`
}
type ServeConfig struct { type ServeConfig struct {
Grpc *struct { Grpc *GrpcConfig `yaml:"grpc"`
Address string `yaml:"address"`
Port int32 `yaml:"port"`
TTL int64 `yaml:"ttl"`
} `yaml:"grpc"`
Socket *struct { Socket *struct {
Web *AddressConfig `yaml:"web"` Web *AddressConfig `yaml:"web"`
Raw *AddressConfig `yaml:"raw"` Raw *AddressConfig `yaml:"raw"`
@@ -62,6 +67,12 @@ type ServeConfig struct {
Http *AddressConfig `yaml:"http"` Http *AddressConfig `yaml:"http"`
} }
type GrpcConfig struct {
Address string `yaml:"address"`
Port int32 `yaml:"port"`
TTL int64 `yaml:"ttl"`
}
type AddressConfig struct { type AddressConfig struct {
Address string `yaml:"address"` Address string `yaml:"address"`
Port int32 `yaml:"port"` Port int32 `yaml:"port"`

View File

@@ -4,13 +4,30 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/spf13/viper" "github.com/spf13/viper"
"os"
"strings" "strings"
"sync"
) )
const ( const (
envConfigPrefix = "XH_G" envConfigPrefix = "XH_G"
) )
var (
currentEnv EnvType // 当前环境变量
currentEnvOnce sync.Once
currentCommit string // 当前提交的CommitID
currentCommitOnce sync.Once
)
type EnvType string
const (
EnvDev EnvType = "dev"
EnvTest EnvType = "test"
EnvProd EnvType = "prod"
)
// LoadConfig 加载并返回应用配置 // LoadConfig 加载并返回应用配置
func LoadConfig[T any](configDir string, configPtr *T) (*T, error) { func LoadConfig[T any](configDir string, configPtr *T) (*T, error) {
v := viper.New() v := viper.New()
@@ -40,3 +57,27 @@ func LoadConfig[T any](configDir string, configPtr *T) (*T, error) {
fmt.Printf("Configuration loading completed: %v\n", string(marshal)) fmt.Printf("Configuration loading completed: %v\n", string(marshal))
return configPtr, nil return configPtr, nil
} }
// Env 获取环境
func Env() EnvType {
currentEnvOnce.Do(func() {
if v, ok := os.LookupEnv(envConfigPrefix + "_ENV"); ok {
currentEnv = EnvType(v)
} else {
currentEnv = EnvDev
}
})
return currentEnv
}
// Commit 获取提交ID
func Commit() string {
currentCommitOnce.Do(func() {
if v, ok := os.LookupEnv(envConfigPrefix + "_COMMIT"); ok {
currentCommit = v
} else {
currentCommit = "unknown"
}
})
return currentCommit
}

View File

@@ -1,48 +0,0 @@
package db
import (
"common/config"
"common/db/etcd"
"common/db/mysql"
"common/db/redis"
"common/log"
)
// ModuleDB 数据库模块
type ModuleDB struct {
}
func (p *ModuleDB) Init(cfg *config.DBConfig) error {
// ETCD
if cfg.Etcd != nil {
if err := etcd.Init(cfg.Etcd); err != nil {
return err
}
}
// MYSQL
if cfg.MySQL != nil {
if err := mysql.Init(cfg.MySQL); err != nil {
return err
}
}
// REDIS
if cfg.Redis != nil {
if err := redis.Init(cfg.Redis); err != nil {
return err
}
}
return nil
}
func (p *ModuleDB) Stop() error {
if err := etcd.Close(); err != nil {
log.Errorf("close etcd failed: %v", err)
}
if err := mysql.Close(); err != nil {
log.Errorf("close mysql failed: %v", err)
}
if err := redis.Close(); err != nil {
log.Errorf("close redis failed: %v", err)
}
return nil
}

View File

@@ -1,8 +1,8 @@
package etcd package etcd
import ( import (
"common/config"
"context" "context"
"git.hlsq.asia/alex/service-common/config"
"go.etcd.io/etcd/client/v3" "go.etcd.io/etcd/client/v3"
"time" "time"
) )
@@ -37,6 +37,10 @@ func GetClient() *Client {
return instance return instance
} }
func (c *Client) Raw() *clientv3.Client {
return c.cli
}
// Get 获取数据 // Get 获取数据
func (c *Client) Get(key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error) { func (c *Client) Get(key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error) {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)

41
db/kafka/carrier.go Normal file
View File

@@ -0,0 +1,41 @@
package kafka
import (
"context"
"github.com/IBM/sarama"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/propagation"
)
type Carrier struct {
}
func NewCarrier() *Carrier {
return &Carrier{}
}
func (c *Carrier) Inject(ctx context.Context) []sarama.RecordHeader {
headers := make([]sarama.RecordHeader, 0)
carrier := propagation.MapCarrier{}
otel.GetTextMapPropagator().Inject(ctx, carrier)
for k, v := range carrier {
headers = append(headers, sarama.RecordHeader{Key: []byte(k), Value: []byte(v)})
}
return headers
}
func (c *Carrier) ExtractConsumer(headers []*sarama.RecordHeader) context.Context {
carrier := propagation.MapCarrier{}
for _, header := range headers {
carrier[string(header.Key)] = string(header.Value)
}
return otel.GetTextMapPropagator().Extract(context.Background(), carrier)
}
func (c *Carrier) ExtractProducer(headers []sarama.RecordHeader) context.Context {
carrier := propagation.MapCarrier{}
for _, header := range headers {
carrier[string(header.Key)] = string(header.Value)
}
return otel.GetTextMapPropagator().Extract(context.Background(), carrier)
}

60
db/kafka/client.go Normal file
View File

@@ -0,0 +1,60 @@
package kafka
import (
"git.hlsq.asia/alex/service-common/config"
"github.com/IBM/sarama"
"time"
)
var client *Client
type Client struct {
producer sarama.AsyncProducer
consumer sarama.ConsumerGroup
}
func Init(cfg *config.KafkaConfig, appName string) error {
producer, err := getAsyncProducer(cfg)
if err != nil {
return err
}
consumer, err := getConsumer(cfg, appName)
if err != nil {
return err
}
client = &Client{
producer: producer,
consumer: consumer,
}
go producerError()
go consumerError()
return nil
}
func getAsyncProducer(cfg *config.KafkaConfig) (sarama.AsyncProducer, error) {
conf := sarama.NewConfig()
conf.Producer.RequiredAcks = sarama.WaitForAll
conf.Producer.Return.Errors = true
conf.Producer.Retry.Max = 5
conf.Producer.Retry.Backoff = 100 * time.Millisecond
return sarama.NewAsyncProducer(cfg.Brokers, conf)
}
func getConsumer(cfg *config.KafkaConfig, appName string) (sarama.ConsumerGroup, error) {
conf := sarama.NewConfig()
conf.Consumer.Return.Errors = true
conf.Consumer.Group.Session.Timeout = 10 * time.Second
conf.Consumer.Offsets.AutoCommit.Enable = true
conf.Consumer.Offsets.Initial = sarama.OffsetOldest
return sarama.NewConsumerGroup(cfg.Brokers, appName, conf)
}
func Close() error {
if client != nil && client.producer != nil {
_ = client.producer.Close()
}
if client != nil && client.consumer != nil {
_ = client.consumer.Close()
}
return nil
}

147
db/kafka/consumer.go Normal file
View File

@@ -0,0 +1,147 @@
package kafka
import (
"context"
"encoding/json"
"errors"
"fmt"
"git.hlsq.asia/alex/service-common/log"
"git.hlsq.asia/alex/service-common/utils"
"github.com/IBM/sarama"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
otelcodes "go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/trace"
"reflect"
"sync"
"time"
)
func NewConsumer() *Consumer {
ctx, cancel := context.WithCancel(context.Background())
return &Consumer{
ctx: ctx,
cancel: cancel,
}
}
type Consumer struct {
ctx context.Context
cancel context.CancelFunc
}
func (c *Consumer) Consume(t []Topic) {
for {
topicArr := make([]string, 0)
handlerMap := make(map[string]*sync.Pool)
for _, v := range t {
topicArr = append(topicArr, v.Name())
typ := reflect.ValueOf(v).Elem().Type()
handlerMap[v.Name()] = &sync.Pool{New: func() interface{} {
return reflect.New(typ).Interface()
}}
}
err := client.consumer.Consume(c.ctx, topicArr, &handler{
handler: handlerMap,
})
if errors.Is(err, context.Canceled) || errors.Is(c.ctx.Err(), context.Canceled) {
return
}
time.Sleep(time.Second)
}
}
func (c *Consumer) Stop() error {
c.cancel()
return client.consumer.Close()
}
type Handler func(context.Context, []byte) error
type handler struct {
handler map[string]*sync.Pool
}
func (h *handler) Setup(_ sarama.ConsumerGroupSession) error {
return nil
}
func (h *handler) Cleanup(sess sarama.ConsumerGroupSession) error {
sess.Commit()
return nil
}
func (h *handler) ConsumeClaim(sess sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim) error {
for {
select {
case message, ok := <-claim.Messages():
if ok {
ctx := NewCarrier().ExtractConsumer(message.Headers)
_, span := otel.Tracer("common.db.kafka").Start(ctx, "kafka.consume")
pool := h.handler[message.Topic]
if pool == nil {
span.SetStatus(otelcodes.Error, "handler not found")
span.End()
return utils.ErrorsWrap(errors.New("handler not found"))
}
span.SetAttributes(attribute.String("kafka.topic", message.Topic))
span.SetAttributes(attribute.String("kafka.message", string(message.Value)))
newCb := pool.Get().(Topic)
if err := json.Unmarshal(message.Value, newCb); err != nil {
releaseTopicObject(pool, newCb)
span.SetStatus(otelcodes.Error, "handler json.Unmarshal error")
span.End()
return utils.ErrorsWrap(err, "handler json.Unmarshal error")
}
if err := func() (err error) {
defer func() {
if e := recover(); e != nil {
span.SetStatus(otelcodes.Error, fmt.Sprintf("%v", e))
span.End()
err = fmt.Errorf("kafka handler panic: %v", e)
}
}()
if err = newCb.OnMessage(ctx); err != nil {
if stack, ok := err.(interface{ StackTrace() string }); ok {
span.AddEvent("Stack Trace", trace.WithAttributes(
attribute.String("stack.trace", fmt.Sprintf("%v", stack.StackTrace())),
))
}
span.SetStatus(otelcodes.Error, err.Error())
span.End()
log.Errorf("kafka handler error: %v", err)
err = utils.ErrorsWrap(err, "kafka handler error")
}
return
}(); err != nil {
releaseTopicObject(pool, newCb)
return err
}
sess.MarkMessage(message, "")
releaseTopicObject(pool, newCb)
span.End()
}
case <-sess.Context().Done():
log.Warnf("kafka session done, reason: %v", sess.Context().Err())
sess.Commit()
return sess.Context().Err()
}
}
}
// 回收Topic对象
func releaseTopicObject(pool *sync.Pool, obj Topic) {
v := reflect.ValueOf(obj).Elem()
v.Set(reflect.Zero(v.Type()))
pool.Put(obj)
}
func consumerError() {
for err := range client.consumer.Errors() {
log.Errorf("kafka consumer error: %v", err)
}
}

48
db/kafka/producer.go Normal file
View File

@@ -0,0 +1,48 @@
package kafka
import (
"context"
"encoding/json"
"errors"
"github.com/IBM/sarama"
"go.opentelemetry.io/otel"
otelcodes "go.opentelemetry.io/otel/codes"
"strconv"
)
var ProduceTimeoutError = errors.New("kafka producer timeout")
func NewProducer(key int64) *Producer {
return &Producer{
key: key,
}
}
type Producer struct {
key int64
}
func (c *Producer) Produce(ctx context.Context, data Topic) error {
marshal, _ := json.Marshal(data)
msg := &sarama.ProducerMessage{
Topic: data.Name(),
Key: sarama.StringEncoder(strconv.FormatInt(c.key, 10)),
Value: sarama.ByteEncoder(marshal),
Headers: NewCarrier().Inject(ctx),
}
select {
case client.producer.Input() <- msg:
return nil
case <-ctx.Done():
return ProduceTimeoutError
}
}
func producerError() {
for err := range client.producer.Errors() {
ctx := NewCarrier().ExtractProducer(err.Msg.Headers)
_, span := otel.Tracer("common.db.kafka").Start(ctx, "kafka.producer.error")
span.SetStatus(otelcodes.Error, err.Error())
span.End()
}
}

8
db/kafka/topic.go Normal file
View File

@@ -0,0 +1,8 @@
package kafka
import "context"
type Topic interface {
Name() string
OnMessage(context.Context) error
}

View File

@@ -1,11 +1,20 @@
package mongo package mongo
import ( import (
"common/config"
"common/log"
"context" "context"
"git.hlsq.asia/alex/service-common/config"
"git.hlsq.asia/alex/service-common/log"
"go.mongodb.org/mongo-driver/event"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/options"
"go.mongodb.org/mongo-driver/mongo/readpref"
"time"
)
// Colors
const (
Reset = "\033[0m"
BrightGreen = "\033[92m"
) )
type DBName string type DBName string
@@ -25,12 +34,27 @@ func Init(cfg map[string]*config.MongoConfig) error {
func initOneClient(cfg *config.MongoConfig) (*mongo.Client, error) { func initOneClient(cfg *config.MongoConfig) (*mongo.Client, error) {
opts := options.Client(). opts := options.Client().
ApplyURI(cfg.URI) ApplyURI(cfg.URI).
SetMonitor(&event.CommandMonitor{
Started: func(ctx context.Context, startedEvent *event.CommandStartedEvent) {
log.Infof(BrightGreen+"[MongoDB] Started, Command: %v"+Reset, startedEvent.Command.String())
},
Failed: func(ctx context.Context, failedEvent *event.CommandFailedEvent) {
log.Errorf(BrightGreen+"[MongoDB] [%v] Failed, Failure: %v"+Reset, failedEvent.Duration, failedEvent.Failure)
},
})
client, err := mongo.Connect(context.Background(), opts) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
client, err := mongo.Connect(ctx, opts)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if err = client.Ping(ctx, readpref.Primary()); err != nil {
_ = client.Disconnect(context.Background())
return nil, err
}
return client, nil return client, nil
} }

View File

@@ -1,8 +1,8 @@
package mysql package mysql
import ( import (
"common/config" "git.hlsq.asia/alex/service-common/config"
"common/log" "git.hlsq.asia/alex/service-common/log"
"gorm.io/driver/mysql" "gorm.io/driver/mysql"
"gorm.io/gorm" "gorm.io/gorm"
"gorm.io/gorm/logger" "gorm.io/gorm/logger"
@@ -29,7 +29,7 @@ func initOneDB(cfg *config.MySQLConfig) (*gorm.DB, error) {
mysql.Open(cfg.Dsn), mysql.Open(cfg.Dsn),
&gorm.Config{ &gorm.Config{
TranslateError: true, TranslateError: true,
Logger: logger.Default.LogMode(parseLogLevel(cfg.LogLevel)), Logger: NewGormLogger(parseLogLevel(cfg.LogLevel)),
}, },
) )
if err != nil { if err != nil {

84
db/mysql/log.go Normal file
View File

@@ -0,0 +1,84 @@
package mysql
import (
"context"
"errors"
"fmt"
"git.hlsq.asia/alex/service-common/log"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.uber.org/zap"
"gorm.io/gorm"
"gorm.io/gorm/logger"
"time"
)
// Colors
const (
Reset = "\033[0m"
Blue = "\033[34m"
)
type GormLogger struct {
logLevel logger.LogLevel
logger *zap.SugaredLogger
}
func NewGormLogger(level logger.LogLevel) *GormLogger {
return &GormLogger{
logLevel: level,
logger: log.GetLogger().
WithOptions(zap.AddCallerSkip(5)).
Named("GORM"),
}
}
func (l *GormLogger) LogMode(level logger.LogLevel) logger.Interface {
newLogger := *l
newLogger.logLevel = level
return &newLogger
}
func (l *GormLogger) Info(ctx context.Context, msg string, data ...interface{}) {
if l.logLevel >= logger.Info {
l.logger.Infof(Blue+msg+Reset, data...)
}
}
func (l *GormLogger) Warn(ctx context.Context, msg string, data ...interface{}) {
if l.logLevel >= logger.Warn {
l.logger.Warnf(Blue+msg+Reset, data...)
}
}
func (l *GormLogger) Error(ctx context.Context, msg string, data ...interface{}) {
if l.logLevel >= logger.Error {
l.logger.Errorf(Blue+msg+Reset, data...)
}
}
func (l *GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (sql string, rowsAffected int64), err error) {
if l.logLevel <= logger.Silent {
return
}
elapsed := time.Since(begin)
sql, rows := fc()
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
l.logger.Errorf(Blue+"[SLOW SQL] [%v] [rows:%v] [error: %v] %v"+Reset, elapsed, rows, err.Error(), sql)
l.SlowLog(ctx, elapsed, sql)
} else if elapsed > 50*time.Millisecond {
l.logger.Warnf(Blue+"[SLOW SQL] [%v] [rows:%v] %v"+Reset, elapsed, rows, sql)
l.SlowLog(ctx, elapsed, sql)
} else {
l.logger.Infof(Blue+"[%v] [rows:%v] %v"+Reset, elapsed, rows, sql)
}
}
func (l *GormLogger) SlowLog(ctx context.Context, elapsed time.Duration, sql string) {
_, span := otel.Tracer("common.db.mysql").Start(ctx, "mysql.slow")
defer span.End()
span.SetAttributes(attribute.String("elapsed", fmt.Sprintf("%v", elapsed)))
span.SetAttributes(attribute.String("sql", sql))
}

View File

@@ -48,3 +48,11 @@ func (c *CacheClient) Get(ctx context.Context, key string, dst interface{}) bool
} }
return true return true
} }
func (c *CacheClient) Exists(ctx context.Context, key ...string) bool {
n, err := c.cli.Exists(ctx, key...).Result()
if err != nil {
return false
}
return n > 0
}

View File

@@ -1,17 +1,16 @@
package redis package redis
import ( import (
"common/config"
"common/log"
"context" "context"
"git.hlsq.asia/alex/service-common/config"
"git.hlsq.asia/alex/service-common/log"
"github.com/redis/go-redis/v9" "github.com/redis/go-redis/v9"
"time"
) )
var instance *Client var instance *Client
type Client struct { type Client struct {
cli *redis.Client *redis.Client
} }
func Init(cfg *config.RedisConfig) error { func Init(cfg *config.RedisConfig) error {
@@ -21,11 +20,13 @@ func Init(cfg *config.RedisConfig) error {
DB: cfg.DB, DB: cfg.DB,
}) })
instance = &Client{ instance = &Client{
cli: client, Client: client,
} }
cacheInstance = &CacheClient{ cacheInstance = &CacheClient{
cli: client, cli: client,
logger: log.GetLogger().Named("CACHE"), }
if logger := log.GetLogger(); logger != nil {
cacheInstance.logger = logger.Named("CACHE")
} }
_, err := client.Ping(context.Background()).Result() _, err := client.Ping(context.Background()).Result()
@@ -33,8 +34,8 @@ func Init(cfg *config.RedisConfig) error {
} }
func Close() error { func Close() error {
if instance != nil && instance.cli != nil { if instance != nil && instance.Client != nil {
return instance.cli.Close() return instance.Client.Close()
} }
return nil return nil
} }
@@ -42,12 +43,3 @@ func Close() error {
func GetClient() *Client { func GetClient() *Client {
return instance return instance
} }
func (c *Client) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd {
return c.cli.Set(ctx, key, value, expiration)
}
// Get 获取数据
func (c *Client) Get(ctx context.Context, key string) *redis.StringCmd {
return c.cli.Get(ctx, key)
}

View File

@@ -10,21 +10,33 @@ const (
) )
var ( var (
KeyDiscover = "xh-discover" KeyDiscover = "/discover"
KeyDiscoverService = KeyDiscover + "/service" KeyDiscoverService = KeyDiscover + "/service"
KeyDiscoverInstance = KeyDiscover + "/instance" KeyDiscoverInstance = KeyDiscover + "/instance"
) )
var ( var (
KeyDiscoverServiceNameGateway = "gateway" // 网关服 KeyDiscoverServiceNameGateway = "01-gateway" // 网关服
KeyDiscoverServiceNameScene = "scene" // 场景服 KeyDiscoverServiceNameScene = "02-scene" // 场景服
KeyDiscoverServiceNameUser = "user" // 用户中心 KeyDiscoverServiceNameUser = "03-user" // 用户中心
KeyDiscoverServiceNameThirdParty = "04-third-party" // 三方服
KeyDiscoverServiceNamePost = "05-post" // 推送服
KeyDiscoverServiceNameNotice = "06-notice" // 公告服
KeyDiscoverServiceNameAdmin = "07-admin" // 后台服
KeyDiscoverServiceNameTimer = "08-timer" // 定时任务服(只起一个)
KeyDiscoverServiceNameQgdzs = "09-qgdzs" // 奇怪的知识
) )
var ( var (
KeyDiscoverGateway = KeyDiscoverService + "/" + KeyDiscoverServiceNameGateway // 网关服 KeyDiscoverGateway = KeyDiscoverService + "/" + KeyDiscoverServiceNameGateway // 网关服
KeyDiscoverScene = KeyDiscoverService + "/" + KeyDiscoverServiceNameScene // 场景服 KeyDiscoverScene = KeyDiscoverService + "/" + KeyDiscoverServiceNameScene // 场景服
KeyDiscoverUser = KeyDiscoverService + "/" + KeyDiscoverServiceNameUser // 用户中心 KeyDiscoverUser = KeyDiscoverService + "/" + KeyDiscoverServiceNameUser // 用户中心
KeyDiscoverThirdParty = KeyDiscoverService + "/" + KeyDiscoverServiceNameThirdParty // 三方服
KeyDiscoverPost = KeyDiscoverService + "/" + KeyDiscoverServiceNamePost // 推送服
KeyDiscoverNotice = KeyDiscoverService + "/" + KeyDiscoverServiceNameNotice // 公告服
KeyDiscoverAdmin = KeyDiscoverService + "/" + KeyDiscoverServiceNameAdmin // 后台服
KeyDiscoverTimer = KeyDiscoverService + "/" + KeyDiscoverServiceNameTimer // 定时任务服(只起一个)
KeyDiscoverQgdzs = KeyDiscoverService + "/" + KeyDiscoverServiceNameQgdzs // 奇怪的知识
) )
// ServiceProvider 服务提供者 // ServiceProvider 服务提供者
@@ -38,5 +50,5 @@ type ServiceProvider struct {
type InstanceProvider struct { type InstanceProvider struct {
InstanceID int // 副本ID InstanceID int // 副本ID
UniqueNo int64 // 副本唯一编号 UniqueNo int64 // 副本唯一编号
SID string SID int64
} }

View File

@@ -1,8 +1,8 @@
package common package common
import ( import (
"common/db/etcd" "git.hlsq.asia/alex/service-common/db/etcd"
"common/log" "git.hlsq.asia/alex/service-common/log"
clientv3 "go.etcd.io/etcd/client/v3" clientv3 "go.etcd.io/etcd/client/v3"
) )

View File

@@ -1,19 +1,19 @@
package discover package discover
import ( import (
"common/db/etcd"
"common/discover/common"
"common/log"
"fmt" "fmt"
"git.hlsq.asia/alex/service-common/db/etcd"
"git.hlsq.asia/alex/service-common/discover/common"
"git.hlsq.asia/alex/service-common/log"
"git.hlsq.asia/alex/service-common/utils"
clientv3 "go.etcd.io/etcd/client/v3" clientv3 "go.etcd.io/etcd/client/v3"
"strconv"
"sync" "sync"
) )
// 大量读少量写的情况下,读写锁比同步Map更高效 // 大量读少量写的情况下,读写锁比同步Map更高效
var ( var (
instanceMU = sync.RWMutex{} instanceMU = sync.RWMutex{}
instanceM = make(map[int64]string) // [uniqueNo]sid instanceM = make(map[int64]int64) // [uniqueNo]sid
instanceLeaseM = make(map[int64]clientv3.LeaseID) // [uniqueNo] instanceLeaseM = make(map[int64]clientv3.LeaseID) // [uniqueNo]
) )
@@ -23,7 +23,7 @@ func init() {
} }
// FindInstanceByUniqueNo 根据唯一标识查询副本 // FindInstanceByUniqueNo 根据唯一标识查询副本
func FindInstanceByUniqueNo(uniqueNO int64) (sid string) { func FindInstanceByUniqueNo(uniqueNO int64) (sid int64) {
instanceMU.RLock() instanceMU.RLock()
defer instanceMU.RUnlock() defer instanceMU.RUnlock()
if c, ok := instanceM[uniqueNO]; ok { if c, ok := instanceM[uniqueNO]; ok {
@@ -33,7 +33,7 @@ func FindInstanceByUniqueNo(uniqueNO int64) (sid string) {
} }
// RegisterInstance 注册副本 // RegisterInstance 注册副本
func RegisterInstance(sid int64, instanceID int32, uniqueNo, ttl int64) error { func RegisterInstance(sid int64, instanceID int32, uniqueNo int64, ttl int64) error {
serverMU.Lock() serverMU.Lock()
defer serverMU.Unlock() defer serverMU.Unlock()
leaseID, err := common.NewLeaseAndKeepAlive(ttl) leaseID, err := common.NewLeaseAndKeepAlive(ttl)
@@ -41,7 +41,7 @@ func RegisterInstance(sid int64, instanceID int32, uniqueNo, ttl int64) error {
return err return err
} }
key := fmt.Sprintf("%v/%v/%v", common.KeyDiscoverInstance, instanceID, uniqueNo) key := fmt.Sprintf("%v/%v/%v", common.KeyDiscoverInstance, instanceID, uniqueNo)
_, err = etcd.GetClient().Put(key, strconv.Itoa(int(sid)), clientv3.WithLease(leaseID)) _, err = etcd.GetClient().Put(key, utils.Int64ToString(sid), clientv3.WithLease(leaseID))
if err != nil { if err != nil {
return err return err
} }

View File

@@ -1,12 +1,12 @@
package discover package discover
import ( import (
"common/db/etcd"
"common/discover/common"
"common/log"
"common/utils"
"context" "context"
"fmt" "fmt"
"git.hlsq.asia/alex/service-common/db/etcd"
"git.hlsq.asia/alex/service-common/discover/common"
"git.hlsq.asia/alex/service-common/log"
"git.hlsq.asia/alex/service-common/utils"
"go.etcd.io/etcd/api/v3/mvccpb" "go.etcd.io/etcd/api/v3/mvccpb"
clientv3 "go.etcd.io/etcd/client/v3" clientv3 "go.etcd.io/etcd/client/v3"
"strconv" "strconv"
@@ -42,7 +42,7 @@ func onCBByType(t common.ListenerType, data any) {
} }
} }
func Listen() { func Listen(ready *sync.WaitGroup) {
var stopCtx context.Context var stopCtx context.Context
stopCtx, stopFunc = context.WithCancel(context.Background()) stopCtx, stopFunc = context.WithCancel(context.Background())
wg.Add(1) wg.Add(1)
@@ -61,6 +61,8 @@ func Listen() {
onInstanceChange(clientv3.EventTypePut, string(kv.Key), string(kv.Value), nil) onInstanceChange(clientv3.EventTypePut, string(kv.Key), string(kv.Value), nil)
} }
chInstance := etcd.GetClient().Watch(common.KeyDiscoverScene, clientv3.WithPrefix(), clientv3.WithRev(instanceAll.Header.Revision+1), clientv3.WithPrevKV()) chInstance := etcd.GetClient().Watch(common.KeyDiscoverScene, clientv3.WithPrefix(), clientv3.WithRev(instanceAll.Header.Revision+1), clientv3.WithPrevKV())
// 准备好了
ready.Done()
for { for {
select { select {
case msg := <-chService: case msg := <-chService:
@@ -81,20 +83,20 @@ func Listen() {
// 服务发生变化 // 服务发生变化
func onServerChange(t mvccpb.Event_EventType, key, value string) { func onServerChange(t mvccpb.Event_EventType, key, value string) {
split := strings.Split(key, "/") split := strings.Split(key, "/")
if len(split) != 4 { if len(split) != 5 {
return return
} }
switch t { switch t {
case clientv3.EventTypePut: case clientv3.EventTypePut:
onCBByType(common.ListenerTypeNewServer, &common.ServiceProvider{ onCBByType(common.ListenerTypeNewServer, &common.ServiceProvider{
Target: common.KeyDiscoverService + "/" + split[2], Target: common.KeyDiscoverService + "/" + split[3],
SID: utils.StringToInt64(split[3]), SID: utils.StringToInt64(split[4]),
Addr: value, Addr: value,
}) })
case clientv3.EventTypeDelete: case clientv3.EventTypeDelete:
onCBByType(common.ListenerTypeCloseServer, &common.ServiceProvider{ onCBByType(common.ListenerTypeCloseServer, &common.ServiceProvider{
Target: common.KeyDiscoverService + "/" + split[2], Target: common.KeyDiscoverService + "/" + split[3],
SID: utils.StringToInt64(split[3]), SID: utils.StringToInt64(split[4]),
}) })
} }
} }
@@ -102,22 +104,22 @@ func onServerChange(t mvccpb.Event_EventType, key, value string) {
// 副本发生变化 // 副本发生变化
func onInstanceChange(t mvccpb.Event_EventType, key, value string, preKv *mvccpb.KeyValue) { func onInstanceChange(t mvccpb.Event_EventType, key, value string, preKv *mvccpb.KeyValue) {
split := strings.Split(key, "/") split := strings.Split(key, "/")
if len(split) != 4 { if len(split) != 5 {
return return
} }
instanceID, _ := strconv.Atoi(split[2]) instanceID, _ := strconv.Atoi(split[3])
switch t { switch t {
case clientv3.EventTypePut: case clientv3.EventTypePut:
onCBByType(common.ListenerTypeNewInstance, &common.InstanceProvider{ onCBByType(common.ListenerTypeNewInstance, &common.InstanceProvider{
InstanceID: instanceID, InstanceID: instanceID,
UniqueNo: utils.StringToInt64(split[3]), UniqueNo: utils.StringToInt64(split[4]),
SID: value, SID: utils.StringToInt64(value),
}) })
case clientv3.EventTypeDelete: case clientv3.EventTypeDelete:
onCBByType(common.ListenerTypeCloseInstance, &common.InstanceProvider{ onCBByType(common.ListenerTypeCloseInstance, &common.InstanceProvider{
InstanceID: instanceID, InstanceID: instanceID,
UniqueNo: utils.StringToInt64(split[3]), UniqueNo: utils.StringToInt64(split[4]),
SID: string(preKv.Value), SID: utils.StringToInt64(string(preKv.Value)),
}) })
} }
} }

View File

@@ -1,11 +1,11 @@
package discover package discover
import ( import (
"common/db/etcd"
"common/discover/common"
"common/log"
"common/net/grpc/grpc_conn"
"fmt" "fmt"
"git.hlsq.asia/alex/service-common/db/etcd"
"git.hlsq.asia/alex/service-common/discover/common"
"git.hlsq.asia/alex/service-common/log"
"git.hlsq.asia/alex/service-common/net/grpc/grpcconn"
clientv3 "go.etcd.io/etcd/client/v3" clientv3 "go.etcd.io/etcd/client/v3"
"google.golang.org/grpc" "google.golang.org/grpc"
"sync" "sync"
@@ -14,7 +14,7 @@ import (
// 大量读少量写的情况下,读写锁比同步Map更高效 // 大量读少量写的情况下,读写锁比同步Map更高效
var ( var (
serverMU = sync.RWMutex{} serverMU = sync.RWMutex{}
conn = make(map[string]*grpc_conn.GrpcConnectionMgr) conn = make(map[string]*grpcconn.GrpcConnectionMgr)
serverLeaseM = make(map[int64]clientv3.LeaseID) serverLeaseM = make(map[int64]clientv3.LeaseID)
) )
@@ -42,6 +42,15 @@ func FindServerAll(target string) map[int64]*grpc.ClientConn {
return make(map[int64]*grpc.ClientConn) return make(map[int64]*grpc.ClientConn)
} }
func FindServerAllSid(target string) []int64 {
serverMU.RLock()
defer serverMU.RUnlock()
if v, ok := conn[target]; ok {
return v.LoadAllSid()
}
return make([]int64, 0)
}
// RegisterGrpcServer 注册服务提供者 // RegisterGrpcServer 注册服务提供者
func RegisterGrpcServer(target string, sid int64, addr string, ttl int64) error { func RegisterGrpcServer(target string, sid int64, addr string, ttl int64) error {
serverMU.Lock() serverMU.Lock()
@@ -79,7 +88,7 @@ func onServerStart(data any) {
if v, ok := conn[provider.Target]; ok { if v, ok := conn[provider.Target]; ok {
v.Store(provider.SID, provider.Addr) v.Store(provider.SID, provider.Addr)
} else { } else {
mgr := grpc_conn.NewGrpcConnectionMgr() mgr := grpcconn.NewGrpcConnectionMgr()
mgr.Store(provider.SID, provider.Addr) mgr.Store(provider.SID, provider.Addr)
conn[provider.Target] = mgr conn[provider.Target] = mgr
} }

76
go.mod
View File

@@ -1,41 +1,59 @@
module common module git.hlsq.asia/alex/service-common
go 1.23.1 go 1.24.0
require ( require (
github.com/bwmarrin/snowflake v0.3.0 git.hlsq.asia/alex/proto v0.0.0-20261029023453-16bb20cbcd2e
github.com/IBM/sarama v1.46.3
github.com/gin-gonic/gin v1.11.0 github.com/gin-gonic/gin v1.11.0
github.com/gobwas/ws v1.4.0 github.com/gobwas/ws v1.4.0
github.com/golang-jwt/jwt/v5 v5.3.0 github.com/golang-jwt/jwt/v5 v5.3.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3
github.com/natefinch/lumberjack v2.0.0+incompatible github.com/natefinch/lumberjack v2.0.0+incompatible
github.com/panjf2000/gnet/v2 v2.9.7 github.com/panjf2000/gnet/v2 v2.9.7
github.com/prometheus/client_golang v1.20.5
github.com/redis/go-redis/v9 v9.10.0 github.com/redis/go-redis/v9 v9.10.0
github.com/shopspring/decimal v1.4.0
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
github.com/sony/sonyflake/v2 v2.2.0
github.com/spf13/viper v1.21.0 github.com/spf13/viper v1.21.0
github.com/stretchr/testify v1.11.1
go.etcd.io/etcd/api/v3 v3.6.1 go.etcd.io/etcd/api/v3 v3.6.1
go.etcd.io/etcd/client/v3 v3.6.1 go.etcd.io/etcd/client/v3 v3.6.1
go.mongodb.org/mongo-driver v1.17.6 go.mongodb.org/mongo-driver v1.17.6
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.64.0
go.opentelemetry.io/otel v1.39.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.39.0
go.opentelemetry.io/otel/sdk v1.39.0
go.opentelemetry.io/otel/trace v1.39.0
go.uber.org/zap v1.27.0 go.uber.org/zap v1.27.0
google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb google.golang.org/grpc v1.77.0
google.golang.org/grpc v1.71.1 google.golang.org/protobuf v1.36.11
google.golang.org/protobuf v1.36.9
gorm.io/driver/mysql v1.6.0 gorm.io/driver/mysql v1.6.0
gorm.io/gen v0.3.27
gorm.io/gorm v1.31.1 gorm.io/gorm v1.31.1
) )
require ( require (
filippo.io/edwards25519 v1.1.0 // indirect filippo.io/edwards25519 v1.1.0 // indirect
github.com/BurntSushi/toml v1.2.0 // indirect github.com/BurntSushi/toml v1.6.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bytedance/sonic v1.14.0 // indirect github.com/bytedance/sonic v1.14.0 // indirect
github.com/bytedance/sonic/loader v0.3.0 // indirect github.com/bytedance/sonic/loader v0.3.0 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cloudwego/base64x v0.1.6 // indirect github.com/cloudwego/base64x v0.1.6 // indirect
github.com/coreos/go-semver v0.3.1 // indirect github.com/coreos/go-semver v0.3.1 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // 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/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/fsnotify/fsnotify v1.9.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.8 // indirect github.com/gabriel-vasile/mimetype v1.4.8 // indirect
github.com/gin-contrib/sse v1.1.0 // 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/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.27.0 // indirect github.com/go-playground/validator/v10 v10.27.0 // indirect
@@ -48,20 +66,35 @@ require (
github.com/gogo/protobuf v1.3.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 // 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/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.9 // indirect github.com/klauspost/compress v1.18.1 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-isatty v0.0.20 // indirect
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect github.com/montanaflynn/stats v0.7.1 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/panjf2000/ants/v2 v2.11.3 // indirect github.com/panjf2000/ants/v2 v2.11.3 // indirect
github.com/pelletier/go-toml/v2 v2.2.4 // indirect github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/pierrec/lz4/v4 v4.1.22 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.62.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/quic-go/qpack v0.5.1 // indirect github.com/quic-go/qpack v0.5.1 // indirect
github.com/quic-go/quic-go v0.54.0 // indirect github.com/quic-go/quic-go v0.54.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9 // indirect
github.com/sagikazarmark/locafero v0.11.0 // indirect github.com/sagikazarmark/locafero v0.11.0 // indirect
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect
github.com/spf13/afero v1.15.0 // indirect github.com/spf13/afero v1.15.0 // indirect
@@ -76,18 +109,23 @@ require (
github.com/xdg-go/stringprep v1.0.4 // indirect github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.6.1 // indirect go.etcd.io/etcd/client/pkg/v3 v3.6.1 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.39.0 // indirect
go.opentelemetry.io/otel/metric v1.39.0 // indirect
go.opentelemetry.io/proto/otlp v1.9.0 // indirect
go.uber.org/mock v0.5.0 // indirect go.uber.org/mock v0.5.0 // indirect
go.uber.org/multierr v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/arch v0.20.0 // indirect golang.org/x/arch v0.20.0 // indirect
golang.org/x/crypto v0.40.0 // indirect golang.org/x/crypto v0.44.0 // indirect
golang.org/x/mod v0.26.0 // indirect golang.org/x/mod v0.29.0 // indirect
golang.org/x/net v0.42.0 // indirect golang.org/x/net v0.47.0 // indirect
golang.org/x/sync v0.16.0 // indirect golang.org/x/sync v0.18.0 // indirect
golang.org/x/sys v0.35.0 // indirect golang.org/x/sys v0.39.0 // indirect
golang.org/x/text v0.28.0 // indirect golang.org/x/text v0.31.0 // indirect
golang.org/x/tools v0.35.0 // indirect golang.org/x/tools v0.38.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb // 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/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )

172
go.sum
View File

@@ -1,17 +1,23 @@
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0= git.hlsq.asia/alex/proto v0.0.0-20261029023453-16bb20cbcd2e h1:MCBfc5To7T6EuAWGJpr0U40BzJcnw9udJHOUWVr/qAE=
github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= git.hlsq.asia/alex/proto v0.0.0-20261029023453-16bb20cbcd2e/go.mod h1:f7oMNC/o7AzT+SLUw5DKHcURu55e/sAHLjtO7in1OCA=
github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk=
github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
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/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 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c= 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 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0=
github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE=
github.com/bytedance/sonic v1.14.0 h1:/OfKt8HFw0kh2rj8N0F6C/qPGRESq0BbaNZgcNXXzQQ= github.com/bytedance/sonic v1.14.0 h1:/OfKt8HFw0kh2rj8N0F6C/qPGRESq0BbaNZgcNXXzQQ=
github.com/bytedance/sonic v1.14.0/go.mod h1:WoEbx8WTcFJfzCe0hbmyTGrfjt8PzNEBdxlNUO24NhA= github.com/bytedance/sonic v1.14.0/go.mod h1:WoEbx8WTcFJfzCe0hbmyTGrfjt8PzNEBdxlNUO24NhA=
github.com/bytedance/sonic/loader v0.3.0 h1:dskwH8edlzNMctoruo8FPTJDF3vLtDT0sXZwvZJyqeA= github.com/bytedance/sonic/loader v0.3.0 h1:dskwH8edlzNMctoruo8FPTJDF3vLtDT0sXZwvZJyqeA=
github.com/bytedance/sonic/loader v0.3.0/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI= github.com/bytedance/sonic/loader v0.3.0/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
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 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= 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 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M=
@@ -25,6 +31,14 @@ 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/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 h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= 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 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= 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 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
@@ -35,8 +49,9 @@ 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-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 h1:OW/6PLjyusp2PPXtyxKHU0RbX6I/l28FTdDlae5ueWk=
github.com/gin-gonic/gin v1.11.0/go.mod h1:+iq/FyxlGzII0KHiBGjuNn4UNENUlKbGlNmc+W50Dls= github.com/gin-gonic/gin v1.11.0/go.mod h1:+iq/FyxlGzII0KHiBGjuNn4UNENUlKbGlNmc+W50Dls=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= 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 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= 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 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
@@ -75,8 +90,25 @@ github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= 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 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 h1:5ZPtiqj0JL5oKWmcsq4VMaAW5ukBEgSGXEN89zeH1Jo= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3/go.mod h1:ndYquD05frm2vACXE1nsccT4oJzjhw2arTS2cpUD1PI= 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 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= 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 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
@@ -85,46 +117,67 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= 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/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co=
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= 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 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= 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 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= 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 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= 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 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= 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 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 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 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE= github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE=
github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
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 h1:4QJd3OLAMgj7ph+yZTuX13Ld4UpgHp07nNdFX7mqFfM=
github.com/natefinch/lumberjack v2.0.0+incompatible/go.mod h1:Wi9p2TTF5DG5oU+6YfsmYQpsTIOm0B1VNzQg9Mw6nPk= 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 h1:AfI0ngBoXJmYOpDh9m516vjqoUu2sLrIVgppI9TZVpg=
github.com/panjf2000/ants/v2 v2.11.3/go.mod h1:8u92CYMUc6gyvTIw8Ru7Mt7+/ESnJahz5EVtqfrilek= github.com/panjf2000/ants/v2 v2.11.3/go.mod h1:8u92CYMUc6gyvTIw8Ru7Mt7+/ESnJahz5EVtqfrilek=
github.com/panjf2000/gnet/v2 v2.9.1 h1:bKewICy/0xnQ9PMzNaswpe/Ah14w1TrRk91LHTcbIlA=
github.com/panjf2000/gnet/v2 v2.9.1/go.mod h1:WQTxDWYuQ/hz3eccH0FN32IVuvZ19HewEWx0l62fx7E=
github.com/panjf2000/gnet/v2 v2.9.7 h1:6zW7Jl3oAfXwSuh1PxHLndoL2MQRWx0AJR6aaQjxUgA= github.com/panjf2000/gnet/v2 v2.9.7 h1:6zW7Jl3oAfXwSuh1PxHLndoL2MQRWx0AJR6aaQjxUgA=
github.com/panjf2000/gnet/v2 v2.9.7/go.mod h1:WQTxDWYuQ/hz3eccH0FN32IVuvZ19HewEWx0l62fx7E= 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 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= 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 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 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.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI= github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI=
github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg= github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg=
github.com/quic-go/quic-go v0.54.0 h1:6s1YB9QotYI6Ospeiguknbp2Znb/jZYjZLRXn9kMQBg= github.com/quic-go/quic-go v0.54.0 h1:6s1YB9QotYI6Ospeiguknbp2Znb/jZYjZLRXn9kMQBg=
github.com/quic-go/quic-go v0.54.0/go.mod h1:e68ZEaCdyviluZmy44P6Iey98v/Wfz6HCjQEm+l8zTY= github.com/quic-go/quic-go v0.54.0/go.mod h1:e68ZEaCdyviluZmy44P6Iey98v/Wfz6HCjQEm+l8zTY=
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 h1:FxwK3eV8p/CQa0Ch276C7u2d0eNC9kCmAYQ7mCXCzVs=
github.com/redis/go-redis/v9 v9.10.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw= github.com/redis/go-redis/v9 v9.10.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw=
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= 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 h1:1iurJgmM9G3PA/I+wWYIOw/5SyBtxapeHDcg+AAIFXc=
github.com/sagikazarmark/locafero v0.11.0/go.mod h1:nVIGvgyzw595SUSUE6tvCp3YYTeHs15MvlmU87WwIik= github.com/sagikazarmark/locafero v0.11.0/go.mod h1:nVIGvgyzw595SUSUE6tvCp3YYTeHs15MvlmU87WwIik=
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
github.com/sony/sonyflake/v2 v2.2.0 h1:wSzEoewlWnUtc3SZX/MpT8zsWTuAnjwrprUYfuPl9Jg=
github.com/sony/sonyflake/v2 v2.2.0/go.mod h1:09EcfmR846JLupbkgVfzp8QtQwJ+Y8e69VVayHdawzg=
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 h1:+jumHNA0Wrelhe64i8F6HNlS8pkoyMv5sreGx2Ry5Rw= 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/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 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I=
@@ -139,6 +192,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= 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.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 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.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.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.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
@@ -171,18 +225,26 @@ 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.etcd.io/etcd/client/v3 v3.6.1/go.mod h1:fCbPUdjWNLfx1A6ATo9syUmFVxqHH9bCnPLBZmnLmMY=
go.mongodb.org/mongo-driver v1.17.6 h1:87JUG1wZfWsr6rIz3ZmpH90rL5tea7O3IHuSwHUpsss= go.mongodb.org/mongo-driver v1.17.6 h1:87JUG1wZfWsr6rIz3ZmpH90rL5tea7O3IHuSwHUpsss=
go.mongodb.org/mongo-driver v1.17.6/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ= go.mongodb.org/mongo-driver v1.17.6/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ=
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.64.0 h1:RN3ifU8y4prNWeEnQp2kRRHz8UwonAEYZl8tUzHEXAk=
go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.64.0/go.mod h1:habDz3tEWiFANTo6oUE99EmaFUrCNYAAg3wiVmusm70=
go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ= go.opentelemetry.io/otel v1.39.0 h1:8yPrr/S0ND9QEfTfdP9V+SiwT4E0G7Y5MO7p85nis48=
go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE= go.opentelemetry.io/otel v1.39.0/go.mod h1:kLlFTywNWrFyEdH0oj2xK0bFYZtHRYUdv1NklR/tgc8=
go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7Wr1A= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.39.0 h1:f0cb2XPmrqn4XMy9PNliTgRKJgS5WcL/u0/WRYGz4t0=
go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.39.0/go.mod h1:vnakAaFckOMiMtOIhFI2MNH4FYrZzXCYxmb1LlhoGz8=
go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.39.0 h1:in9O8ESIOlwJAEGTkkf34DesGRAc/Pn8qJ7k3r/42LM=
go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.39.0/go.mod h1:Rp0EXBm5tfnv0WL+ARyO/PHBEaEAT8UUHQ6AGJcSq6c=
go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k= go.opentelemetry.io/otel/metric v1.39.0 h1:d1UzonvEZriVfpNKEVmHXbdf909uGTOQjA0HF0Ls5Q0=
go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE= 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 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU= go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU=
@@ -199,27 +261,31 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 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-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.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY= golang.org/x/crypto v0.44.0 h1:A97SsFvM3AIwEEmTBiaxPPTYpDC47w720rdiiUvgoAU=
golang.org/x/crypto v0.44.0/go.mod h1:013i+Nw79BMiQiMsOPcVCB5ZIJbYkerPrGnOa00tvmc=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 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.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.26.0 h1:EGMPT//Ezu+ylkCijjPc+f4Aih7sZvaAr+O3EHBxvZg= golang.org/x/mod v0.29.0 h1:HV8lRxZC4l2cr3Zq1LvtOsi/ThTgWnUk/y64QSs8GwA=
golang.org/x/mod v0.26.0/go.mod h1:/j6NAhSk8iQ723BGAUyoAcn7SlD7s15Dp9Nd/SfeaFQ= golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-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-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-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-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= 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-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-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-20201020160332-67f06af15bc9/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.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw= golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I=
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= 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-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-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-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -227,41 +293,47 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/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-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.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.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= 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-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.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.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.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.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU= golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 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-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-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.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.35.0 h1:mBffYraMEf7aa0sB+NuKnuCy8qI/9Bughn8dC2Gu5r0= golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ=
golang.org/x/tools v0.35.0/go.mod h1:NKdj5HkL/73byiZSJjqJgKn3ep7KjFkBOkR/Hps3VPw= golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 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-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-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb h1:p31xT4yrYrSM/G4Sn2+TNUkVhFCbG9y8itM2S6Th950= gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb/go.mod h1:jbe3Bkdp+Dh2IrslsFCklNhweNTBgSYanP1UXhJDhKg= gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb h1:TLPQVbx1GJ8VKZxz52VAxl1EBgKXXbTiU9Fc5fZeLn4= google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 h1:fCvbg86sFXwdrl5LgVcTEvNC+2txB5mgROGmRL5mrls=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb/go.mod h1:LuRYeWDFV6WOn90g357N17oMCaxpgCnbi/44qJvDn2I= google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217/go.mod h1:+rXWjjaukWZun3mLfjmVnQi18E1AsFbDN9QdJ5YXLto=
google.golang.org/grpc v1.71.1 h1:ffsFWr7ygTUscGPI0KKK6TLrGz0476KUvvsbqWK0rPI= google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 h1:gRkg/vSppuSQoDjxyiGfN4Upv/h/DQmIR10ZU8dh4Ww=
google.golang.org/grpc v1.71.1/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec= google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk=
google.golang.org/protobuf v1.36.9 h1:w2gp2mA27hUeUzj9Ex9FBjsBm40zfaDtEWow293U7Iw= google.golang.org/grpc v1.77.0 h1:wVVY6/8cGA6vvffn+wWK5ToddbgdU3d8MNENr4evgXM=
google.golang.org/protobuf v1.36.9/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU= google.golang.org/grpc v1.77.0/go.mod h1:z0BY1iVj0q8E1uSQCjL9cppRj+gnZjzDnzV0dHhrNig=
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 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 h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= 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 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= 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 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= 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.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
@@ -269,5 +341,7 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 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 h1:eNbLmNTpPpTOVZi8MMxCi2aaIm0ZpInbORNXDwyLGvg=
gorm.io/driver/mysql v1.6.0/go.mod h1:D/oCC2GWK3M/dqoLxnOlaNKmXz8WNTfcS9y5ovaSqKo= gorm.io/driver/mysql v1.6.0/go.mod h1:D/oCC2GWK3M/dqoLxnOlaNKmXz8WNTfcS9y5ovaSqKo=
gorm.io/gen v0.3.27 h1:ziocAFLpE7e0g4Rum69pGfB9S6DweTxK8gAun7cU8as=
gorm.io/gen v0.3.27/go.mod h1:9zquz2xD1f3Eb/eHq4oLn2z6vDVvQlCY5S3uMBLv4EA=
gorm.io/gorm v1.31.1 h1:7CA8FTFz/gRfgqgpeKIBcervUn3xSyPUmr6B2WXJ7kg= gorm.io/gorm v1.31.1 h1:7CA8FTFz/gRfgqgpeKIBcervUn3xSyPUmr6B2WXJ7kg=
gorm.io/gorm v1.31.1/go.mod h1:XyQVbO2k6YkOis7C2437jSit3SsDK72s7n7rsSHd+Gs= gorm.io/gorm v1.31.1/go.mod h1:XyQVbO2k6YkOis7C2437jSit3SsDK72s7n7rsSHd+Gs=

View File

@@ -1,13 +1,14 @@
package log package log
import ( import (
"git.hlsq.asia/alex/service-common/config"
"github.com/natefinch/lumberjack" "github.com/natefinch/lumberjack"
"go.uber.org/zap" "go.uber.org/zap"
"go.uber.org/zap/zapcore" "go.uber.org/zap/zapcore"
"os" "os"
) )
func Init(debug bool, maxSize, maxBackups, maxAge int32, level string) { func Init(cfg *config.LogConfig) {
// 格式配置 // 格式配置
jsonConfig := zapcore.EncoderConfig{ jsonConfig := zapcore.EncoderConfig{
MessageKey: "M", MessageKey: "M",
@@ -30,19 +31,19 @@ func Init(debug bool, maxSize, maxBackups, maxAge int32, level string) {
// 日志输出到控制台和文件 // 日志输出到控制台和文件
writeSyncer := []zapcore.WriteSyncer{zapcore.AddSync(os.Stdout)} writeSyncer := []zapcore.WriteSyncer{zapcore.AddSync(os.Stdout)}
if !debug { if !cfg.Debug {
writeSyncer = append(writeSyncer, zapcore.AddSync(&lumberjack.Logger{ writeSyncer = append(writeSyncer, zapcore.AddSync(&lumberjack.Logger{
Filename: "./logs/log.log", // 日志文件位置 Filename: "./logs/log.log", // 日志文件位置
MaxSize: int(maxSize), // 最大文件大小(MB) MaxSize: int(cfg.MaxSize), // 最大文件大小(MB)
MaxBackups: int(maxBackups), // 保留旧文件的最大个数 MaxBackups: int(cfg.MaxBackups), // 保留旧文件的最大个数
MaxAge: int(maxAge), // 保留旧文件的最大天数 MaxAge: int(cfg.MaxAge), // 保留旧文件的最大天数
Compress: false, // 是否压缩/归档旧文件 Compress: false, // 是否压缩/归档旧文件
LocalTime: true, LocalTime: true,
})) }))
} }
var encoder zapcore.Encoder var encoder zapcore.Encoder
if debug { if cfg.Debug {
encoder = zapcore.NewConsoleEncoder(jsonConfig) encoder = zapcore.NewConsoleEncoder(jsonConfig)
} else { } else {
encoder = zapcore.NewJSONEncoder(jsonConfig) encoder = zapcore.NewJSONEncoder(jsonConfig)
@@ -50,9 +51,9 @@ func Init(debug bool, maxSize, maxBackups, maxAge int32, level string) {
logger := zap.New(zapcore.NewCore( logger := zap.New(zapcore.NewCore(
encoder, encoder,
zapcore.NewMultiWriteSyncer(writeSyncer...), zapcore.NewMultiWriteSyncer(writeSyncer...),
zap.NewAtomicLevelAt(GetLogLevel(level)), zap.NewAtomicLevelAt(GetLogLevel(cfg.Level)),
)) ))
if debug { if cfg.Debug {
logger = logger.WithOptions( logger = logger.WithOptions(
zap.AddCaller(), zap.AddCaller(),
zap.AddCallerSkip(1), zap.AddCallerSkip(1),

71
module/db.go Normal file
View File

@@ -0,0 +1,71 @@
package module
import (
"git.hlsq.asia/alex/service-common/config"
"git.hlsq.asia/alex/service-common/db/etcd"
"git.hlsq.asia/alex/service-common/db/kafka"
"git.hlsq.asia/alex/service-common/db/mongo"
"git.hlsq.asia/alex/service-common/db/mysql"
"git.hlsq.asia/alex/service-common/db/redis"
"git.hlsq.asia/alex/service-common/log"
)
// DB 数据库模块
type DB struct {
DefaultModule
Cfg *config.DBConfig
AppName string
}
func (m *DB) Init() error {
// ETCD
if m.Cfg.Etcd != nil {
if err := etcd.Init(m.Cfg.Etcd); err != nil {
return err
}
}
// MYSQL
if m.Cfg.MySQL != nil {
if err := mysql.Init(m.Cfg.MySQL); err != nil {
return err
}
}
// REDIS
if m.Cfg.Redis != nil {
if err := redis.Init(m.Cfg.Redis); err != nil {
return err
}
}
// KAFKA
if m.Cfg.Kafka != nil {
if err := kafka.Init(m.Cfg.Kafka, m.AppName); err != nil {
return err
}
}
// MONGO
if m.Cfg.Mongo != nil {
if err := mongo.Init(m.Cfg.Mongo); err != nil {
return err
}
}
return nil
}
func (m *DB) Stop() error {
if err := etcd.Close(); err != nil {
log.Errorf("close etcd failed: %v", err)
}
if err := mysql.Close(); err != nil {
log.Errorf("close mysql failed: %v", err)
}
if err := redis.Close(); err != nil {
log.Errorf("close redis failed: %v", err)
}
if err := kafka.Close(); err != nil {
log.Errorf("close kafka failed: %v", err)
}
if err := mongo.Close(); err != nil {
log.Errorf("close mongo failed: %v", err)
}
return nil
}

21
module/discover.go Normal file
View File

@@ -0,0 +1,21 @@
package module
import (
"git.hlsq.asia/alex/service-common/discover"
"sync"
)
// Discover 服务发现模块
type Discover struct {
DefaultModule
}
func (m *Discover) Start(ready *sync.WaitGroup) error {
discover.Listen(ready)
return nil
}
func (m *Discover) Stop() error {
discover.Close()
return nil
}

27
module/grpc.go Normal file
View File

@@ -0,0 +1,27 @@
package module
import (
"git.hlsq.asia/alex/service-common/net/grpc/service"
"sync"
)
// Grpc Grpc模块
type Grpc struct {
DefaultModule
Server service.IService
}
func (m *Grpc) Start(ready *sync.WaitGroup) error {
m.Server.Init(ready)
return nil
}
func (m *Grpc) AfterStart() error {
m.Server.SetReady()
return nil
}
func (m *Grpc) Stop() error {
m.Server.Close()
return nil
}

17
module/log.go Normal file
View File

@@ -0,0 +1,17 @@
package module
import (
"git.hlsq.asia/alex/service-common/config"
"git.hlsq.asia/alex/service-common/log"
)
// Log 日志模块
type Log struct {
DefaultModule
Cfg *config.LogConfig
}
func (m *Log) Init() error {
log.Init(m.Cfg)
return nil
}

32
module/module.go Normal file
View File

@@ -0,0 +1,32 @@
package module
import "sync"
// 重点!!!每个模块需要保证同步执行
type Module interface {
Init() error // 初始化
Start(ready *sync.WaitGroup) error // 启动
AfterStart() error // 启动之后
Stop() error // 停止
}
type DefaultModule struct {
}
func (m *DefaultModule) Init() error {
return nil
}
func (m *DefaultModule) Start(ready *sync.WaitGroup) error {
ready.Done()
return nil
}
func (m *DefaultModule) AfterStart() error {
return nil
}
func (m *DefaultModule) Stop() error {
return nil
}

50
module/prometheus.go Normal file
View File

@@ -0,0 +1,50 @@
package module
import (
"context"
"errors"
"fmt"
"git.hlsq.asia/alex/service-common/config"
"git.hlsq.asia/alex/service-common/log"
"github.com/prometheus/client_golang/prometheus/promhttp"
"net/http"
"sync"
)
// Prometheus 普罗米修斯模块
type Prometheus struct {
DefaultModule
Cfg *config.MetricConfig
wg *sync.WaitGroup
server *http.Server
}
func (m *Prometheus) Init() error {
m.wg = &sync.WaitGroup{}
return nil
}
func (m *Prometheus) Start(ready *sync.WaitGroup) error {
m.wg.Add(1)
go func() {
defer m.wg.Done()
m.server = &http.Server{
Addr: fmt.Sprintf("%v:%v", m.Cfg.Prometheus.Address, m.Cfg.Prometheus.Port),
Handler: promhttp.Handler(),
}
ready.Done()
if err := m.server.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
log.Errorf("prometheus server failed: %v", err.Error())
}
log.Infof("prometheus server stop.")
}()
return nil
}
func (m *Prometheus) Stop() error {
if err := m.server.Shutdown(context.Background()); err != nil {
log.Errorf("stop prometheus server failed: %v", err)
}
m.wg.Wait()
return nil
}

25
module/server_status.go Normal file
View File

@@ -0,0 +1,25 @@
package module
import (
"git.hlsq.asia/alex/service-common/server"
"sync"
)
type ServerStatus struct {
DefaultModule
}
func (s *ServerStatus) Init() error {
server.InitStatus()
return nil
}
func (s *ServerStatus) Start(ready *sync.WaitGroup) error {
server.ListenStatus(ready)
return nil
}
func (s *ServerStatus) Stop() error {
server.CloseStatus()
return nil
}

View File

@@ -0,0 +1,25 @@
package module
import (
"git.hlsq.asia/alex/service-common/server"
"sync"
)
type ServerWhitelist struct {
DefaultModule
}
func (s *ServerWhitelist) Init() error {
server.InitWhitelist()
return nil
}
func (s *ServerWhitelist) Start(ready *sync.WaitGroup) error {
server.ListenWhitelist(ready)
return nil
}
func (s *ServerWhitelist) Stop() error {
server.CloseWhitelist()
return nil
}

64
module/snowflake.go Normal file
View File

@@ -0,0 +1,64 @@
package module
import (
"context"
"errors"
"fmt"
"git.hlsq.asia/alex/service-common/db/etcd"
"git.hlsq.asia/alex/service-common/utils"
clientv3 "go.etcd.io/etcd/client/v3"
"go.etcd.io/etcd/client/v3/concurrency"
"math/rand"
)
// Snowflake 雪花模块
type Snowflake struct {
DefaultModule
snowflakeSession *concurrency.Session
}
func (m *Snowflake) Init() error {
node, session, err := acquire(context.Background(), 1, 1000)
if err != nil {
return err
}
m.snowflakeSession = session
utils.InitSnowflake(node)
return nil
}
func (m *Snowflake) Stop() error {
_ = m.snowflakeSession.Close()
return nil
}
func acquire(ctx context.Context, min, max int) (int64, *concurrency.Session, error) {
nums := rand.Perm(max - min + 1)
for i := range nums {
nums[i] += min
}
for _, n := range nums {
key := fmt.Sprintf("/node/num/%d", n)
session, err := concurrency.NewSession(
etcd.GetClient().Raw(),
concurrency.WithContext(ctx),
)
if err != nil {
return 0, nil, utils.ErrorsWrap(fmt.Errorf("etcd NewSession error: %v", err))
}
txnResp, _ := etcd.GetClient().Raw().Txn(ctx).
If(clientv3.Compare(clientv3.CreateRevision(key), "=", 0)).
Then(clientv3.OpPut(key, "", clientv3.WithLease(session.Lease()))).
Commit()
if txnResp.Succeeded {
return int64(n), session, nil
} else {
_ = session.Close()
}
}
return 0, nil, utils.ErrorsWrap(errors.New("etcd num empty"), "acquire error")
}

57
module/tracer.go Normal file
View File

@@ -0,0 +1,57 @@
package module
import (
"context"
"git.hlsq.asia/alex/service-common/config"
"git.hlsq.asia/alex/service-common/log"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
"go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/sdk/resource"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
semconv "go.opentelemetry.io/otel/semconv/v1.24.0"
)
// Tracer 链路追踪模块
type Tracer struct {
DefaultModule
Cfg *config.MetricConfig
ServiceName string
tp *sdktrace.TracerProvider
}
func (m *Tracer) Init() error {
exporter, err := otlptracegrpc.New(
context.Background(),
otlptracegrpc.WithInsecure(),
otlptracegrpc.WithEndpoint(m.Cfg.Jaeger.Endpoint),
)
if err != nil {
return err
}
samplingRate := 1.0
if 0 <= m.Cfg.Jaeger.SamplingRate && m.Cfg.Jaeger.SamplingRate <= 1 {
samplingRate = m.Cfg.Jaeger.SamplingRate
}
m.tp = sdktrace.NewTracerProvider(
sdktrace.WithBatcher(exporter),
sdktrace.WithResource(resource.NewWithAttributes(
semconv.SchemaURL,
semconv.ServiceNameKey.String(m.ServiceName),
)),
sdktrace.WithSampler(sdktrace.ParentBased(sdktrace.TraceIDRatioBased(samplingRate))),
)
otel.SetTracerProvider(m.tp)
otel.SetTextMapPropagator(propagation.TraceContext{})
return nil
}
func (m *Tracer) Stop() error {
if m.tp != nil {
if err := m.tp.Shutdown(context.Background()); err != nil {
log.Errorf("stop tracer provider failed: %v", err)
}
}
return nil
}

View File

@@ -0,0 +1,23 @@
package grpcclient
import (
"git.hlsq.asia/alex/proto/proto/rs/rspb"
"git.hlsq.asia/alex/service-common/discover"
"git.hlsq.asia/alex/service-common/discover/common"
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
"google.golang.org/grpc"
)
func AdminNewClient(sid ...int64) (rspb.AdminClient, error) {
var c *grpc.ClientConn
var err error
if len(sid) == 0 {
c, err = resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameAdmin)
} else {
c, err = discover.FindServer(common.KeyDiscoverAdmin, sid...)
}
if err != nil {
return nil, err
}
return rspb.NewAdminClient(c), nil
}

View File

@@ -0,0 +1,32 @@
package grpcclient
import (
"git.hlsq.asia/alex/proto/proto/rs/rspb"
"git.hlsq.asia/alex/service-common/discover"
"git.hlsq.asia/alex/service-common/discover/common"
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
"google.golang.org/grpc"
)
func GatewayNewClient(sid ...int64) (rspb.GatewayClient, error) {
var c *grpc.ClientConn
var err error
if len(sid) == 0 {
c, err = resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameGateway)
} else {
c, err = discover.FindServer(common.KeyDiscoverGateway, sid...)
}
if err != nil {
return nil, err
}
return rspb.NewGatewayClient(c), nil
}
func GatewayNewBroadcastClient() map[int64]rspb.GatewayClient {
clientM := make(map[int64]rspb.GatewayClient)
connM := discover.FindServerAll(common.KeyDiscoverGateway)
for sid, conn := range connM {
clientM[sid] = rspb.NewGatewayClient(conn)
}
return clientM
}

View File

@@ -0,0 +1,23 @@
package grpcclient
import (
"git.hlsq.asia/alex/proto/proto/rs/rspb"
"git.hlsq.asia/alex/service-common/discover"
"git.hlsq.asia/alex/service-common/discover/common"
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
"google.golang.org/grpc"
)
func NoticeNewClient(sid ...int64) (rspb.NoticeClient, error) {
var c *grpc.ClientConn
var err error
if len(sid) == 0 {
c, err = resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameNotice)
} else {
c, err = discover.FindServer(common.KeyDiscoverNotice, sid...)
}
if err != nil {
return nil, err
}
return rspb.NewNoticeClient(c), nil
}

View File

@@ -0,0 +1,23 @@
package grpcclient
import (
"git.hlsq.asia/alex/proto/proto/rs/rspb"
"git.hlsq.asia/alex/service-common/discover"
"git.hlsq.asia/alex/service-common/discover/common"
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
"google.golang.org/grpc"
)
func PostNewClient(sid ...int64) (rspb.PostClient, error) {
var c *grpc.ClientConn
var err error
if len(sid) == 0 {
c, err = resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNamePost)
} else {
c, err = discover.FindServer(common.KeyDiscoverPost, sid...)
}
if err != nil {
return nil, err
}
return rspb.NewPostClient(c), nil
}

View File

@@ -0,0 +1,23 @@
package grpcclient
import (
"git.hlsq.asia/alex/proto/proto/rs/rspb"
"git.hlsq.asia/alex/service-common/discover"
"git.hlsq.asia/alex/service-common/discover/common"
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
"google.golang.org/grpc"
)
func QgdzsNewClient(sid ...int64) (rspb.QgdzsClient, error) {
var c *grpc.ClientConn
var err error
if len(sid) == 0 {
c, err = resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameQgdzs)
} else {
c, err = discover.FindServer(common.KeyDiscoverQgdzs, sid...)
}
if err != nil {
return nil, err
}
return rspb.NewQgdzsClient(c), nil
}

View File

@@ -0,0 +1,43 @@
package grpcclient
import (
"fmt"
"git.hlsq.asia/alex/proto/proto/rs/rspb"
"git.hlsq.asia/alex/service-common/discover"
"git.hlsq.asia/alex/service-common/discover/common"
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
"google.golang.org/grpc"
)
// SceneNewClient 根据SID查找场景服,一般不用这个函数
func SceneNewClient(sid ...int64) (rspb.SceneClient, error) {
var c *grpc.ClientConn
var err error
if len(sid) == 0 {
c, err = resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameScene)
} else {
c, err = discover.FindServer(common.KeyDiscoverScene, sid...)
}
if err != nil {
return nil, err
}
return rspb.NewSceneClient(c), nil
}
// SceneInstanceNewClient 根据副本唯一编号查找场景服
func SceneInstanceNewClient(uniqueNO int64) (rspb.SceneClient, error) {
sid := discover.FindInstanceByUniqueNo(uniqueNO)
if sid == 0 {
return nil, fmt.Errorf("instance not found: %v", uniqueNO)
}
return SceneNewClient(sid)
}
func SceneNewBroadcastClient() map[int64]rspb.SceneClient {
clientM := make(map[int64]rspb.SceneClient)
connM := discover.FindServerAll(common.KeyDiscoverScene)
for sid, conn := range connM {
clientM[sid] = rspb.NewSceneClient(conn)
}
return clientM
}

View File

@@ -0,0 +1,23 @@
package grpcclient
import (
"git.hlsq.asia/alex/proto/proto/rs/rspb"
"git.hlsq.asia/alex/service-common/discover"
"git.hlsq.asia/alex/service-common/discover/common"
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
"google.golang.org/grpc"
)
func ThirdPartyNewClient(sid ...int64) (rspb.ThirdPartyClient, error) {
var c *grpc.ClientConn
var err error
if len(sid) == 0 {
c, err = resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameThirdParty)
} else {
c, err = discover.FindServer(common.KeyDiscoverThirdParty, sid...)
}
if err != nil {
return nil, err
}
return rspb.NewThirdPartyClient(c), nil
}

View File

@@ -0,0 +1,23 @@
package grpcclient
import (
"git.hlsq.asia/alex/proto/proto/rs/rspb"
"git.hlsq.asia/alex/service-common/discover"
"git.hlsq.asia/alex/service-common/discover/common"
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
"google.golang.org/grpc"
)
func TimerNewClient(sid ...int64) (rspb.TimerClient, error) {
var c *grpc.ClientConn
var err error
if len(sid) == 0 {
c, err = resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameTimer)
} else {
c, err = discover.FindServer(common.KeyDiscoverTimer, sid...)
}
if err != nil {
return nil, err
}
return rspb.NewTimerClient(c), nil
}

View File

@@ -0,0 +1,23 @@
package grpcclient
import (
"git.hlsq.asia/alex/proto/proto/rs/rspb"
"git.hlsq.asia/alex/service-common/discover"
"git.hlsq.asia/alex/service-common/discover/common"
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
"google.golang.org/grpc"
)
func UserNewClient(sid ...int64) (rspb.UserClient, error) {
var c *grpc.ClientConn
var err error
if len(sid) == 0 {
c, err = resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameUser)
} else {
c, err = discover.FindServer(common.KeyDiscoverUser, sid...)
}
if err != nil {
return nil, err
}
return rspb.NewUserClient(c), nil
}

View File

@@ -0,0 +1,126 @@
package grpcclient
import (
"context"
"fmt"
"git.hlsq.asia/alex/proto/proto/rs/rspb"
"git.hlsq.asia/alex/service-common/discover"
"git.hlsq.asia/alex/service-common/discover/common"
"git.hlsq.asia/alex/service-common/log"
"git.hlsq.asia/alex/service-common/utils/locator"
"google.golang.org/grpc"
"google.golang.org/protobuf/proto"
"sync"
)
type GatewayFun int
const (
FunToClient GatewayFun = iota
FunBroadcastClient
FunBroadcastChannel
)
var gatewayServer sync.Map // map[string]*gatewayStream
type gatewayStream struct {
mu sync.Mutex
stream grpc.ClientStream
}
func findGatewayBySID(sid int64, fun GatewayFun) (*gatewayStream, error) {
key := gatewayKey(sid, fun)
if v, ok := gatewayServer.Load(key); ok {
return v.(*gatewayStream), nil
}
client, err := GatewayNewClient(sid)
if err != nil {
log.Errorf("findGatewayBySID cannot find client: %v", err)
return nil, err
}
var stream grpc.ClientStream
switch fun {
case FunToClient:
stream, err = client.InnerToClient(context.Background())
case FunBroadcastClient:
stream, err = client.InnerBroadcastClient(context.Background())
case FunBroadcastChannel:
stream, err = client.InnerBroadcastChannel(context.Background())
}
if err != nil {
log.Errorf("findGatewayBySID %v err: %v, sid: %v", fun, err, sid)
return nil, err
}
ss := &gatewayStream{stream: stream}
if actual, loaded := gatewayServer.LoadOrStore(key, ss); loaded {
go func() { _ = stream.CloseSend() }()
return actual.(*gatewayStream), nil
}
return ss, nil
}
func sendMessageToGateway(sid int64, fun GatewayFun, msg proto.Message, re ...bool) error {
ss, err := findGatewayBySID(sid, fun)
if err != nil {
return err
}
ss.mu.Lock()
err = ss.stream.SendMsg(msg)
ss.mu.Unlock()
if err != nil {
key := gatewayKey(sid, fun)
if v, ok := gatewayServer.Load(key); ok && v == ss {
gatewayServer.Delete(key)
_ = ss.stream.CloseSend()
}
// 如果没有标识本次是重试的,就重试一次(默认重试)
if re == nil || !re[0] {
return sendMessageToGateway(sid, fun, msg, true)
}
return err
}
return nil
}
// SendMessageToClient 单播消息给客户端
func SendMessageToClient(ctx context.Context, usn int64, msg proto.Message, platform ...rspb.PlatformType) error {
if platform == nil || len(platform) == 0 {
return nil
}
for _, pf := range platform {
if gatewaySID := locator.NewLocator(ctx, usn, int32(pf)).LocateGateway(); gatewaySID > 0 {
return sendMessageToGateway(gatewaySID, FunToClient, msg)
}
}
return nil
}
// BroadcastMessageToClient 广播消息给客户端
func BroadcastMessageToClient(msg *rspb.InnerBroadcastClientReq) error {
return broadcastMessageToGateway(FunBroadcastClient, msg)
}
// BroadcastMessageToChannel 广播消息到频道(加入频道的能收到,不区分平台)
func BroadcastMessageToChannel(msg *rspb.InnerBroadcastChannelReq) error {
return broadcastMessageToGateway(FunBroadcastChannel, msg)
}
func broadcastMessageToGateway(fun GatewayFun, msg proto.Message) error {
sidArr := discover.FindServerAllSid(common.KeyDiscoverGateway)
for _, sid := range sidArr {
if err := sendMessageToGateway(sid, fun, msg); err != nil {
return err
}
}
return nil
}
func gatewayKey(sid int64, fun GatewayFun) string {
return fmt.Sprintf("%v-%v", sid, fun)
}

View File

@@ -0,0 +1,83 @@
package grpcclient
import (
"context"
"fmt"
"git.hlsq.asia/alex/service-common/log"
"google.golang.org/grpc"
"google.golang.org/protobuf/proto"
"sync"
)
type SceneFun int
const (
FunAction SceneFun = iota
)
var sceneServer sync.Map // map[string]*sceneStream
type sceneStream struct {
mu sync.Mutex
stream grpc.ClientStream
}
func findSceneBySID(sid int64, fun SceneFun) (*sceneStream, error) {
key := sceneKey(sid, fun)
if v, ok := sceneServer.Load(key); ok {
return v.(*sceneStream), nil
}
client, err := SceneNewClient(sid)
if err != nil {
log.Errorf("findSceneBySID cannot find client: %v", err)
return nil, err
}
var stream grpc.ClientStream
switch fun {
case FunAction:
stream, err = client.Action(context.Background())
}
if err != nil {
log.Errorf("findSceneBySID %v err: %v, sid: %v", fun, err, sid)
return nil, err
}
ss := &sceneStream{stream: stream}
if actual, loaded := sceneServer.LoadOrStore(key, ss); loaded {
go func() { _ = stream.CloseSend() }()
return actual.(*sceneStream), nil
}
return ss, nil
}
func sendMessageToScene(sid int64, fun SceneFun, msg proto.Message, re ...bool) error {
ss, err := findSceneBySID(sid, fun)
if err != nil {
return err
}
ss.mu.Lock()
err = ss.stream.SendMsg(msg)
ss.mu.Unlock()
if err != nil {
key := sceneKey(sid, fun)
if v, ok := sceneServer.Load(key); ok && v == ss {
sceneServer.Delete(key)
_ = ss.stream.CloseSend()
}
// 如果没有标识本次是重试的,就重试一次(默认重试)
if re == nil || !re[0] {
return sendMessageToScene(sid, fun, msg, true)
}
return err
}
return nil
}
func sceneKey(sid int64, fun SceneFun) string {
return fmt.Sprintf("%v-%v", sid, fun)
}

View File

@@ -1,10 +1,14 @@
package grpc_conn package grpcconn
import ( import (
"common/log" "context"
"git.hlsq.asia/alex/service-common/log"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/keepalive" "google.golang.org/grpc/keepalive"
"google.golang.org/grpc/metadata"
"strconv"
"time" "time"
) )
@@ -20,6 +24,8 @@ func NewGrpcConnection(sid int64, address string) (*GrpcConnection, error) {
conn, err := grpc.NewClient( conn, err := grpc.NewClient(
address, address,
grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithStatsHandler(otelgrpc.NewClientHandler()),
grpc.WithUnaryInterceptor(sidInterceptor(sid)),
grpc.WithKeepaliveParams( grpc.WithKeepaliveParams(
keepalive.ClientParameters{ keepalive.ClientParameters{
Time: 30 * time.Second, // 保活探测包发送的时间间隔 Time: 30 * time.Second, // 保活探测包发送的时间间隔
@@ -27,7 +33,6 @@ func NewGrpcConnection(sid int64, address string) (*GrpcConnection, error) {
PermitWithoutStream: true, PermitWithoutStream: true,
}, },
), ),
//grpc.WithStatsHandler(&StatsHandler{}),
) )
if err != nil { if err != nil {
log.Errorf("create grpc err: %v, sid: %v, addr: %v", err, sid, address) log.Errorf("create grpc err: %v, sid: %v, addr: %v", err, sid, address)
@@ -40,3 +45,13 @@ func NewGrpcConnection(sid int64, address string) (*GrpcConnection, error) {
func (g *GrpcConnection) GetConnection() *grpc.ClientConn { func (g *GrpcConnection) GetConnection() *grpc.ClientConn {
return g.conn return g.conn
} }
func sidInterceptor(sid int64) grpc.UnaryClientInterceptor {
sidStr := strconv.Itoa(int(sid))
return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
ctx = metadata.AppendToOutgoingContext(ctx,
"X-Sid", sidStr,
)
return invoker(ctx, method, req, reply, cc, opts...)
}
}

View File

@@ -1,8 +1,8 @@
package grpc_conn package grpcconn
import ( import (
"common/log"
"fmt" "fmt"
"git.hlsq.asia/alex/service-common/log"
"google.golang.org/grpc" "google.golang.org/grpc"
"math/rand" "math/rand"
) )
@@ -42,7 +42,7 @@ func (p *GrpcConnectionMgr) Delete(sid int64) int {
func (p *GrpcConnectionMgr) Load(sid ...int64) (*grpc.ClientConn, error) { func (p *GrpcConnectionMgr) Load(sid ...int64) (*grpc.ClientConn, error) {
var pool *GrpcConnection var pool *GrpcConnection
if len(sid) > 0 && sid[0] > 0 { if len(sid) > 0 && sid[0] != 0 {
pool = p.poolM[sid[0]] pool = p.poolM[sid[0]]
} else { } else {
pool = p.poolS[rand.Intn(len(p.poolS))] pool = p.poolS[rand.Intn(len(p.poolS))]
@@ -60,3 +60,11 @@ func (p *GrpcConnectionMgr) LoadAll() map[int64]*grpc.ClientConn {
} }
return sidM return sidM
} }
func (p *GrpcConnectionMgr) LoadAllSid() []int64 {
sidArr := make([]int64, 0)
for sid := range p.poolM {
sidArr = append(sidArr, sid)
}
return sidArr
}

View File

@@ -1,18 +1,31 @@
package resolver package resolver
import ( import (
"common/log" "git.hlsq.asia/alex/service-common/log"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/keepalive" "google.golang.org/grpc/keepalive"
"time" "time"
) )
const serviceConfig = `{
"loadBalancingConfig": [
{
"round_robin": {}
}
],
"healthCheckConfig": {
"serviceName": ""
}
}`
func NewGrpcConnection(target string) (*grpc.ClientConn, error) { func NewGrpcConnection(target string) (*grpc.ClientConn, error) {
cc, err := grpc.NewClient( cc, err := grpc.NewClient(
target, target,
grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithDefaultServiceConfig(`{"loadBalancingConfig": [{"round_robin": {}}]}`), grpc.WithStatsHandler(otelgrpc.NewClientHandler()),
grpc.WithDefaultServiceConfig(serviceConfig),
grpc.WithKeepaliveParams( grpc.WithKeepaliveParams(
keepalive.ClientParameters{ keepalive.ClientParameters{
Time: 30 * time.Second, // 保活探测包发送的时间间隔 Time: 30 * time.Second, // 保活探测包发送的时间间隔
@@ -20,7 +33,6 @@ func NewGrpcConnection(target string) (*grpc.ClientConn, error) {
PermitWithoutStream: true, PermitWithoutStream: true,
}, },
), ),
//grpc.WithStatsHandler(&StatsHandler{}),
) )
if err != nil { if err != nil {
log.Errorf("create grpc err: %v, target: %v", err, target) log.Errorf("create grpc err: %v, target: %v", err, target)

View File

@@ -1,10 +1,10 @@
package resolver package resolver
import ( import (
"common/db/etcd"
"common/discover/common"
"common/log"
"context" "context"
"git.hlsq.asia/alex/service-common/db/etcd"
"git.hlsq.asia/alex/service-common/discover/common"
"git.hlsq.asia/alex/service-common/log"
"go.etcd.io/etcd/client/v3" "go.etcd.io/etcd/client/v3"
"google.golang.org/grpc/resolver" "google.golang.org/grpc/resolver"
"strings" "strings"

View File

@@ -1,24 +0,0 @@
package service
import (
"common/discover"
"common/discover/common"
"common/proto/ss/grpc_pb"
)
func GatewayNewClient(sid ...int64) (grpc_pb.GatewayClient, error) {
c, err := discover.FindServer(common.KeyDiscoverGateway, sid...)
if err != nil {
return nil, err
}
return grpc_pb.NewGatewayClient(c), nil
}
func GatewayNewBroadcastClient() map[int64]grpc_pb.GatewayClient {
clientM := make(map[int64]grpc_pb.GatewayClient)
connM := discover.FindServerAll(common.KeyDiscoverGateway)
for sid, conn := range connM {
clientM[sid] = grpc_pb.NewGatewayClient(conn)
}
return clientM
}

View File

@@ -1,33 +0,0 @@
package service
import (
"common/discover"
"common/discover/common"
"common/net/grpc/resolver"
"common/proto/ss/grpc_pb"
)
func SceneNewClient(sid ...int64) (grpc_pb.SceneClient, error) {
c, err := discover.FindServer(common.KeyDiscoverScene, sid...)
if err != nil {
return nil, err
}
return grpc_pb.NewSceneClient(c), nil
}
func SceneNewClientLB() (grpc_pb.SceneClient, error) {
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameScene)
if err != nil {
return nil, err
}
return grpc_pb.NewSceneClient(c), nil
}
func SceneNewBroadcastClient() map[int64]grpc_pb.SceneClient {
clientM := make(map[int64]grpc_pb.SceneClient)
connM := discover.FindServerAll(common.KeyDiscoverScene)
for sid, conn := range connM {
clientM[sid] = grpc_pb.NewSceneClient(conn)
}
return clientM
}

View File

@@ -1,24 +0,0 @@
package service
import (
"common/discover"
"common/discover/common"
"common/net/grpc/resolver"
"common/proto/ss/grpc_pb"
)
func UserNewClient(sid ...int64) (grpc_pb.UserClient, error) {
c, err := discover.FindServer(common.KeyDiscoverUser, sid...)
if err != nil {
return nil, err
}
return grpc_pb.NewUserClient(c), nil
}
func UserNewClientLB() (grpc_pb.UserClient, error) {
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameUser)
if err != nil {
return nil, err
}
return grpc_pb.NewUserClient(c), nil
}

View File

@@ -0,0 +1,103 @@
package service
import (
"context"
"encoding/json"
"fmt"
"git.hlsq.asia/alex/proto/proto/rs/rscommon"
"git.hlsq.asia/alex/service-common/log"
"git.hlsq.asia/alex/service-common/net/http/httpresp"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
otelcodes "go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/trace"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
"strconv"
"time"
)
func (s *Base) RecoveryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
defer func() {
if r := recover(); r != nil {
log.Errorf("service Panic: %v", r)
err = status.Error(codes.Internal, fmt.Sprintf("Internal server error: %v", r))
}
}()
return handler(ctx, req)
}
func (s *Base) CheckSID(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
if md, ok := metadata.FromIncomingContext(ctx); ok {
sidArr := md.Get("X-Sid")
if len(sidArr) > 0 {
if strconv.Itoa(int(s.SID)) != sidArr[0] {
err = status.Error(codes.Internal, "SID mismatch")
return
}
}
}
return handler(ctx, req)
}
func (s *Base) LoggingInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
usn := ""
if md, ok := metadata.FromIncomingContext(ctx); ok {
usnArr := md.Get("X-Usn")
if len(usnArr) > 0 {
usn = usnArr[0]
}
}
_, span := otel.Tracer("grpc.interceptor.logging").Start(ctx, info.FullMethod)
defer span.End()
reqStr, _ := json.Marshal(req)
reqString := fmt.Sprintf("[usn:%v] ↓↓↓ method: %s, Request: %v", usn, info.FullMethod, string(reqStr))
span.SetAttributes(attribute.String("rpc.req", reqString))
span.SetAttributes(attribute.String("usn", usn))
log.Infof(reqString)
start := time.Now()
resp, err = handler(ctx, req)
respStr, _ := json.Marshal(resp)
respString := fmt.Sprintf("[usn:%v] ↑↑↑ method: %s, Duration: %v, Response: %v, Error: %v", usn, info.FullMethod, time.Since(start), string(respStr), err)
span.SetAttributes(attribute.String("rpc.resp", respString))
log.Infof(respString)
if err != nil {
if stack, ok := err.(interface{ StackTrace() string }); ok {
span.AddEvent("Stack Trace", trace.WithAttributes(
attribute.String("stack.trace", fmt.Sprintf("%v", stack.StackTrace())),
))
if original, ok := err.(interface{ Original() error }); ok {
if wrap, ok := original.Original().(interface{ Wrap() error }); ok {
err = wrap.Wrap()
} else {
err = checkGRPCError(original.Original())
}
}
} else if wrap, ok := err.(interface{ Wrap() error }); ok {
err = wrap.Wrap()
} else {
err = checkGRPCError(err)
}
span.SetStatus(otelcodes.Error, err.Error())
}
return
}
func checkGRPCError(err error) error {
if original, ok := err.(interface{ GRPCStatus() *status.Status }); ok {
details := original.GRPCStatus().Details()
if len(details) > 0 {
if ei, ok := details[0].(*rscommon.ErrorInfo); ok {
return httpresp.NewCode(int(ei.Code), ei.Msg).Wrap()
}
}
}
return err
}

View File

@@ -1,77 +1,86 @@
package service package service
import ( import (
"common/discover"
"common/log"
"common/utils"
"context"
"fmt" "fmt"
"git.hlsq.asia/alex/service-common/config"
"git.hlsq.asia/alex/service-common/discover"
"git.hlsq.asia/alex/service-common/log"
"git.hlsq.asia/alex/service-common/utils"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/codes" "google.golang.org/grpc/health"
"google.golang.org/grpc/health/grpc_health_v1"
"google.golang.org/grpc/keepalive" "google.golang.org/grpc/keepalive"
"google.golang.org/grpc/status"
"net" "net"
"sync" "sync"
"time" "time"
) )
type IService interface { type IService interface {
Init(addr string, port int32) Init(ready *sync.WaitGroup)
SetReady()
Close() Close()
} }
type Base struct { type Base struct {
Target string Target string
ServiceName string
SID int64 SID int64
Serve *grpc.Server Serve *grpc.Server
EtcdTTL int64 Cfg *config.GrpcConfig
OnCustomGrpcServerOption func() []grpc.ServerOption
OnInit func(serve *grpc.Server) OnInit func(serve *grpc.Server)
OnClose func() OnClose func()
wg *sync.WaitGroup wg *sync.WaitGroup
healthcheck *health.Server
} }
func (s *Base) Init(addr string, port int32) { func (s *Base) Init(ready *sync.WaitGroup) {
s.wg = &sync.WaitGroup{} s.wg = &sync.WaitGroup{}
s.wg.Add(1) s.wg.Add(1)
s.SID = utils.SnowflakeInstance().Generate().Int64() s.SID = utils.SnowflakeInt64()
go func() { go func() {
defer s.wg.Done() defer s.wg.Done()
defer s.OnClose() defer s.OnClose()
defer discover.UnRegisterGrpcServer(s.SID) defer discover.UnRegisterGrpcServer(s.SID)
// 监听端口 // 监听端口
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", port)) lis, err := net.Listen("tcp", fmt.Sprintf(":%d", s.Cfg.Port))
if err != nil { if err != nil {
log.Errorf("%v ListenPort err: %v", s.Target, err) log.Errorf("%v ListenPort err: %v", s.Target, err)
return return
} }
s.Serve = grpc.NewServer( options := []grpc.ServerOption{
grpc.UnaryInterceptor( grpc.ChainUnaryInterceptor(
func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) { s.RecoveryInterceptor,
defer func() { s.CheckSID,
if r := recover(); r != nil { s.LoggingInterceptor,
log.Errorf("server Panic: %v", r)
err = status.Error(codes.Internal, fmt.Sprintf("%v", r))
}
}()
resp, err = handler(ctx, req)
return
},
), ),
grpc.StatsHandler(otelgrpc.NewServerHandler()),
grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{ grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{
MinTime: 20 * time.Second, MinTime: 20 * time.Second,
PermitWithoutStream: true, PermitWithoutStream: true,
}), }),
) }
options = append(options, s.OnCustomGrpcServerOption()...)
s.Serve = grpc.NewServer(options...)
s.OnInit(s.Serve) s.OnInit(s.Serve)
// 健康检查
s.healthcheck = health.NewServer()
s.healthcheck.SetServingStatus("", grpc_health_v1.HealthCheckResponse_NOT_SERVING)
grpc_health_v1.RegisterHealthServer(s.Serve, s.healthcheck)
// 服务注册 // 服务注册
if err = discover.RegisterGrpcServer(s.Target, s.SID, fmt.Sprintf("%v:%d", addr, port), s.EtcdTTL); err != nil { if err = discover.RegisterGrpcServer(s.Target, s.SID, fmt.Sprintf("%v:%d", s.Cfg.Address, s.Cfg.Port), s.Cfg.TTL); err != nil {
log.Errorf("%v RegisterGrpcServer err: %v", s.Target, err) log.Errorf("%v RegisterGrpcServer err: %v", s.Target, err)
return return
} }
// 准备好了
ready.Done()
log.Infof("%v registered grpc sid: %v", s.Target, s.SID)
if err = s.Serve.Serve(lis); err != nil { if err = s.Serve.Serve(lis); err != nil {
log.Errorf("%v Serve err: %v", s.Target, err) log.Errorf("%v Serve err: %v", s.Target, err)
return return
@@ -80,9 +89,18 @@ func (s *Base) Init(addr string, port int32) {
}() }()
} }
func (s *Base) SetReady() {
if s.healthcheck != nil {
s.healthcheck.SetServingStatus("", grpc_health_v1.HealthCheckResponse_SERVING)
}
}
func (s *Base) Close() { func (s *Base) Close() {
if s.healthcheck != nil {
s.healthcheck.SetServingStatus("", grpc_health_v1.HealthCheckResponse_NOT_SERVING)
}
if s.Serve != nil { if s.Serve != nil {
s.Serve.Stop() s.Serve.GracefulStop()
s.wg.Wait() s.wg.Wait()
} }
} }

View File

@@ -1,47 +0,0 @@
package http_resp
import (
"common/proto/ss/ss_common"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
var (
OK = NewCode(0, "OK")
Failed = NewCode(1, "Failed")
TokenInvalid = NewCode(2, "Token无效")
ParamError = NewCode(1001, "参数错误")
NameEmpty = NewCode(1002, "名称不能为空")
NameDuplicate = NewCode(1003, "名称或编号不能重复")
ListEmpty = NewCode(1004, "列表不能为空")
RepeatCommit = NewCode(1005, "请勿重复提交")
)
type Code struct {
code int
error string
}
func NewCode(code int, error string) *Code {
return &Code{
code: code,
error: error,
}
}
func (c *Code) Code() int {
return c.code
}
func (c *Code) Error() string {
return c.error
}
func (c *Code) Wrap() error {
st := status.New(codes.Unknown, c.Error())
st, _ = st.WithDetails(&ss_common.ErrorInfo{
Code: int32(c.Code()),
Msg: c.Error(),
})
return st.Err()
}

122
net/http/httpresp/code.go Normal file
View File

@@ -0,0 +1,122 @@
package httpresp
import (
"git.hlsq.asia/alex/proto/proto/rs/rscommon"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
var (
OK = NewCode(0, "OK")
Failed = NewCode(1, "Failed")
TokenInvalid = NewCode(2, "Token Invalid")
MethodNotAllowed = NewCode(3, "Method Not Allowed")
NotFound = NewCode(4, "Not Found")
TokenForbidden = NewCode(5, "Token Forbidden")
AdminNotExist = NewCode(6, "Admin Not Exist")
ServerMaintenance = NewCode(7, "Server Maintenance")
RequestTooFast = NewCode(8, "Request too fast") // 请求太频繁了
ParamError = NewCode(1001, "参数错误")
PageQueryError = NewCode(1002, "page query param error")
PhoneCodeError = NewCode(1003, "Phone or code error") // 手机验证码错误
PhoneHasBeenBind = NewCode(1004, "Phone number has been bind") // 手机号已经被绑定
WeChatHasBeenBind = NewCode(1005, "WeChat has been bind") // 微信已经被绑定
BindTicketError = NewCode(1006, "Bind ticket error") // 登录绑定凭证无效
RoundIsEnd = NewCode(2001, "Round is end")
RoundNotEnd = NewCode(2002, "Round not end")
NameEmpty = NewCode(1002, "名称不能为空")
NameDuplicate = NewCode(1003, "名称或编号不能重复")
ListEmpty = NewCode(1004, "列表不能为空")
RepeatCommit = NewCode(1005, "请勿重复提交")
// ----------------user 10000-11000--------------------
UserNotFound = NewCode(10001, "User not found")
CharNickNameTooLong = NewCode(10002, "Character nickname too long")
CharNickNameIllegal = NewCode(10003, "Character nickname illegal")
CharNickNameEmpty = NewCode(10004, "Character nickname empty")
CharModelEmpty = NewCode(10005, "Character model empty")
CharModelNotExist = NewCode(10006, "Character model not exist")
CharAvatarEmpty = NewCode(10007, "Character avatar empty")
CharAvatarNotExist = NewCode(10008, "Character avatar not exist")
CharSexInvalid = NewCode(10009, "Character sex invalid")
RewardAlreadyBindError = NewCode(10010, "Reward already bind") // 奖励已绑定
// ----------------SCENE 10010-10100--------------------
SceneRoomNumberGenError = NewCode(10010, "Room number gen error")
RoomNotExistsError = NewCode(10011, "Room not exists error")
RoomPlayerUpperLimit = NewCode(10012, "Room player upper limit") // 房间人数满了
RoomStatusNotAllowEnter = NewCode(10013, "Room status not allow enter") // 房间状态不允许中途进入
PlayerAlreadyInRoom = NewCode(10014, "Player already in room") //玩家已经在房间中
PlayerHandicapNotMeet = NewCode(10015, "Player handicap not meet") //玩家等级不足
NoAvailableRoom = NewCode(10016, "No available room") // 没有符合的房间
SceneRoomDescriptionWidthError = NewCode(10017, "Room description width more than error")
// ----------------court-physical 11001-12000--------------------
CourtPhysicalNotFind = NewCode(11001, "没有找到线下球场配置")
CourtPhysicalNotFindCompetitionl = NewCode(11002, "没有找到比赛")
CourtPhysicalCompetitionlNotPermission = NewCode(11003, "你不是房主无权编辑")
CourtPhysicalCompetitionlNotHole = NewCode(11004, "球场配置错误,没有洞的数据")
CourtPhysicalCompetitionlPlayerUpperLimit = NewCode(11005, "比赛球员已达上限")
CourtPhysicalCompetitionlPlayerIsRoom = NewCode(11006, "用户已在房间")
CourtPhysicalCompetitionlStart = NewCode(11007, "比赛已开始")
CourtPhysicalCompetitionlPlayerJoinFailed = NewCode(11008, "用户加入比赛失败")
CourtPhysicalCompetitionlNotRemovedHomeowner = NewCode(11009, "不能移除房主")
CourtPhysicalCompetitionlNotFindPlayer = NewCode(11010, "房间没有该用户")
CourtPhysicalCompetitionlNotGamePlayer = NewCode(11011, "该用户不是球员")
CourtPhysicalCompetitionlNotIn = NewCode(11012, "该用户不在本局比赛")
CourtPhysicalCompetitionlStartFail = NewCode(11013, "比赛开始初始化数据失败")
CourtPhysicalCompetitionlEnd = NewCode(11014, "比赛已结束")
CourtPhysicalCompetitionlNotStart = NewCode(11015, "比赛未开始")
CourtPhysicalCompetitionlPKFail = NewCode(11016, "PK玩法配置错误")
CourtPhysicalCompetitionlPKTigerNot3Player = NewCode(11017, "PK玩法配置错误:Tiger玩法参赛选手需≥3")
CourtPhysicalCompetitionlPKTigerNotTiger = NewCode(11018, "PK玩法配置错误:Tiger玩法不能没有老虎")
CourtPhysicalCompetitionlPKTigerNotHole = NewCode(11019, "PK玩法配置错误:Tiger玩法至少要选择一个球洞")
CourtPhysicalCompetitionlPKTigerEnhanceFail = NewCode(11020, "PK玩法配置错误:Tiger玩法比洞才有受让杆")
CourtPhysicalCompetitionlPKTigerTopHoleFail = NewCode(11021, "PK玩法配置错误:Tiger玩法比洞才有顶洞和收顶洞")
CourtPhysicalCompetitionlPKRyderCupNot4Player = NewCode(11022, "PK玩法配置错误:莱德杯玩法需4名参赛选手")
CourtPhysicalCompetitionlPKRyderCupLeastFormat = NewCode(11023, "PK玩法配置错误:莱德杯玩法至少要选择一个赛制")
CourtPhysicalCompetitionlPKRyderCupHoleFail = NewCode(11024, "PK玩法配置错误:莱德杯玩法球洞配置冲突")
CourtPhysicalCompetitionlPKRyderCupTeamFail = NewCode(11025, "PK玩法配置错误:莱德杯玩法两队人数不对")
CourtPhysicalCompetitionlNameIllegal = NewCode(11026, "比赛昵称存在违禁词")
CourtPhysicalCompetitionlLinkError = NewCode(11027, "生成微信链接错误")
// 锦标赛 ----------------court 12001-13000--------------------
CourtTournamentNotInvited = NewCode(12002, "仅限受邀用户参赛") // 未在邀请名单内
CourtTournamentHandicapNotMeet = NewCode(12003, "差点不符合参赛要求") // 无有效差点或超出要求区间
CourtTournamentRoundAlreadyStarted = NewCode(12004, "本轮比赛已开始") // 并发重复开赛(竞态)
CourtTournamentRoundNotInProgress = NewCode(12005, "轮次未开始,不能开赛") // 轮次不是进行中
CourtTournamentJoinEnded = NewCode(12006, "已淘汰,无法继续比赛") // 报名已结束(已淘汰)
CourtTournamentPracticeNotAllowed = NewCode(12007, "该锦标赛未开放练习") // 未配置练习次数
CourtTournamentPracticeEnded = NewCode(12008, "比赛已结束,不允许练习") // 决赛结束/已完成/已取消
CourtTournamentPracticeTimesNotEnough = NewCode(12009, "练习次数已用完") // 已练习次数达上限
CourtTournamentShelfStatusNotAllowed = NewCode(12010, "该锦标赛不允许下架") // 该锦标赛不允许下架
)
type Code struct {
code int
error string
}
func NewCode(code int, error string) *Code {
return &Code{
code: code,
error: error,
}
}
func (c *Code) Code() int {
return c.code
}
func (c *Code) Error() string {
return c.error
}
func (c *Code) Wrap() error {
st := status.New(codes.Unknown, c.Error())
st, _ = st.WithDetails(&rscommon.ErrorInfo{
Code: int32(c.Code()),
Msg: c.Error(),
})
return st.Err()
}

View File

@@ -1,4 +1,4 @@
package http_resp package httpresp
import ( import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@@ -35,13 +35,17 @@ func JsonBadRequest(c *gin.Context) {
} }
func JsonMethodNotAllowed(c *gin.Context) { func JsonMethodNotAllowed(c *gin.Context) {
c.JSON(http.StatusMethodNotAllowed, Error(NewCode(Failed.Code(), "Method Not Allowed"))) c.JSON(http.StatusMethodNotAllowed, Error(MethodNotAllowed))
} }
func JsonNotFound(c *gin.Context) { func JsonNotFound(c *gin.Context) {
c.JSON(http.StatusNotFound, Error(NewCode(Failed.Code(), "Endpoint Not Found"))) c.JSON(http.StatusNotFound, Error(NotFound))
} }
func AbortUnauthorized(c *gin.Context) { func JsonUnauthorized(c *gin.Context) {
c.AbortWithStatusJSON(http.StatusUnauthorized, Error(NewCode(Failed.Code(), "Invalid Authorization"))) c.JSON(http.StatusOK, Error(TokenInvalid))
}
func JsonMaintenance(c *gin.Context) {
c.JSON(http.StatusOK, Error(ServerMaintenance))
} }

View File

@@ -1,9 +1,5 @@
package socket package socket
import (
"time"
)
type Action int type Action int
const ( const (
@@ -29,11 +25,10 @@ const (
// ISocketServer 由应用层实现 // ISocketServer 由应用层实现
type ISocketServer interface { type ISocketServer interface {
OnOpen(ISocketConn) ([]byte, Action) // 开启连接 OnOpen(ISocketConn) ([]byte, Action) // 开启连接
OnHandShake(ISocketConn, []byte, func(ISocketConn, []byte)) Action // 开始握手 OnHandShake(ISocketConn) Action // 开始握手
OnMessage(ISocketConn, []byte) Action // 收到消息 OnMessage(ISocketConn, []byte) Action // 收到消息
OnPong(ISocketConn)
OnClose(ISocketConn, error) Action // 关闭连接 OnClose(ISocketConn, error) Action // 关闭连接
OnTick() (time.Duration, Action) OnTick() Action // 定时调用(由网络层决定)
} }
// ISocketConn 由网络层实现 // ISocketConn 由网络层实现
@@ -41,7 +36,7 @@ type ISocketConn interface {
GetParam(key string) interface{} GetParam(key string) interface{}
SetParam(key string, values interface{}) SetParam(key string, values interface{})
RemoteAddr() string RemoteAddr() string
Ping() error // 需要隔一段时间调用一下,建议20s Ping() error
Write(data []byte) error Write(data []byte) error
Close() error Close() error
IsClose() bool IsClose() bool

View File

@@ -2,8 +2,10 @@ package websocket
import ( import (
"bytes" "bytes"
"common/net/socket"
"context" "context"
"fmt"
"git.hlsq.asia/alex/service-common/log"
"git.hlsq.asia/alex/service-common/net/socket"
"github.com/panjf2000/gnet/v2" "github.com/panjf2000/gnet/v2"
"github.com/panjf2000/gnet/v2/pkg/logging" "github.com/panjf2000/gnet/v2/pkg/logging"
"sync" "sync"
@@ -31,7 +33,7 @@ func NewWSServer(i socket.ISocketServer, logger logging.Logger, upgradeTimeout t
} }
} }
func (s *WSServer) Run(addr string, multicore bool, numEventLoop int, tcpNoDelay gnet.TCPSocketOpt, readBufferCap, writeBufferCap int, lockOSThread bool, reusePort, ticker bool, logger logging.Logger) error { func (s *WSServer) Run(addr string, multicore bool, numEventLoop int, tcpNoDelay gnet.TCPSocketOpt, readBufferCap, writeBufferCap int, lockOSThread bool, reusePort, ticker bool) error {
return gnet.Run( return gnet.Run(
s, s,
addr, addr,
@@ -43,7 +45,7 @@ func (s *WSServer) Run(addr string, multicore bool, numEventLoop int, tcpNoDelay
gnet.WithLockOSThread(lockOSThread), gnet.WithLockOSThread(lockOSThread),
gnet.WithReusePort(reusePort), gnet.WithReusePort(reusePort),
gnet.WithTicker(ticker), gnet.WithTicker(ticker),
gnet.WithLogger(logger), gnet.WithLogger(s.logger),
) )
} }
@@ -65,7 +67,7 @@ func (s *WSServer) OnOpen(c gnet.Conn) ([]byte, gnet.Action) {
isUpgrade: false, isUpgrade: false,
openTime: time.Now().Unix(), openTime: time.Now().Unix(),
buf: bytes.Buffer{}, buf: bytes.Buffer{},
logger: s.logger, logger: log.GetLogger().Named(fmt.Sprintf("CONN %v", c.RemoteAddr().String())),
wsMessageBuf: wsMessageBuf{ wsMessageBuf: wsMessageBuf{
curHeader: nil, curHeader: nil,
cachedBuf: bytes.Buffer{}, cachedBuf: bytes.Buffer{},
@@ -86,7 +88,7 @@ func (s *WSServer) OnClose(c gnet.Conn, err error) (action gnet.Action) {
ws, ok := c.Context().(*WSConn) ws, ok := c.Context().(*WSConn)
if ok { if ok {
ws.isClose = true ws.isClose = true
ws.logger.Warnf("connection close, err: %v", err) ws.logger.Infof("Connection close, err: %v", err)
return gnet.Action(s.i.OnClose(ws, err)) return gnet.Action(s.i.OnClose(ws, err))
} }
return return
@@ -103,7 +105,15 @@ func (s *WSServer) OnTraffic(c gnet.Conn) gnet.Action {
data, action := ws.upgrade() data, action := ws.upgrade()
if len(data) > 0 { if len(data) > 0 {
s.unUpgradeConn.Delete(c.RemoteAddr().String()) s.unUpgradeConn.Delete(c.RemoteAddr().String())
action = gnet.Action(s.i.OnHandShake(ws, data, s.OnHandShakeFinish)) action = gnet.Action(s.i.OnHandShake(ws))
if action == gnet.None {
if err := ws.Conn.AsyncWrite(data, nil); err != nil {
ws.logger.Errorf("OnTraffic upgrade AsyncWrite err: %v", err)
if err = ws.Close(); err != nil {
ws.logger.Errorf("OnTraffic upgrade Close error: %v", err)
}
}
}
} }
return action return action
} }
@@ -113,14 +123,10 @@ func (s *WSServer) OnTraffic(c gnet.Conn) gnet.Action {
return gnet.Close return gnet.Close
} else if msg != nil { } else if msg != nil {
for _, m := range msg { for _, m := range msg {
if socket.OpCode(m.OpCode) == socket.OpPong {
s.i.OnPong(ws)
continue
}
if socket.OpCode(m.OpCode) == socket.OpClose { if socket.OpCode(m.OpCode) == socket.OpClose {
return gnet.Close return gnet.Close
} }
if socket.OpCode(m.OpCode) == socket.OpPing { if socket.OpCode(m.OpCode) == socket.OpPing || socket.OpCode(m.OpCode) == socket.OpPong {
continue continue
} }
a := s.i.OnMessage(ws, m.Payload) a := s.i.OnMessage(ws, m.Payload)
@@ -168,20 +174,8 @@ func (s *WSServer) OnTick() (delay time.Duration, action gnet.Action) {
v.logger.Errorf("upgrade ws time out close socket error: %v", err) v.logger.Errorf("upgrade ws time out close socket error: %v", err)
} }
} }
d, a := s.i.OnTick() delay = 5 * time.Second
delay = d action = gnet.Action(s.i.OnTick())
action = gnet.Action(a)
return return
} }
// OnHandShakeFinish 握手完成
func (s *WSServer) OnHandShakeFinish(conn socket.ISocketConn, hsResp []byte) {
ws := conn.(*WSConn)
if err := ws.Conn.AsyncWrite(hsResp, nil); err != nil {
ws.logger.Errorf("OnHandShakeFinish err: %v", err)
if err = ws.Close(); err != nil {
ws.logger.Errorf("OnHandShakeFinish Close error: %v", err)
}
}
}

View File

@@ -4,12 +4,13 @@ import (
"bufio" "bufio"
"bytes" "bytes"
"errors" "errors"
"io"
"net/url"
"github.com/gobwas/ws" "github.com/gobwas/ws"
"github.com/gobwas/ws/wsutil" "github.com/gobwas/ws/wsutil"
"github.com/panjf2000/gnet/v2" "github.com/panjf2000/gnet/v2"
"github.com/panjf2000/gnet/v2/pkg/logging" "github.com/panjf2000/gnet/v2/pkg/logging"
"io"
"net/url"
) )
// WSConn 实现ISocketConn接口 // WSConn 实现ISocketConn接口
@@ -22,7 +23,7 @@ type WSConn struct {
isClose bool isClose bool
param map[string]interface{} param map[string]interface{}
openTime int64 // 开启连接的时间 openTime int64 // 开启连接的时间
remoteAddr string // 远程ID地址 remoteAddr string // 远程IP地址
wsMessageBuf wsMessageBuf
} }
@@ -46,7 +47,7 @@ func (w *WSConn) readBytesBuf(c gnet.Conn) gnet.Action {
read, err := c.Read(buf) read, err := c.Read(buf)
if err != nil { if err != nil {
if w.logger != nil { if w.logger != nil {
w.logger.Errorf("ws read bytes buf error", err) w.logger.Errorf("ws read bytes buf error: %v", err)
} }
return gnet.Close return gnet.Close
} }
@@ -132,7 +133,7 @@ func (w *WSConn) readWsMessages() (messages []wsutil.Message, err error) {
} }
} else { //数据不完整 } else { //数据不完整
if w.logger != nil { if w.logger != nil {
w.logger.Debugf("ws read ws message incomplete data", in.Len(), dataLen) w.logger.Debugf("ws read ws message incomplete data ,%v,%v", in.Len(), dataLen)
} }
return return
} }

View File

@@ -1,62 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.32.0
// protoc v4.25.1
// source: sc_common.proto
package sc_common
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
var File_sc_common_proto protoreflect.FileDescriptor
var file_sc_common_proto_rawDesc = []byte{
0x0a, 0x0f, 0x73, 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x42, 0x1b, 0x5a, 0x19, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x2f, 0x73, 0x63, 0x2f, 0x73, 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var file_sc_common_proto_goTypes = []interface{}{}
var file_sc_common_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
0, // [0:0] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_sc_common_proto_init() }
func file_sc_common_proto_init() {
if File_sc_common_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_sc_common_proto_rawDesc,
NumEnums: 0,
NumMessages: 0,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_sc_common_proto_goTypes,
DependencyIndexes: file_sc_common_proto_depIdxs,
}.Build()
File_sc_common_proto = out.File
file_sc_common_proto_rawDesc = nil
file_sc_common_proto_goTypes = nil
file_sc_common_proto_depIdxs = nil
}

View File

@@ -1,521 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.32.0
// protoc v4.25.1
// source: action.proto
package sc_pb
import (
_ "common/proto/sc/sc_common"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// MESSAGE_ID_ACTION
type ActionID int32
const (
ActionID_ACTION_ID_MOVE ActionID = 0 // 移动
ActionID_ACTION_ID_ATTACK ActionID = 1 // 攻击
)
// Enum value maps for ActionID.
var (
ActionID_name = map[int32]string{
0: "ACTION_ID_MOVE",
1: "ACTION_ID_ATTACK",
}
ActionID_value = map[string]int32{
"ACTION_ID_MOVE": 0,
"ACTION_ID_ATTACK": 1,
}
)
func (x ActionID) Enum() *ActionID {
p := new(ActionID)
*p = x
return p
}
func (x ActionID) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (ActionID) Descriptor() protoreflect.EnumDescriptor {
return file_action_proto_enumTypes[0].Descriptor()
}
func (ActionID) Type() protoreflect.EnumType {
return &file_action_proto_enumTypes[0]
}
func (x ActionID) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use ActionID.Descriptor instead.
func (ActionID) EnumDescriptor() ([]byte, []int) {
return file_action_proto_rawDescGZIP(), []int{0}
}
// MESSAGE_ID_ENTER_INSTANCE
type C2S_EnterInstance struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
InstanceID int32 `protobuf:"varint,1,opt,name=InstanceID,proto3" json:"InstanceID,omitempty"`
}
func (x *C2S_EnterInstance) Reset() {
*x = C2S_EnterInstance{}
if protoimpl.UnsafeEnabled {
mi := &file_action_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *C2S_EnterInstance) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*C2S_EnterInstance) ProtoMessage() {}
func (x *C2S_EnterInstance) ProtoReflect() protoreflect.Message {
mi := &file_action_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use C2S_EnterInstance.ProtoReflect.Descriptor instead.
func (*C2S_EnterInstance) Descriptor() ([]byte, []int) {
return file_action_proto_rawDescGZIP(), []int{0}
}
func (x *C2S_EnterInstance) GetInstanceID() int32 {
if x != nil {
return x.InstanceID
}
return 0
}
type S2C_EnterInstance struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Info *PositionInfo `protobuf:"bytes,1,opt,name=Info,proto3" json:"Info,omitempty"`
}
func (x *S2C_EnterInstance) Reset() {
*x = S2C_EnterInstance{}
if protoimpl.UnsafeEnabled {
mi := &file_action_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *S2C_EnterInstance) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*S2C_EnterInstance) ProtoMessage() {}
func (x *S2C_EnterInstance) ProtoReflect() protoreflect.Message {
mi := &file_action_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use S2C_EnterInstance.ProtoReflect.Descriptor instead.
func (*S2C_EnterInstance) Descriptor() ([]byte, []int) {
return file_action_proto_rawDescGZIP(), []int{1}
}
func (x *S2C_EnterInstance) GetInfo() *PositionInfo {
if x != nil {
return x.Info
}
return nil
}
type C2S_Action struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Sequence uint32 `protobuf:"varint,1,opt,name=Sequence,proto3" json:"Sequence,omitempty"` // 指令序号
Timestamp int64 `protobuf:"varint,2,opt,name=Timestamp,proto3" json:"Timestamp,omitempty"` // 时间戳(毫秒)
Action ActionID `protobuf:"varint,3,opt,name=Action,proto3,enum=ActionID" json:"Action,omitempty"` // 指令ID
DirX int32 `protobuf:"zigzag32,4,opt,name=DirX,proto3" json:"DirX,omitempty"` // 移动-X方向(×100 缩放)
DirY int32 `protobuf:"zigzag32,5,opt,name=DirY,proto3" json:"DirY,omitempty"` // 移动-Y方向(×100 缩放)
SkillID int32 `protobuf:"varint,6,opt,name=SkillID,proto3" json:"SkillID,omitempty"` // 攻击-技能ID
}
func (x *C2S_Action) Reset() {
*x = C2S_Action{}
if protoimpl.UnsafeEnabled {
mi := &file_action_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *C2S_Action) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*C2S_Action) ProtoMessage() {}
func (x *C2S_Action) ProtoReflect() protoreflect.Message {
mi := &file_action_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use C2S_Action.ProtoReflect.Descriptor instead.
func (*C2S_Action) Descriptor() ([]byte, []int) {
return file_action_proto_rawDescGZIP(), []int{2}
}
func (x *C2S_Action) GetSequence() uint32 {
if x != nil {
return x.Sequence
}
return 0
}
func (x *C2S_Action) GetTimestamp() int64 {
if x != nil {
return x.Timestamp
}
return 0
}
func (x *C2S_Action) GetAction() ActionID {
if x != nil {
return x.Action
}
return ActionID_ACTION_ID_MOVE
}
func (x *C2S_Action) GetDirX() int32 {
if x != nil {
return x.DirX
}
return 0
}
func (x *C2S_Action) GetDirY() int32 {
if x != nil {
return x.DirY
}
return 0
}
func (x *C2S_Action) GetSkillID() int32 {
if x != nil {
return x.SkillID
}
return 0
}
// MESSAGE_ID_POSITION
type PositionInfo struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
USN int64 `protobuf:"varint,1,opt,name=USN,proto3" json:"USN,omitempty"`
X int32 `protobuf:"zigzag32,2,opt,name=X,proto3" json:"X,omitempty"`
Y int32 `protobuf:"zigzag32,3,opt,name=Y,proto3" json:"Y,omitempty"`
}
func (x *PositionInfo) Reset() {
*x = PositionInfo{}
if protoimpl.UnsafeEnabled {
mi := &file_action_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PositionInfo) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PositionInfo) ProtoMessage() {}
func (x *PositionInfo) ProtoReflect() protoreflect.Message {
mi := &file_action_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use PositionInfo.ProtoReflect.Descriptor instead.
func (*PositionInfo) Descriptor() ([]byte, []int) {
return file_action_proto_rawDescGZIP(), []int{3}
}
func (x *PositionInfo) GetUSN() int64 {
if x != nil {
return x.USN
}
return 0
}
func (x *PositionInfo) GetX() int32 {
if x != nil {
return x.X
}
return 0
}
func (x *PositionInfo) GetY() int32 {
if x != nil {
return x.Y
}
return 0
}
type S2C_Position struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Info []*PositionInfo `protobuf:"bytes,1,rep,name=Info,proto3" json:"Info,omitempty"`
}
func (x *S2C_Position) Reset() {
*x = S2C_Position{}
if protoimpl.UnsafeEnabled {
mi := &file_action_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *S2C_Position) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*S2C_Position) ProtoMessage() {}
func (x *S2C_Position) ProtoReflect() protoreflect.Message {
mi := &file_action_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use S2C_Position.ProtoReflect.Descriptor instead.
func (*S2C_Position) Descriptor() ([]byte, []int) {
return file_action_proto_rawDescGZIP(), []int{4}
}
func (x *S2C_Position) GetInfo() []*PositionInfo {
if x != nil {
return x.Info
}
return nil
}
var File_action_proto protoreflect.FileDescriptor
var file_action_proto_rawDesc = []byte{
0x0a, 0x0c, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f,
0x73, 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
0x33, 0x0a, 0x11, 0x43, 0x32, 0x53, 0x5f, 0x45, 0x6e, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x73, 0x74,
0x61, 0x6e, 0x63, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65,
0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e,
0x63, 0x65, 0x49, 0x44, 0x22, 0x36, 0x0a, 0x11, 0x53, 0x32, 0x43, 0x5f, 0x45, 0x6e, 0x74, 0x65,
0x72, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x21, 0x0a, 0x04, 0x49, 0x6e, 0x66,
0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69,
0x6f, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0xab, 0x01, 0x0a,
0x0a, 0x43, 0x32, 0x53, 0x5f, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x53,
0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x53,
0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x54, 0x69, 0x6d, 0x65, 0x73,
0x74, 0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x54, 0x69, 0x6d, 0x65,
0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x21, 0x0a, 0x06, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18,
0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x44,
0x52, 0x06, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x69, 0x72, 0x58,
0x18, 0x04, 0x20, 0x01, 0x28, 0x11, 0x52, 0x04, 0x44, 0x69, 0x72, 0x58, 0x12, 0x12, 0x0a, 0x04,
0x44, 0x69, 0x72, 0x59, 0x18, 0x05, 0x20, 0x01, 0x28, 0x11, 0x52, 0x04, 0x44, 0x69, 0x72, 0x59,
0x12, 0x18, 0x0a, 0x07, 0x53, 0x6b, 0x69, 0x6c, 0x6c, 0x49, 0x44, 0x18, 0x06, 0x20, 0x01, 0x28,
0x05, 0x52, 0x07, 0x53, 0x6b, 0x69, 0x6c, 0x6c, 0x49, 0x44, 0x22, 0x3c, 0x0a, 0x0c, 0x50, 0x6f,
0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x10, 0x0a, 0x03, 0x55, 0x53,
0x4e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x55, 0x53, 0x4e, 0x12, 0x0c, 0x0a, 0x01,
0x58, 0x18, 0x02, 0x20, 0x01, 0x28, 0x11, 0x52, 0x01, 0x58, 0x12, 0x0c, 0x0a, 0x01, 0x59, 0x18,
0x03, 0x20, 0x01, 0x28, 0x11, 0x52, 0x01, 0x59, 0x22, 0x31, 0x0a, 0x0c, 0x53, 0x32, 0x43, 0x5f,
0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x21, 0x0a, 0x04, 0x49, 0x6e, 0x66, 0x6f,
0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f,
0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x49, 0x6e, 0x66, 0x6f, 0x2a, 0x34, 0x0a, 0x08, 0x41,
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x44, 0x12, 0x12, 0x0a, 0x0e, 0x41, 0x43, 0x54, 0x49, 0x4f,
0x4e, 0x5f, 0x49, 0x44, 0x5f, 0x4d, 0x4f, 0x56, 0x45, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x41,
0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x49, 0x44, 0x5f, 0x41, 0x54, 0x54, 0x41, 0x43, 0x4b, 0x10,
0x01, 0x42, 0x17, 0x5a, 0x15, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x2f, 0x73, 0x63, 0x2f, 0x73, 0x63, 0x5f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
}
var (
file_action_proto_rawDescOnce sync.Once
file_action_proto_rawDescData = file_action_proto_rawDesc
)
func file_action_proto_rawDescGZIP() []byte {
file_action_proto_rawDescOnce.Do(func() {
file_action_proto_rawDescData = protoimpl.X.CompressGZIP(file_action_proto_rawDescData)
})
return file_action_proto_rawDescData
}
var file_action_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_action_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
var file_action_proto_goTypes = []interface{}{
(ActionID)(0), // 0: ActionID
(*C2S_EnterInstance)(nil), // 1: C2S_EnterInstance
(*S2C_EnterInstance)(nil), // 2: S2C_EnterInstance
(*C2S_Action)(nil), // 3: C2S_Action
(*PositionInfo)(nil), // 4: PositionInfo
(*S2C_Position)(nil), // 5: S2C_Position
}
var file_action_proto_depIdxs = []int32{
4, // 0: S2C_EnterInstance.Info:type_name -> PositionInfo
0, // 1: C2S_Action.Action:type_name -> ActionID
4, // 2: S2C_Position.Info:type_name -> PositionInfo
3, // [3:3] is the sub-list for method output_type
3, // [3:3] is the sub-list for method input_type
3, // [3:3] is the sub-list for extension type_name
3, // [3:3] is the sub-list for extension extendee
0, // [0:3] is the sub-list for field type_name
}
func init() { file_action_proto_init() }
func file_action_proto_init() {
if File_action_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_action_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*C2S_EnterInstance); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_action_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*S2C_EnterInstance); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_action_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*C2S_Action); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_action_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PositionInfo); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_action_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*S2C_Position); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_action_proto_rawDesc,
NumEnums: 1,
NumMessages: 5,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_action_proto_goTypes,
DependencyIndexes: file_action_proto_depIdxs,
EnumInfos: file_action_proto_enumTypes,
MessageInfos: file_action_proto_msgTypes,
}.Build()
File_action_proto = out.File
file_action_proto_rawDesc = nil
file_action_proto_goTypes = nil
file_action_proto_depIdxs = nil
}

View File

@@ -1,217 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.32.0
// protoc v4.25.1
// source: define.proto
package sc_pb
import (
_ "common/proto/sc/sc_common"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type MessageID int32
const (
MessageID_MESSAGE_ID_INVALID MessageID = 0
MessageID_MESSAGE_ID_ENTER_INSTANCE MessageID = 1 // 进入副本
MessageID_MESSAGE_ID_ACTION MessageID = 2 // 指令
MessageID_MESSAGE_ID_POSITION MessageID = 3 // 位置更新
)
// Enum value maps for MessageID.
var (
MessageID_name = map[int32]string{
0: "MESSAGE_ID_INVALID",
1: "MESSAGE_ID_ENTER_INSTANCE",
2: "MESSAGE_ID_ACTION",
3: "MESSAGE_ID_POSITION",
}
MessageID_value = map[string]int32{
"MESSAGE_ID_INVALID": 0,
"MESSAGE_ID_ENTER_INSTANCE": 1,
"MESSAGE_ID_ACTION": 2,
"MESSAGE_ID_POSITION": 3,
}
)
func (x MessageID) Enum() *MessageID {
p := new(MessageID)
*p = x
return p
}
func (x MessageID) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (MessageID) Descriptor() protoreflect.EnumDescriptor {
return file_define_proto_enumTypes[0].Descriptor()
}
func (MessageID) Type() protoreflect.EnumType {
return &file_define_proto_enumTypes[0]
}
func (x MessageID) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use MessageID.Descriptor instead.
func (MessageID) EnumDescriptor() ([]byte, []int) {
return file_define_proto_rawDescGZIP(), []int{0}
}
type Message struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ID MessageID `protobuf:"varint,1,opt,name=ID,proto3,enum=MessageID" json:"ID,omitempty"`
Payload []byte `protobuf:"bytes,2,opt,name=Payload,proto3" json:"Payload,omitempty"`
}
func (x *Message) Reset() {
*x = Message{}
if protoimpl.UnsafeEnabled {
mi := &file_define_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Message) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Message) ProtoMessage() {}
func (x *Message) ProtoReflect() protoreflect.Message {
mi := &file_define_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Message.ProtoReflect.Descriptor instead.
func (*Message) Descriptor() ([]byte, []int) {
return file_define_proto_rawDescGZIP(), []int{0}
}
func (x *Message) GetID() MessageID {
if x != nil {
return x.ID
}
return MessageID_MESSAGE_ID_INVALID
}
func (x *Message) GetPayload() []byte {
if x != nil {
return x.Payload
}
return nil
}
var File_define_proto protoreflect.FileDescriptor
var file_define_proto_rawDesc = []byte{
0x0a, 0x0c, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f,
0x73, 0x63, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
0x3f, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x02, 0x49, 0x44,
0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
0x49, 0x44, 0x52, 0x02, 0x49, 0x44, 0x12, 0x18, 0x0a, 0x07, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61,
0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64,
0x2a, 0x72, 0x0a, 0x09, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x44, 0x12, 0x16, 0x0a,
0x12, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45, 0x5f, 0x49, 0x44, 0x5f, 0x49, 0x4e, 0x56, 0x41,
0x4c, 0x49, 0x44, 0x10, 0x00, 0x12, 0x1d, 0x0a, 0x19, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45,
0x5f, 0x49, 0x44, 0x5f, 0x45, 0x4e, 0x54, 0x45, 0x52, 0x5f, 0x49, 0x4e, 0x53, 0x54, 0x41, 0x4e,
0x43, 0x45, 0x10, 0x01, 0x12, 0x15, 0x0a, 0x11, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45, 0x5f,
0x49, 0x44, 0x5f, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0x02, 0x12, 0x17, 0x0a, 0x13, 0x4d,
0x45, 0x53, 0x53, 0x41, 0x47, 0x45, 0x5f, 0x49, 0x44, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49,
0x4f, 0x4e, 0x10, 0x03, 0x42, 0x17, 0x5a, 0x15, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x63, 0x2f, 0x73, 0x63, 0x5f, 0x70, 0x62, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_define_proto_rawDescOnce sync.Once
file_define_proto_rawDescData = file_define_proto_rawDesc
)
func file_define_proto_rawDescGZIP() []byte {
file_define_proto_rawDescOnce.Do(func() {
file_define_proto_rawDescData = protoimpl.X.CompressGZIP(file_define_proto_rawDescData)
})
return file_define_proto_rawDescData
}
var file_define_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_define_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_define_proto_goTypes = []interface{}{
(MessageID)(0), // 0: MessageID
(*Message)(nil), // 1: Message
}
var file_define_proto_depIdxs = []int32{
0, // 0: Message.ID:type_name -> MessageID
1, // [1:1] is the sub-list for method output_type
1, // [1:1] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_define_proto_init() }
func file_define_proto_init() {
if File_define_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_define_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Message); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_define_proto_rawDesc,
NumEnums: 1,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_define_proto_goTypes,
DependencyIndexes: file_define_proto_depIdxs,
EnumInfos: file_define_proto_enumTypes,
MessageInfos: file_define_proto_msgTypes,
}.Build()
File_define_proto = out.File
file_define_proto_rawDesc = nil
file_define_proto_goTypes = nil
file_define_proto_depIdxs = nil
}

View File

@@ -1,221 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.32.0
// protoc v4.25.1
// source: service_gateway.proto
package grpc_pb
import (
_ "common/proto/ss/ss_common"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type ToClientReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
USN int64 `protobuf:"varint,1,opt,name=USN,proto3" json:"USN,omitempty"`
MessageID int32 `protobuf:"varint,2,opt,name=MessageID,proto3" json:"MessageID,omitempty"`
Payload []byte `protobuf:"bytes,3,opt,name=Payload,proto3" json:"Payload,omitempty"`
}
func (x *ToClientReq) Reset() {
*x = ToClientReq{}
if protoimpl.UnsafeEnabled {
mi := &file_service_gateway_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ToClientReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ToClientReq) ProtoMessage() {}
func (x *ToClientReq) ProtoReflect() protoreflect.Message {
mi := &file_service_gateway_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ToClientReq.ProtoReflect.Descriptor instead.
func (*ToClientReq) Descriptor() ([]byte, []int) {
return file_service_gateway_proto_rawDescGZIP(), []int{0}
}
func (x *ToClientReq) GetUSN() int64 {
if x != nil {
return x.USN
}
return 0
}
func (x *ToClientReq) GetMessageID() int32 {
if x != nil {
return x.MessageID
}
return 0
}
func (x *ToClientReq) GetPayload() []byte {
if x != nil {
return x.Payload
}
return nil
}
type ToClientResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *ToClientResp) Reset() {
*x = ToClientResp{}
if protoimpl.UnsafeEnabled {
mi := &file_service_gateway_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ToClientResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ToClientResp) ProtoMessage() {}
func (x *ToClientResp) ProtoReflect() protoreflect.Message {
mi := &file_service_gateway_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ToClientResp.ProtoReflect.Descriptor instead.
func (*ToClientResp) Descriptor() ([]byte, []int) {
return file_service_gateway_proto_rawDescGZIP(), []int{1}
}
var File_service_gateway_proto protoreflect.FileDescriptor
var file_service_gateway_proto_rawDesc = []byte{
0x0a, 0x15, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61,
0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x73, 0x73, 0x5f, 0x63, 0x6f, 0x6d, 0x6d,
0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x57, 0x0a, 0x0b, 0x54, 0x6f, 0x43, 0x6c,
0x69, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x55, 0x53, 0x4e, 0x18, 0x01,
0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x55, 0x53, 0x4e, 0x12, 0x1c, 0x0a, 0x09, 0x4d, 0x65, 0x73,
0x73, 0x61, 0x67, 0x65, 0x49, 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x4d, 0x65,
0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x44, 0x12, 0x18, 0x0a, 0x07, 0x50, 0x61, 0x79, 0x6c, 0x6f,
0x61, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61,
0x64, 0x22, 0x0e, 0x0a, 0x0c, 0x54, 0x6f, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73,
0x70, 0x32, 0x36, 0x0a, 0x07, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x12, 0x2b, 0x0a, 0x08,
0x54, 0x6f, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x0c, 0x2e, 0x54, 0x6f, 0x43, 0x6c, 0x69,
0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x0d, 0x2e, 0x54, 0x6f, 0x43, 0x6c, 0x69, 0x65, 0x6e,
0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x28, 0x01, 0x42, 0x19, 0x5a, 0x17, 0x63, 0x6f, 0x6d,
0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x73, 0x2f, 0x67, 0x72, 0x70,
0x63, 0x5f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_service_gateway_proto_rawDescOnce sync.Once
file_service_gateway_proto_rawDescData = file_service_gateway_proto_rawDesc
)
func file_service_gateway_proto_rawDescGZIP() []byte {
file_service_gateway_proto_rawDescOnce.Do(func() {
file_service_gateway_proto_rawDescData = protoimpl.X.CompressGZIP(file_service_gateway_proto_rawDescData)
})
return file_service_gateway_proto_rawDescData
}
var file_service_gateway_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_service_gateway_proto_goTypes = []interface{}{
(*ToClientReq)(nil), // 0: ToClientReq
(*ToClientResp)(nil), // 1: ToClientResp
}
var file_service_gateway_proto_depIdxs = []int32{
0, // 0: Gateway.ToClient:input_type -> ToClientReq
1, // 1: Gateway.ToClient:output_type -> ToClientResp
1, // [1:2] is the sub-list for method output_type
0, // [0:1] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_service_gateway_proto_init() }
func file_service_gateway_proto_init() {
if File_service_gateway_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_service_gateway_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ToClientReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_service_gateway_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ToClientResp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_service_gateway_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_service_gateway_proto_goTypes,
DependencyIndexes: file_service_gateway_proto_depIdxs,
MessageInfos: file_service_gateway_proto_msgTypes,
}.Build()
File_service_gateway_proto = out.File
file_service_gateway_proto_rawDesc = nil
file_service_gateway_proto_goTypes = nil
file_service_gateway_proto_depIdxs = nil
}

View File

@@ -1,141 +0,0 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v4.25.1
// source: service_gateway.proto
package grpc_pb
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// GatewayClient is the client API for Gateway service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type GatewayClient interface {
// 发送消息到客户端
ToClient(ctx context.Context, opts ...grpc.CallOption) (Gateway_ToClientClient, error)
}
type gatewayClient struct {
cc grpc.ClientConnInterface
}
func NewGatewayClient(cc grpc.ClientConnInterface) GatewayClient {
return &gatewayClient{cc}
}
func (c *gatewayClient) ToClient(ctx context.Context, opts ...grpc.CallOption) (Gateway_ToClientClient, error) {
stream, err := c.cc.NewStream(ctx, &Gateway_ServiceDesc.Streams[0], "/Gateway/ToClient", opts...)
if err != nil {
return nil, err
}
x := &gatewayToClientClient{stream}
return x, nil
}
type Gateway_ToClientClient interface {
Send(*ToClientReq) error
CloseAndRecv() (*ToClientResp, error)
grpc.ClientStream
}
type gatewayToClientClient struct {
grpc.ClientStream
}
func (x *gatewayToClientClient) Send(m *ToClientReq) error {
return x.ClientStream.SendMsg(m)
}
func (x *gatewayToClientClient) CloseAndRecv() (*ToClientResp, error) {
if err := x.ClientStream.CloseSend(); err != nil {
return nil, err
}
m := new(ToClientResp)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// GatewayServer is the server API for Gateway service.
// All implementations must embed UnimplementedGatewayServer
// for forward compatibility
type GatewayServer interface {
// 发送消息到客户端
ToClient(Gateway_ToClientServer) error
mustEmbedUnimplementedGatewayServer()
}
// UnimplementedGatewayServer must be embedded to have forward compatible implementations.
type UnimplementedGatewayServer struct {
}
func (UnimplementedGatewayServer) ToClient(Gateway_ToClientServer) error {
return status.Errorf(codes.Unimplemented, "method ToClient not implemented")
}
func (UnimplementedGatewayServer) mustEmbedUnimplementedGatewayServer() {}
// UnsafeGatewayServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to GatewayServer will
// result in compilation errors.
type UnsafeGatewayServer interface {
mustEmbedUnimplementedGatewayServer()
}
func RegisterGatewayServer(s grpc.ServiceRegistrar, srv GatewayServer) {
s.RegisterService(&Gateway_ServiceDesc, srv)
}
func _Gateway_ToClient_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(GatewayServer).ToClient(&gatewayToClientServer{stream})
}
type Gateway_ToClientServer interface {
SendAndClose(*ToClientResp) error
Recv() (*ToClientReq, error)
grpc.ServerStream
}
type gatewayToClientServer struct {
grpc.ServerStream
}
func (x *gatewayToClientServer) SendAndClose(m *ToClientResp) error {
return x.ServerStream.SendMsg(m)
}
func (x *gatewayToClientServer) Recv() (*ToClientReq, error) {
m := new(ToClientReq)
if err := x.ServerStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// Gateway_ServiceDesc is the grpc.ServiceDesc for Gateway service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Gateway_ServiceDesc = grpc.ServiceDesc{
ServiceName: "Gateway",
HandlerType: (*GatewayServer)(nil),
Methods: []grpc.MethodDesc{},
Streams: []grpc.StreamDesc{
{
StreamName: "ToClient",
Handler: _Gateway_ToClient_Handler,
ClientStreams: true,
},
},
Metadata: "service_gateway.proto",
}

View File

@@ -1,574 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.32.0
// protoc v4.25.1
// source: service_scene.proto
package grpc_pb
import (
_ "common/proto/ss/ss_common"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type EnterReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
USN int64 `protobuf:"varint,1,opt,name=USN,proto3" json:"USN,omitempty"` // 用户ID
GatewaySID int64 `protobuf:"varint,2,opt,name=GatewaySID,proto3" json:"GatewaySID,omitempty"` // 网关服务ID
InstanceID int32 `protobuf:"varint,3,opt,name=InstanceID,proto3" json:"InstanceID,omitempty"` // 副本ID
}
func (x *EnterReq) Reset() {
*x = EnterReq{}
if protoimpl.UnsafeEnabled {
mi := &file_service_scene_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *EnterReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*EnterReq) ProtoMessage() {}
func (x *EnterReq) ProtoReflect() protoreflect.Message {
mi := &file_service_scene_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use EnterReq.ProtoReflect.Descriptor instead.
func (*EnterReq) Descriptor() ([]byte, []int) {
return file_service_scene_proto_rawDescGZIP(), []int{0}
}
func (x *EnterReq) GetUSN() int64 {
if x != nil {
return x.USN
}
return 0
}
func (x *EnterReq) GetGatewaySID() int64 {
if x != nil {
return x.GatewaySID
}
return 0
}
func (x *EnterReq) GetInstanceID() int32 {
if x != nil {
return x.InstanceID
}
return 0
}
type EnterResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
SceneSID int64 `protobuf:"varint,1,opt,name=SceneSID,proto3" json:"SceneSID,omitempty"` // 场景服务ID
UniqueNo int64 `protobuf:"varint,2,opt,name=UniqueNo,proto3" json:"UniqueNo,omitempty"` // 副本唯一编号
MessageID int32 `protobuf:"varint,3,opt,name=MessageID,proto3" json:"MessageID,omitempty"` // 发送给客户端的消息ID
Payload []byte `protobuf:"bytes,4,opt,name=Payload,proto3" json:"Payload,omitempty"` // 消息负载
}
func (x *EnterResp) Reset() {
*x = EnterResp{}
if protoimpl.UnsafeEnabled {
mi := &file_service_scene_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *EnterResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*EnterResp) ProtoMessage() {}
func (x *EnterResp) ProtoReflect() protoreflect.Message {
mi := &file_service_scene_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use EnterResp.ProtoReflect.Descriptor instead.
func (*EnterResp) Descriptor() ([]byte, []int) {
return file_service_scene_proto_rawDescGZIP(), []int{1}
}
func (x *EnterResp) GetSceneSID() int64 {
if x != nil {
return x.SceneSID
}
return 0
}
func (x *EnterResp) GetUniqueNo() int64 {
if x != nil {
return x.UniqueNo
}
return 0
}
func (x *EnterResp) GetMessageID() int32 {
if x != nil {
return x.MessageID
}
return 0
}
func (x *EnterResp) GetPayload() []byte {
if x != nil {
return x.Payload
}
return nil
}
type LeaveReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
USN int64 `protobuf:"varint,1,opt,name=USN,proto3" json:"USN,omitempty"` // 用户ID
GatewaySID int64 `protobuf:"varint,2,opt,name=GatewaySID,proto3" json:"GatewaySID,omitempty"` // 网关服务ID
InstanceID int32 `protobuf:"varint,3,opt,name=InstanceID,proto3" json:"InstanceID,omitempty"` // 副本ID
UniqueNo int64 `protobuf:"varint,4,opt,name=UniqueNo,proto3" json:"UniqueNo,omitempty"` // 副本唯一编号
}
func (x *LeaveReq) Reset() {
*x = LeaveReq{}
if protoimpl.UnsafeEnabled {
mi := &file_service_scene_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *LeaveReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*LeaveReq) ProtoMessage() {}
func (x *LeaveReq) ProtoReflect() protoreflect.Message {
mi := &file_service_scene_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use LeaveReq.ProtoReflect.Descriptor instead.
func (*LeaveReq) Descriptor() ([]byte, []int) {
return file_service_scene_proto_rawDescGZIP(), []int{2}
}
func (x *LeaveReq) GetUSN() int64 {
if x != nil {
return x.USN
}
return 0
}
func (x *LeaveReq) GetGatewaySID() int64 {
if x != nil {
return x.GatewaySID
}
return 0
}
func (x *LeaveReq) GetInstanceID() int32 {
if x != nil {
return x.InstanceID
}
return 0
}
func (x *LeaveReq) GetUniqueNo() int64 {
if x != nil {
return x.UniqueNo
}
return 0
}
type LeaveResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *LeaveResp) Reset() {
*x = LeaveResp{}
if protoimpl.UnsafeEnabled {
mi := &file_service_scene_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *LeaveResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*LeaveResp) ProtoMessage() {}
func (x *LeaveResp) ProtoReflect() protoreflect.Message {
mi := &file_service_scene_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use LeaveResp.ProtoReflect.Descriptor instead.
func (*LeaveResp) Descriptor() ([]byte, []int) {
return file_service_scene_proto_rawDescGZIP(), []int{3}
}
type ActionReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
UniqueNo int64 `protobuf:"varint,1,opt,name=UniqueNo,proto3" json:"UniqueNo,omitempty"` // 副本唯一编号
USN int64 `protobuf:"varint,2,opt,name=USN,proto3" json:"USN,omitempty"` // 用户ID
Action int32 `protobuf:"varint,3,opt,name=Action,proto3" json:"Action,omitempty"` // 指令ID
DirX int32 `protobuf:"zigzag32,4,opt,name=DirX,proto3" json:"DirX,omitempty"` // 移动-X方向(×1000 缩放)
DirY int32 `protobuf:"zigzag32,5,opt,name=DirY,proto3" json:"DirY,omitempty"` // 移动-Y方向(×1000 缩放)
SkillID int32 `protobuf:"varint,6,opt,name=SkillID,proto3" json:"SkillID,omitempty"` // 攻击-技能ID
}
func (x *ActionReq) Reset() {
*x = ActionReq{}
if protoimpl.UnsafeEnabled {
mi := &file_service_scene_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ActionReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ActionReq) ProtoMessage() {}
func (x *ActionReq) ProtoReflect() protoreflect.Message {
mi := &file_service_scene_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ActionReq.ProtoReflect.Descriptor instead.
func (*ActionReq) Descriptor() ([]byte, []int) {
return file_service_scene_proto_rawDescGZIP(), []int{4}
}
func (x *ActionReq) GetUniqueNo() int64 {
if x != nil {
return x.UniqueNo
}
return 0
}
func (x *ActionReq) GetUSN() int64 {
if x != nil {
return x.USN
}
return 0
}
func (x *ActionReq) GetAction() int32 {
if x != nil {
return x.Action
}
return 0
}
func (x *ActionReq) GetDirX() int32 {
if x != nil {
return x.DirX
}
return 0
}
func (x *ActionReq) GetDirY() int32 {
if x != nil {
return x.DirY
}
return 0
}
func (x *ActionReq) GetSkillID() int32 {
if x != nil {
return x.SkillID
}
return 0
}
type ActionResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *ActionResp) Reset() {
*x = ActionResp{}
if protoimpl.UnsafeEnabled {
mi := &file_service_scene_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ActionResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ActionResp) ProtoMessage() {}
func (x *ActionResp) ProtoReflect() protoreflect.Message {
mi := &file_service_scene_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ActionResp.ProtoReflect.Descriptor instead.
func (*ActionResp) Descriptor() ([]byte, []int) {
return file_service_scene_proto_rawDescGZIP(), []int{5}
}
var File_service_scene_proto protoreflect.FileDescriptor
var file_service_scene_proto_rawDesc = []byte{
0x0a, 0x13, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x73, 0x63, 0x65, 0x6e, 0x65, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x73, 0x73, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x5c, 0x0a, 0x08, 0x45, 0x6e, 0x74, 0x65, 0x72, 0x52,
0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x55, 0x53, 0x4e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52,
0x03, 0x55, 0x53, 0x4e, 0x12, 0x1e, 0x0a, 0x0a, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53,
0x49, 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61,
0x79, 0x53, 0x49, 0x44, 0x12, 0x1e, 0x0a, 0x0a, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65,
0x49, 0x44, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e,
0x63, 0x65, 0x49, 0x44, 0x22, 0x7b, 0x0a, 0x09, 0x45, 0x6e, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73,
0x70, 0x12, 0x1a, 0x0a, 0x08, 0x53, 0x63, 0x65, 0x6e, 0x65, 0x53, 0x49, 0x44, 0x18, 0x01, 0x20,
0x01, 0x28, 0x03, 0x52, 0x08, 0x53, 0x63, 0x65, 0x6e, 0x65, 0x53, 0x49, 0x44, 0x12, 0x1a, 0x0a,
0x08, 0x55, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x4e, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52,
0x08, 0x55, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x4e, 0x6f, 0x12, 0x1c, 0x0a, 0x09, 0x4d, 0x65, 0x73,
0x73, 0x61, 0x67, 0x65, 0x49, 0x44, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x4d, 0x65,
0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x44, 0x12, 0x18, 0x0a, 0x07, 0x50, 0x61, 0x79, 0x6c, 0x6f,
0x61, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61,
0x64, 0x22, 0x78, 0x0a, 0x08, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a,
0x03, 0x55, 0x53, 0x4e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x55, 0x53, 0x4e, 0x12,
0x1e, 0x0a, 0x0a, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x49, 0x44, 0x18, 0x02, 0x20,
0x01, 0x28, 0x03, 0x52, 0x0a, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x49, 0x44, 0x12,
0x1e, 0x0a, 0x0a, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x44, 0x18, 0x03, 0x20,
0x01, 0x28, 0x05, 0x52, 0x0a, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x44, 0x12,
0x1a, 0x0a, 0x08, 0x55, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x4e, 0x6f, 0x18, 0x04, 0x20, 0x01, 0x28,
0x03, 0x52, 0x08, 0x55, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x4e, 0x6f, 0x22, 0x0b, 0x0a, 0x09, 0x4c,
0x65, 0x61, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x22, 0x93, 0x01, 0x0a, 0x09, 0x41, 0x63, 0x74,
0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x55, 0x6e, 0x69, 0x71, 0x75, 0x65,
0x4e, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x55, 0x6e, 0x69, 0x71, 0x75, 0x65,
0x4e, 0x6f, 0x12, 0x10, 0x0a, 0x03, 0x55, 0x53, 0x4e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52,
0x03, 0x55, 0x53, 0x4e, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03,
0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04,
0x44, 0x69, 0x72, 0x58, 0x18, 0x04, 0x20, 0x01, 0x28, 0x11, 0x52, 0x04, 0x44, 0x69, 0x72, 0x58,
0x12, 0x12, 0x0a, 0x04, 0x44, 0x69, 0x72, 0x59, 0x18, 0x05, 0x20, 0x01, 0x28, 0x11, 0x52, 0x04,
0x44, 0x69, 0x72, 0x59, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x6b, 0x69, 0x6c, 0x6c, 0x49, 0x44, 0x18,
0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x53, 0x6b, 0x69, 0x6c, 0x6c, 0x49, 0x44, 0x22, 0x0c,
0x0a, 0x0a, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x32, 0x72, 0x0a, 0x05,
0x53, 0x63, 0x65, 0x6e, 0x65, 0x12, 0x20, 0x0a, 0x05, 0x45, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x09,
0x2e, 0x45, 0x6e, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x0a, 0x2e, 0x45, 0x6e, 0x74, 0x65,
0x72, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x20, 0x0a, 0x05, 0x4c, 0x65, 0x61, 0x76, 0x65,
0x12, 0x09, 0x2e, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x0a, 0x2e, 0x4c, 0x65,
0x61, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x25, 0x0a, 0x06, 0x41, 0x63, 0x74,
0x69, 0x6f, 0x6e, 0x12, 0x0a, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x1a,
0x0b, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x28, 0x01,
0x42, 0x19, 0x5a, 0x17, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x2f, 0x73, 0x73, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
}
var (
file_service_scene_proto_rawDescOnce sync.Once
file_service_scene_proto_rawDescData = file_service_scene_proto_rawDesc
)
func file_service_scene_proto_rawDescGZIP() []byte {
file_service_scene_proto_rawDescOnce.Do(func() {
file_service_scene_proto_rawDescData = protoimpl.X.CompressGZIP(file_service_scene_proto_rawDescData)
})
return file_service_scene_proto_rawDescData
}
var file_service_scene_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_service_scene_proto_goTypes = []interface{}{
(*EnterReq)(nil), // 0: EnterReq
(*EnterResp)(nil), // 1: EnterResp
(*LeaveReq)(nil), // 2: LeaveReq
(*LeaveResp)(nil), // 3: LeaveResp
(*ActionReq)(nil), // 4: ActionReq
(*ActionResp)(nil), // 5: ActionResp
}
var file_service_scene_proto_depIdxs = []int32{
0, // 0: Scene.Enter:input_type -> EnterReq
2, // 1: Scene.Leave:input_type -> LeaveReq
4, // 2: Scene.Action:input_type -> ActionReq
1, // 3: Scene.Enter:output_type -> EnterResp
3, // 4: Scene.Leave:output_type -> LeaveResp
5, // 5: Scene.Action:output_type -> ActionResp
3, // [3:6] is the sub-list for method output_type
0, // [0:3] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_service_scene_proto_init() }
func file_service_scene_proto_init() {
if File_service_scene_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_service_scene_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*EnterReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_service_scene_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*EnterResp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_service_scene_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*LeaveReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_service_scene_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*LeaveResp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_service_scene_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ActionReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_service_scene_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ActionResp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_service_scene_proto_rawDesc,
NumEnums: 0,
NumMessages: 6,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_service_scene_proto_goTypes,
DependencyIndexes: file_service_scene_proto_depIdxs,
MessageInfos: file_service_scene_proto_msgTypes,
}.Build()
File_service_scene_proto = out.File
file_service_scene_proto_rawDesc = nil
file_service_scene_proto_goTypes = nil
file_service_scene_proto_depIdxs = nil
}

View File

@@ -1,212 +0,0 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v4.25.1
// source: service_scene.proto
package grpc_pb
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// SceneClient is the client API for Scene service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type SceneClient interface {
Enter(ctx context.Context, in *EnterReq, opts ...grpc.CallOption) (*EnterResp, error)
Leave(ctx context.Context, in *LeaveReq, opts ...grpc.CallOption) (*LeaveResp, error)
Action(ctx context.Context, opts ...grpc.CallOption) (Scene_ActionClient, error)
}
type sceneClient struct {
cc grpc.ClientConnInterface
}
func NewSceneClient(cc grpc.ClientConnInterface) SceneClient {
return &sceneClient{cc}
}
func (c *sceneClient) Enter(ctx context.Context, in *EnterReq, opts ...grpc.CallOption) (*EnterResp, error) {
out := new(EnterResp)
err := c.cc.Invoke(ctx, "/Scene/Enter", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *sceneClient) Leave(ctx context.Context, in *LeaveReq, opts ...grpc.CallOption) (*LeaveResp, error) {
out := new(LeaveResp)
err := c.cc.Invoke(ctx, "/Scene/Leave", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *sceneClient) Action(ctx context.Context, opts ...grpc.CallOption) (Scene_ActionClient, error) {
stream, err := c.cc.NewStream(ctx, &Scene_ServiceDesc.Streams[0], "/Scene/Action", opts...)
if err != nil {
return nil, err
}
x := &sceneActionClient{stream}
return x, nil
}
type Scene_ActionClient interface {
Send(*ActionReq) error
CloseAndRecv() (*ActionResp, error)
grpc.ClientStream
}
type sceneActionClient struct {
grpc.ClientStream
}
func (x *sceneActionClient) Send(m *ActionReq) error {
return x.ClientStream.SendMsg(m)
}
func (x *sceneActionClient) CloseAndRecv() (*ActionResp, error) {
if err := x.ClientStream.CloseSend(); err != nil {
return nil, err
}
m := new(ActionResp)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// SceneServer is the server API for Scene service.
// All implementations must embed UnimplementedSceneServer
// for forward compatibility
type SceneServer interface {
Enter(context.Context, *EnterReq) (*EnterResp, error)
Leave(context.Context, *LeaveReq) (*LeaveResp, error)
Action(Scene_ActionServer) error
mustEmbedUnimplementedSceneServer()
}
// UnimplementedSceneServer must be embedded to have forward compatible implementations.
type UnimplementedSceneServer struct {
}
func (UnimplementedSceneServer) Enter(context.Context, *EnterReq) (*EnterResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method Enter not implemented")
}
func (UnimplementedSceneServer) Leave(context.Context, *LeaveReq) (*LeaveResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method Leave not implemented")
}
func (UnimplementedSceneServer) Action(Scene_ActionServer) error {
return status.Errorf(codes.Unimplemented, "method Action not implemented")
}
func (UnimplementedSceneServer) mustEmbedUnimplementedSceneServer() {}
// UnsafeSceneServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to SceneServer will
// result in compilation errors.
type UnsafeSceneServer interface {
mustEmbedUnimplementedSceneServer()
}
func RegisterSceneServer(s grpc.ServiceRegistrar, srv SceneServer) {
s.RegisterService(&Scene_ServiceDesc, srv)
}
func _Scene_Enter_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(EnterReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SceneServer).Enter(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Scene/Enter",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SceneServer).Enter(ctx, req.(*EnterReq))
}
return interceptor(ctx, in, info, handler)
}
func _Scene_Leave_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(LeaveReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SceneServer).Leave(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Scene/Leave",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SceneServer).Leave(ctx, req.(*LeaveReq))
}
return interceptor(ctx, in, info, handler)
}
func _Scene_Action_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(SceneServer).Action(&sceneActionServer{stream})
}
type Scene_ActionServer interface {
SendAndClose(*ActionResp) error
Recv() (*ActionReq, error)
grpc.ServerStream
}
type sceneActionServer struct {
grpc.ServerStream
}
func (x *sceneActionServer) SendAndClose(m *ActionResp) error {
return x.ServerStream.SendMsg(m)
}
func (x *sceneActionServer) Recv() (*ActionReq, error) {
m := new(ActionReq)
if err := x.ServerStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// Scene_ServiceDesc is the grpc.ServiceDesc for Scene service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Scene_ServiceDesc = grpc.ServiceDesc{
ServiceName: "Scene",
HandlerType: (*SceneServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Enter",
Handler: _Scene_Enter_Handler,
},
{
MethodName: "Leave",
Handler: _Scene_Leave_Handler,
},
},
Streams: []grpc.StreamDesc{
{
StreamName: "Action",
Handler: _Scene_Action_Handler,
ClientStreams: true,
},
},
Metadata: "service_scene.proto",
}

View File

@@ -1,372 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.32.0
// protoc v4.25.1
// source: service_user.proto
package grpc_pb
import (
_ "common/proto/ss/ss_common"
_ "google.golang.org/genproto/googleapis/api/annotations"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type LoginReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Phone string `protobuf:"bytes,1,opt,name=Phone,json=phone,proto3" json:"Phone,omitempty"` // 手机号
Code string `protobuf:"bytes,2,opt,name=Code,json=code,proto3" json:"Code,omitempty"` // 验证码
}
func (x *LoginReq) Reset() {
*x = LoginReq{}
if protoimpl.UnsafeEnabled {
mi := &file_service_user_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *LoginReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*LoginReq) ProtoMessage() {}
func (x *LoginReq) ProtoReflect() protoreflect.Message {
mi := &file_service_user_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use LoginReq.ProtoReflect.Descriptor instead.
func (*LoginReq) Descriptor() ([]byte, []int) {
return file_service_user_proto_rawDescGZIP(), []int{0}
}
func (x *LoginReq) GetPhone() string {
if x != nil {
return x.Phone
}
return ""
}
func (x *LoginReq) GetCode() string {
if x != nil {
return x.Code
}
return ""
}
type LoginResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
USN int64 `protobuf:"varint,1,opt,name=USN,json=usn,proto3" json:"USN,omitempty"` // 用户ID
Name string `protobuf:"bytes,2,opt,name=Name,json=name,proto3" json:"Name,omitempty"` // 用户名
}
func (x *LoginResp) Reset() {
*x = LoginResp{}
if protoimpl.UnsafeEnabled {
mi := &file_service_user_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *LoginResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*LoginResp) ProtoMessage() {}
func (x *LoginResp) ProtoReflect() protoreflect.Message {
mi := &file_service_user_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use LoginResp.ProtoReflect.Descriptor instead.
func (*LoginResp) Descriptor() ([]byte, []int) {
return file_service_user_proto_rawDescGZIP(), []int{1}
}
func (x *LoginResp) GetUSN() int64 {
if x != nil {
return x.USN
}
return 0
}
func (x *LoginResp) GetName() string {
if x != nil {
return x.Name
}
return ""
}
type GetUserInfoReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
USN int64 `protobuf:"varint,1,opt,name=USN,json=usn,proto3" json:"USN,omitempty"`
}
func (x *GetUserInfoReq) Reset() {
*x = GetUserInfoReq{}
if protoimpl.UnsafeEnabled {
mi := &file_service_user_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetUserInfoReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetUserInfoReq) ProtoMessage() {}
func (x *GetUserInfoReq) ProtoReflect() protoreflect.Message {
mi := &file_service_user_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetUserInfoReq.ProtoReflect.Descriptor instead.
func (*GetUserInfoReq) Descriptor() ([]byte, []int) {
return file_service_user_proto_rawDescGZIP(), []int{2}
}
func (x *GetUserInfoReq) GetUSN() int64 {
if x != nil {
return x.USN
}
return 0
}
type GetUserInfoResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
USN int64 `protobuf:"varint,1,opt,name=USN,json=usn,proto3" json:"USN,omitempty"`
Name string `protobuf:"bytes,2,opt,name=Name,json=name,proto3" json:"Name,omitempty"`
}
func (x *GetUserInfoResp) Reset() {
*x = GetUserInfoResp{}
if protoimpl.UnsafeEnabled {
mi := &file_service_user_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetUserInfoResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetUserInfoResp) ProtoMessage() {}
func (x *GetUserInfoResp) ProtoReflect() protoreflect.Message {
mi := &file_service_user_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetUserInfoResp.ProtoReflect.Descriptor instead.
func (*GetUserInfoResp) Descriptor() ([]byte, []int) {
return file_service_user_proto_rawDescGZIP(), []int{3}
}
func (x *GetUserInfoResp) GetUSN() int64 {
if x != nil {
return x.USN
}
return 0
}
func (x *GetUserInfoResp) GetName() string {
if x != nil {
return x.Name
}
return ""
}
var File_service_user_proto protoreflect.FileDescriptor
var file_service_user_proto_rawDesc = []byte{
0x0a, 0x12, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x73, 0x73, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70,
0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x22, 0x34, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x12,
0x14, 0x0a, 0x05, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05,
0x70, 0x68, 0x6f, 0x6e, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20,
0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x22, 0x31, 0x0a, 0x09, 0x4c, 0x6f, 0x67,
0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x55, 0x53, 0x4e, 0x18, 0x01, 0x20,
0x01, 0x28, 0x03, 0x52, 0x03, 0x75, 0x73, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x22, 0x0a, 0x0e,
0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x12, 0x10,
0x0a, 0x03, 0x55, 0x53, 0x4e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x75, 0x73, 0x6e,
0x22, 0x37, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52,
0x65, 0x73, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x55, 0x53, 0x4e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03,
0x52, 0x03, 0x75, 0x73, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20,
0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x32, 0x71, 0x0a, 0x04, 0x55, 0x73, 0x65,
0x72, 0x12, 0x20, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x09, 0x2e, 0x4c, 0x6f, 0x67,
0x69, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x0a, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73,
0x70, 0x22, 0x00, 0x12, 0x47, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e,
0x66, 0x6f, 0x12, 0x0f, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f,
0x52, 0x65, 0x71, 0x1a, 0x10, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66,
0x6f, 0x52, 0x65, 0x73, 0x70, 0x22, 0x15, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0f, 0x3a, 0x01, 0x2a,
0x22, 0x0a, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x69, 0x6e, 0x66, 0x6f, 0x42, 0x19, 0x5a, 0x17,
0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x73, 0x2f,
0x67, 0x72, 0x70, 0x63, 0x5f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_service_user_proto_rawDescOnce sync.Once
file_service_user_proto_rawDescData = file_service_user_proto_rawDesc
)
func file_service_user_proto_rawDescGZIP() []byte {
file_service_user_proto_rawDescOnce.Do(func() {
file_service_user_proto_rawDescData = protoimpl.X.CompressGZIP(file_service_user_proto_rawDescData)
})
return file_service_user_proto_rawDescData
}
var file_service_user_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_service_user_proto_goTypes = []interface{}{
(*LoginReq)(nil), // 0: LoginReq
(*LoginResp)(nil), // 1: LoginResp
(*GetUserInfoReq)(nil), // 2: GetUserInfoReq
(*GetUserInfoResp)(nil), // 3: GetUserInfoResp
}
var file_service_user_proto_depIdxs = []int32{
0, // 0: User.Login:input_type -> LoginReq
2, // 1: User.GetUserInfo:input_type -> GetUserInfoReq
1, // 2: User.Login:output_type -> LoginResp
3, // 3: User.GetUserInfo:output_type -> GetUserInfoResp
2, // [2:4] is the sub-list for method output_type
0, // [0:2] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_service_user_proto_init() }
func file_service_user_proto_init() {
if File_service_user_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_service_user_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*LoginReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_service_user_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*LoginResp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_service_user_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetUserInfoReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_service_user_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetUserInfoResp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_service_user_proto_rawDesc,
NumEnums: 0,
NumMessages: 4,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_service_user_proto_goTypes,
DependencyIndexes: file_service_user_proto_depIdxs,
MessageInfos: file_service_user_proto_msgTypes,
}.Build()
File_service_user_proto = out.File
file_service_user_proto_rawDesc = nil
file_service_user_proto_goTypes = nil
file_service_user_proto_depIdxs = nil
}

View File

@@ -1,154 +0,0 @@
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: service_user.proto
/*
Package grpc_pb is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
*/
package grpc_pb
import (
"context"
"errors"
"io"
"net/http"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
)
// Suppress "imported and not used" errors
var (
_ codes.Code
_ io.Reader
_ status.Status
_ = errors.New
_ = runtime.String
_ = utilities.NewDoubleArray
_ = metadata.Join
)
func request_User_GetUserInfo_0(ctx context.Context, marshaler runtime.Marshaler, client UserClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GetUserInfoReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.GetUserInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_User_GetUserInfo_0(ctx context.Context, marshaler runtime.Marshaler, server UserServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GetUserInfoReq
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.GetUserInfo(ctx, &protoReq)
return msg, metadata, err
}
// RegisterUserHandlerServer registers the http handlers for service User to "mux".
// UnaryRPC :call UserServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterUserHandlerFromEndpoint instead.
// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call.
func RegisterUserHandlerServer(ctx context.Context, mux *runtime.ServeMux, server UserServer) error {
mux.Handle(http.MethodPost, pattern_User_GetUserInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/.User/GetUserInfo", runtime.WithHTTPPathPattern("/user/info"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_User_GetUserInfo_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_User_GetUserInfo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
// RegisterUserHandlerFromEndpoint is same as RegisterUserHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterUserHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
conn, err := grpc.NewClient(endpoint, opts...)
if err != nil {
return err
}
defer func() {
if err != nil {
if cerr := conn.Close(); cerr != nil {
grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
}
return
}
go func() {
<-ctx.Done()
if cerr := conn.Close(); cerr != nil {
grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
}
}()
}()
return RegisterUserHandler(ctx, mux, conn)
}
// RegisterUserHandler registers the http handlers for service User to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterUserHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterUserHandlerClient(ctx, mux, NewUserClient(conn))
}
// RegisterUserHandlerClient registers the http handlers for service User
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "UserClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "UserClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "UserClient" to call the correct interceptors. This client ignores the HTTP middlewares.
func RegisterUserHandlerClient(ctx context.Context, mux *runtime.ServeMux, client UserClient) error {
mux.Handle(http.MethodPost, pattern_User_GetUserInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/.User/GetUserInfo", runtime.WithHTTPPathPattern("/user/info"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_User_GetUserInfo_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_User_GetUserInfo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
var (
pattern_User_GetUserInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"user", "info"}, ""))
)
var (
forward_User_GetUserInfo_0 = runtime.ForwardResponseMessage
)

View File

@@ -1,141 +0,0 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v4.25.1
// source: service_user.proto
package grpc_pb
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// UserClient is the client API for User service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type UserClient interface {
Login(ctx context.Context, in *LoginReq, opts ...grpc.CallOption) (*LoginResp, error)
GetUserInfo(ctx context.Context, in *GetUserInfoReq, opts ...grpc.CallOption) (*GetUserInfoResp, error)
}
type userClient struct {
cc grpc.ClientConnInterface
}
func NewUserClient(cc grpc.ClientConnInterface) UserClient {
return &userClient{cc}
}
func (c *userClient) Login(ctx context.Context, in *LoginReq, opts ...grpc.CallOption) (*LoginResp, error) {
out := new(LoginResp)
err := c.cc.Invoke(ctx, "/User/Login", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *userClient) GetUserInfo(ctx context.Context, in *GetUserInfoReq, opts ...grpc.CallOption) (*GetUserInfoResp, error) {
out := new(GetUserInfoResp)
err := c.cc.Invoke(ctx, "/User/GetUserInfo", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// UserServer is the server API for User service.
// All implementations must embed UnimplementedUserServer
// for forward compatibility
type UserServer interface {
Login(context.Context, *LoginReq) (*LoginResp, error)
GetUserInfo(context.Context, *GetUserInfoReq) (*GetUserInfoResp, error)
mustEmbedUnimplementedUserServer()
}
// UnimplementedUserServer must be embedded to have forward compatible implementations.
type UnimplementedUserServer struct {
}
func (UnimplementedUserServer) Login(context.Context, *LoginReq) (*LoginResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method Login not implemented")
}
func (UnimplementedUserServer) GetUserInfo(context.Context, *GetUserInfoReq) (*GetUserInfoResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetUserInfo not implemented")
}
func (UnimplementedUserServer) mustEmbedUnimplementedUserServer() {}
// UnsafeUserServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to UserServer will
// result in compilation errors.
type UnsafeUserServer interface {
mustEmbedUnimplementedUserServer()
}
func RegisterUserServer(s grpc.ServiceRegistrar, srv UserServer) {
s.RegisterService(&User_ServiceDesc, srv)
}
func _User_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(LoginReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserServer).Login(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/User/Login",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServer).Login(ctx, req.(*LoginReq))
}
return interceptor(ctx, in, info, handler)
}
func _User_GetUserInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetUserInfoReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserServer).GetUserInfo(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/User/GetUserInfo",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServer).GetUserInfo(ctx, req.(*GetUserInfoReq))
}
return interceptor(ctx, in, info, handler)
}
// User_ServiceDesc is the grpc.ServiceDesc for User service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var User_ServiceDesc = grpc.ServiceDesc{
ServiceName: "User",
HandlerType: (*UserServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Login",
Handler: _User_Login_Handler,
},
{
MethodName: "GetUserInfo",
Handler: _User_GetUserInfo_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "service_user.proto",
}

View File

@@ -1,151 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.32.0
// protoc v4.25.1
// source: ss_common.proto
package ss_common
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type ErrorInfo struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Code int32 `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"`
Msg string `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"`
}
func (x *ErrorInfo) Reset() {
*x = ErrorInfo{}
if protoimpl.UnsafeEnabled {
mi := &file_ss_common_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ErrorInfo) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ErrorInfo) ProtoMessage() {}
func (x *ErrorInfo) ProtoReflect() protoreflect.Message {
mi := &file_ss_common_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ErrorInfo.ProtoReflect.Descriptor instead.
func (*ErrorInfo) Descriptor() ([]byte, []int) {
return file_ss_common_proto_rawDescGZIP(), []int{0}
}
func (x *ErrorInfo) GetCode() int32 {
if x != nil {
return x.Code
}
return 0
}
func (x *ErrorInfo) GetMsg() string {
if x != nil {
return x.Msg
}
return ""
}
var File_ss_common_proto protoreflect.FileDescriptor
var file_ss_common_proto_rawDesc = []byte{
0x0a, 0x0f, 0x73, 0x73, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x22, 0x31, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x12,
0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f,
0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x03, 0x4d, 0x73, 0x67, 0x42, 0x1b, 0x5a, 0x19, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x73, 0x2f, 0x73, 0x73, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f,
0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_ss_common_proto_rawDescOnce sync.Once
file_ss_common_proto_rawDescData = file_ss_common_proto_rawDesc
)
func file_ss_common_proto_rawDescGZIP() []byte {
file_ss_common_proto_rawDescOnce.Do(func() {
file_ss_common_proto_rawDescData = protoimpl.X.CompressGZIP(file_ss_common_proto_rawDescData)
})
return file_ss_common_proto_rawDescData
}
var file_ss_common_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_ss_common_proto_goTypes = []interface{}{
(*ErrorInfo)(nil), // 0: ErrorInfo
}
var file_ss_common_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
0, // [0:0] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_ss_common_proto_init() }
func file_ss_common_proto_init() {
if File_ss_common_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_ss_common_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ErrorInfo); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_ss_common_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_ss_common_proto_goTypes,
DependencyIndexes: file_ss_common_proto_depIdxs,
MessageInfos: file_ss_common_proto_msgTypes,
}.Build()
File_ss_common_proto = out.File
file_ss_common_proto_rawDesc = nil
file_ss_common_proto_goTypes = nil
file_ss_common_proto_depIdxs = nil
}

143
server/status.go Normal file
View File

@@ -0,0 +1,143 @@
package server
import (
"context"
"git.hlsq.asia/alex/service-common/db/etcd"
"git.hlsq.asia/alex/service-common/log"
"go.etcd.io/etcd/api/v3/mvccpb"
clientv3 "go.etcd.io/etcd/client/v3"
"sync"
)
var (
statusWg = &sync.WaitGroup{}
statusStopFunc context.CancelFunc
)
const (
serverStatusKey = "/server/status" // 状态key
)
type StatusType string
const (
StatusInit StatusType = "init" // 初始化状态
StatusRunning StatusType = "running" // 运行中
StatusMaintenance StatusType = "maintenance" // 维护中
StatusWhitelist StatusType = "whitelist" // 白名单模式
)
var serverStatus *Status
type Status struct {
etcdClient *etcd.Client
status StatusType
mu sync.RWMutex
callbacks []func(status StatusType)
}
func InitStatus() {
serverStatus = &Status{
etcdClient: etcd.GetClient(),
status: StatusInit,
mu: sync.RWMutex{},
}
}
func GetServerStatus() *Status {
return serverStatus
}
func ListenStatus(ready *sync.WaitGroup) {
var stopCtx context.Context
stopCtx, statusStopFunc = context.WithCancel(context.Background())
statusWg.Add(1)
go func(stopCtx context.Context) {
defer statusWg.Done()
// 监听状态变化
serverStatusResp, _ := serverStatus.etcdClient.Get(serverStatusKey)
for _, kv := range serverStatusResp.Kvs {
serverStatus.onStatusChange(clientv3.EventTypePut, string(kv.Key), string(kv.Value))
}
serverStatusWatchChan := serverStatus.etcdClient.Watch(serverStatusKey,
clientv3.WithRev(serverStatusResp.Header.Revision+1))
ready.Done()
for {
select {
case msg := <-serverStatusWatchChan:
for _, event := range msg.Events {
serverStatus.onStatusChange(event.Type, string(event.Kv.Key), string(event.Kv.Value))
}
case <-stopCtx.Done():
return
}
}
}(stopCtx)
return
}
func CloseStatus() {
if statusStopFunc != nil {
statusStopFunc()
statusWg.Wait()
}
}
func (s *Status) GetStatus() StatusType {
s.mu.RLock()
defer s.mu.RUnlock()
return s.status
}
func (s *Status) CanAccess(usn int64) bool {
var status StatusType
s.mu.RLock()
status = s.status
s.mu.RUnlock()
switch status {
case StatusRunning:
return true
case StatusMaintenance:
return false
case StatusWhitelist:
return GetServerWhitelist().CheckWhitelist(usn)
default:
return false
}
}
func (s *Status) RegisterChangeCallback(fc func(status StatusType)) {
s.mu.Lock()
defer s.mu.Unlock()
s.callbacks = append(s.callbacks, fc)
}
func (s *Status) SetStatus(status string) {
_, err := s.etcdClient.Put(serverStatusKey, status)
if err != nil {
log.Errorf("server status set failed: %v", err)
return
}
return
}
func (s *Status) onStatusChange(t mvccpb.Event_EventType, key, value string) {
if key != serverStatusKey {
return
}
switch t {
case clientv3.EventTypePut:
s.mu.Lock()
s.status = StatusType(value)
s.mu.Unlock()
for _, fc := range s.callbacks {
fc(StatusType(value))
}
}
}

215
server/whitelist.go Normal file
View File

@@ -0,0 +1,215 @@
package server
import (
"context"
"encoding/json"
"git.hlsq.asia/alex/service-common/db/etcd"
"git.hlsq.asia/alex/service-common/log"
"go.etcd.io/etcd/api/v3/mvccpb"
clientv3 "go.etcd.io/etcd/client/v3"
"sync"
)
var (
whiteListenWg = &sync.WaitGroup{}
whiteListenStopFunc context.CancelFunc
)
const (
serverWhitelistKey = "/server/whitelist" // 白名单列表key
serverFactoryWhitelistKey = "/server/factory_whitelist" // 工厂白名单列表key
)
const whitelistUsnList = "usn_list" // usn白名单列表字段名
type Whitelist struct {
etcdClient *etcd.Client
mu sync.RWMutex
whitelist map[int64]struct{}
factoryWhitelist map[int64]struct{}
}
var serverWhitelist *Whitelist
func InitWhitelist() {
serverWhitelist = &Whitelist{
etcdClient: etcd.GetClient(),
mu: sync.RWMutex{},
whitelist: make(map[int64]struct{}),
factoryWhitelist: make(map[int64]struct{}),
}
}
func ListenWhitelist(ready *sync.WaitGroup) {
var stopCtx context.Context
stopCtx, whiteListenStopFunc = context.WithCancel(context.Background())
whiteListenWg.Add(1)
go func(stopCtx context.Context) {
defer whiteListenWg.Done()
// 监听工厂白名单变化
serverFactoryWhitelistResp, _ := serverWhitelist.etcdClient.Get(serverFactoryWhitelistKey)
for _, kv := range serverFactoryWhitelistResp.Kvs {
serverWhitelist.onFactoryWhitelistChange(clientv3.EventTypePut, string(kv.Key), string(kv.Value))
}
serverFactoryWhitelistWatchChan := serverWhitelist.etcdClient.Watch(serverFactoryWhitelistKey,
clientv3.WithRev(serverFactoryWhitelistResp.Header.Revision+1))
// 监听白名单变化
serverWhitelistResp, _ := serverWhitelist.etcdClient.Get(serverWhitelistKey)
for _, kv := range serverWhitelistResp.Kvs {
serverWhitelist.onWhitelistChange(clientv3.EventTypePut, string(kv.Key), string(kv.Value))
}
serverWhitelistWatchChan := serverWhitelist.etcdClient.Watch(serverWhitelistKey,
clientv3.WithRev(serverWhitelistResp.Header.Revision+1))
ready.Done()
for {
select {
case msg := <-serverFactoryWhitelistWatchChan:
for _, event := range msg.Events {
serverWhitelist.onFactoryWhitelistChange(event.Type, string(event.Kv.Key), string(event.Kv.Value))
}
case msg := <-serverWhitelistWatchChan:
for _, event := range msg.Events {
serverWhitelist.onWhitelistChange(event.Type, string(event.Kv.Key), string(event.Kv.Value))
}
case <-stopCtx.Done():
return
}
}
}(stopCtx)
return
}
func CloseWhitelist() {
if whiteListenStopFunc != nil {
whiteListenStopFunc()
whiteListenWg.Wait()
}
}
func GetServerWhitelist() *Whitelist {
return serverWhitelist
}
func (s *Whitelist) GetWhitelist() map[int64]struct{} {
s.mu.RLock()
defer s.mu.RUnlock()
return s.whitelist
}
func (s *Whitelist) SetWhitelist(whitelist []int64) {
white := make(map[string]interface{})
white[whitelistUsnList] = whitelist
whiteStr, err := json.Marshal(white)
if err != nil {
log.Errorf("server whitelist set failed: %v", err)
return
}
_, err = s.etcdClient.Put(serverWhitelistKey, string(whiteStr))
if err != nil {
log.Errorf("server whitelist set failed: %v", err)
return
}
}
func (s *Whitelist) CheckWhitelist(usn int64) bool {
s.mu.RLock()
defer s.mu.RUnlock()
_, ok := s.whitelist[usn]
return ok
}
func (s *Whitelist) GetFactoryWhitelist() map[int64]struct{} {
s.mu.RLock()
defer s.mu.RUnlock()
return s.factoryWhitelist
}
func (s *Whitelist) SetFactoryWhitelist(whitelist []int64) {
white := make(map[string]interface{})
white[whitelistUsnList] = whitelist
whiteStr, err := json.Marshal(white)
if err != nil {
log.Errorf("server factory whitelist set failed: %v", err)
return
}
_, err = s.etcdClient.Put(serverFactoryWhitelistKey, string(whiteStr))
if err != nil {
log.Errorf("server factory whitelist set failed: %v", err)
return
}
}
func (s *Whitelist) CheckFactoryWhitelist(usn int64) bool {
s.mu.RLock()
defer s.mu.RUnlock()
_, ok := s.factoryWhitelist[usn]
return ok
}
func (s *Whitelist) onFactoryWhitelistChange(t mvccpb.Event_EventType, key, value string) {
if key != serverFactoryWhitelistKey {
return
}
switch t {
case clientv3.EventTypePut:
s.mu.Lock()
defer s.mu.Unlock()
userSns := s.handlerWhitelistChange(value)
s.factoryWhitelist = make(map[int64]struct{})
for _, usn := range userSns {
s.factoryWhitelist[usn] = struct{}{}
}
}
}
func (s *Whitelist) onWhitelistChange(t mvccpb.Event_EventType, key, value string) {
if key != serverWhitelistKey {
return
}
switch t {
case clientv3.EventTypePut:
s.mu.Lock()
defer s.mu.Unlock()
userSns := s.handlerWhitelistChange(value)
s.whitelist = make(map[int64]struct{})
for _, usn := range userSns {
s.whitelist[usn] = struct{}{}
}
}
}
func (s *Whitelist) handlerWhitelistChange(value string) []int64 {
userSns := make([]int64, 0)
white := make(map[string]interface{})
if err := json.Unmarshal([]byte(value), &white); err != nil {
log.Errorf("server whitelist set failed: %v", err)
return userSns
}
if usnList, ok := white[whitelistUsnList].([]interface{}); ok {
for _, usn := range usnList {
userSns = append(userSns, int64(usn.(float64)))
}
}
return userSns
}

37
template/sms/lianlu.go Normal file
View File

@@ -0,0 +1,37 @@
package sms
//
//import "git.hlsq.asia/alex/proto/topic"
//
//type CountryCode string
//
//const (
// CountryCodeChina CountryCode = "+86" // 中国
// CountryCodeHongKong CountryCode = "+852" // 中国香港
// CountryCodeMacau CountryCode = "+853" // 中国澳门
// CountryCodeTaiwan CountryCode = "+886" // 中国台湾
// CountryCodeJapan CountryCode = "+81" // 日本
// CountryCodeSouthKorea CountryCode = "+82" // 韩国
//)
//
//const (
// TemplateCodeVerificationCodeChinese topic.SmsTemplateCode = "70630138" // 验证码(中文)
// TemplateCodeVerificationCodeEnglish topic.SmsTemplateCode = "54236" // 验证码(英文)
// TemplateCodeVerificationCodeJapanese topic.SmsTemplateCode = "54270" // 验证码(日文)
// TemplateCodeVerificationCodeKorean topic.SmsTemplateCode = "54271" // 验证码(韩文)
// TemplateCodeVerificationCodeChineseTraditional topic.SmsTemplateCode = "54272" // 验证码(繁体中文)
//)
//
//func GetTemplateCodeVerificationCodeByCountryCode(countryCode CountryCode) topic.SmsTemplateCode {
// switch countryCode {
// case CountryCodeChina:
// return TemplateCodeVerificationCodeChinese
// case CountryCodeHongKong, CountryCodeMacau, CountryCodeTaiwan:
// return TemplateCodeVerificationCodeChineseTraditional
// case CountryCodeJapan:
// return TemplateCodeVerificationCodeJapanese
// case CountryCodeSouthKorea:
// return TemplateCodeVerificationCodeKorean
// }
// return TemplateCodeVerificationCodeEnglish
//}

36
template/sms/zhongtian.go Normal file
View File

@@ -0,0 +1,36 @@
package sms
import "git.hlsq.asia/alex/proto/topic"
type CountryCode string
const (
CountryCodeChina CountryCode = "+86" // 中国
CountryCodeHongKong CountryCode = "+852" // 中国香港
CountryCodeMacau CountryCode = "+853" // 中国澳门
CountryCodeTaiwan CountryCode = "+886" // 中国台湾
CountryCodeJapan CountryCode = "+81" // 日本
CountryCodeSouthKorea CountryCode = "+82" // 韩国
)
const (
TemplateCodeVerificationCodeChinese topic.SmsTemplateCode = "【巢云互动】您的验证码是:%v,该验证码5分钟内有效,请勿泄漏于他人!" // 验证码(中文)
TemplateCodeVerificationCodeEnglish topic.SmsTemplateCode = "[NEXQUB] Your verification code is %v. It is valid for 5 minutes. Please do not share it with anyone." // 验证码(英文)
TemplateCodeVerificationCodeJapanese topic.SmsTemplateCode = "[NEXQUB] 認証コード:%v 有効期限5分。このコードを他人に教えないでください。" // 验证码(日文)
TemplateCodeVerificationCodeKorean topic.SmsTemplateCode = "[NEXQUB] 인증번호 %v 유효시간 5분. 타인과 공유하지 마세요." // 验证码(韩文)
TemplateCodeVerificationCodeChineseTraditional topic.SmsTemplateCode = "[NEXQUB] 您的驗證碼是:%v,5分鐘內有效,請勿向他人提供。" // 验证码(繁体中文)
)
func GetTemplateCodeVerificationCodeByCountryCode(countryCode CountryCode) topic.SmsTemplateCode {
switch countryCode {
case CountryCodeChina:
return TemplateCodeVerificationCodeChinese
case CountryCodeHongKong, CountryCodeMacau, CountryCodeTaiwan:
return TemplateCodeVerificationCodeChineseTraditional
case CountryCodeJapan:
return TemplateCodeVerificationCodeJapanese
case CountryCodeSouthKorea:
return TemplateCodeVerificationCodeKorean
}
return TemplateCodeVerificationCodeEnglish
}

13
utils/channel.go Normal file
View File

@@ -0,0 +1,13 @@
package utils
import (
"fmt"
"git.hlsq.asia/alex/proto/proto/ss/sspb"
"strings"
)
// GetChannelName 获得频道名称
func GetChannelName(t sspb.ChannelType, sn int64) string {
s := sspb.ChannelType_name[int32(t)]
return fmt.Sprintf("%v-%v", strings.TrimPrefix(s, "CHANNEL_TYPE_"), sn)
}

72
utils/error.go Normal file
View File

@@ -0,0 +1,72 @@
package utils
import (
"errors"
"fmt"
"runtime"
"strconv"
"strings"
)
type WrapErrors struct {
original error
message string
trace []string
}
func (e *WrapErrors) Original() error {
return e.original
}
func (e *WrapErrors) Error() string {
return e.message
}
func (e *WrapErrors) StackTrace() string {
if e.trace == nil {
return ""
}
return strings.Join(e.trace, "\n")
}
func ErrorsWrap(err error, message ...string) error {
if err == nil {
return nil
}
var e *WrapErrors
if !errors.As(err, &e) {
e = &WrapErrors{
original: err,
}
}
if len(message) > 0 {
e.message = fmt.Sprintf("%v: %v", message[0], err.Error())
} else {
e.message = err.Error()
}
e.trace = append(e.trace, getErrorPath())
return e
}
func ErrorsWrapF(err error, message string, a ...any) error {
if err == nil {
return nil
}
var e *WrapErrors
if !errors.As(err, &e) {
e = &WrapErrors{
original: err,
}
}
e.message = fmt.Sprintf("%v: %v", fmt.Sprintf(message, a...), err.Error())
e.trace = append(e.trace, getErrorPath())
return e
}
func getErrorPath() string {
_, file, line, _ := runtime.Caller(2)
if file == "" {
return "unknown"
}
return file + ":" + strconv.Itoa(line)
}

View File

@@ -1,11 +1,8 @@
package utils package utils
import ( import (
"context"
"errors" "errors"
"github.com/golang-jwt/jwt/v5" "github.com/golang-jwt/jwt/v5"
"google.golang.org/grpc/metadata"
"strconv"
"time" "time"
) )
@@ -41,16 +38,34 @@ func ParseToken(tokenString string, secret string) (*Claims, error) {
return claims, nil return claims, nil
} }
func ShouldBindUsn(ctx context.Context, usn *int64) bool { type PhoneClaims struct {
if md, ok := metadata.FromIncomingContext(ctx); ok { Phone string `json:"phone"`
usnArr := md.Get("X-Usn") jwt.RegisteredClaims
if len(usnArr) == 0 || usnArr[0] == "" {
return false
} }
s, _ := strconv.Atoi(usnArr[0])
if s > 0 { func GenPhoneToken(phone string, secret string, expires time.Duration) (string, error) {
*usn = int64(s) token := jwt.NewWithClaims(jwt.SigningMethodHS256, PhoneClaims{
Phone: phone,
RegisteredClaims: jwt.RegisteredClaims{
ExpiresAt: jwt.NewNumericDate(time.Now().Add(expires)),
},
})
return token.SignedString([]byte(secret))
} }
func ParsePhoneToken(tokenString string, secret string) (*PhoneClaims, error) {
if tokenString == "" {
return nil, errors.New("invalid token")
} }
return *usn > 0 claims := &PhoneClaims{}
token, err := jwt.ParseWithClaims(tokenString, claims, func(_ *jwt.Token) (interface{}, error) {
return []byte(secret), nil
})
if err != nil {
return nil, err
}
if !token.Valid {
return nil, errors.New("invalid token")
}
return claims, nil
} }

82
utils/locator/locator.go Normal file
View File

@@ -0,0 +1,82 @@
package locator
import (
"context"
"fmt"
"git.hlsq.asia/alex/service-common/db/redis"
"git.hlsq.asia/alex/service-common/log"
)
// 玩家定位器
const (
KeyGatewayInfo = "gateway:info:%v"
HFieldInfoGatewaySID = "gateway_sid_%v"
)
var (
scriptBindGatewaySha1 string
scriptBindGateway = `
local gateway_key = KEYS[1]
local field_key = ARGV[1]
local new_sid = ARGV[2]
local existing_sid = redis.call("HGET", gateway_key, field_key)
if existing_sid then
return 0
end
redis.call("HSET", gateway_key, field_key, new_sid)
return 1
`
)
func NewLocator(ctx context.Context, usn int64, platform int32) *Locator {
return &Locator{
ctx: ctx,
usn: usn,
platform: platform,
}
}
type Locator struct {
ctx context.Context
usn int64
platform int32
}
// BindGateway 绑定网关
func (l *Locator) BindGateway(gatewaySID int64) bool {
if scriptBindGatewaySha1 == "" {
scriptBindGatewaySha1 = redis.GetClient().ScriptLoad(l.ctx, scriptBindGateway).Val()
}
result, err := redis.GetClient().EvalSha(
l.ctx,
scriptBindGatewaySha1,
[]string{fmt.Sprintf(KeyGatewayInfo, l.usn)},
fmt.Sprintf(HFieldInfoGatewaySID, l.platform),
gatewaySID,
).Int64()
if err != nil {
return false
}
if result == 0 {
return false
}
return true
}
// UnbindGateway 解绑网关
func (l *Locator) UnbindGateway() {
err := redis.GetClient().HDel(l.ctx, fmt.Sprintf(KeyGatewayInfo, l.usn), fmt.Sprintf(HFieldInfoGatewaySID, l.platform)).Err()
if err != nil {
log.Errorf("UnbindGateway Failed %v-%v, err: %v", l.usn, l.platform, err)
}
}
// LocateGateway 定位网关
func (l *Locator) LocateGateway() int64 {
sid, _ := redis.GetClient().HGet(l.ctx, fmt.Sprintf(KeyGatewayInfo, l.usn), fmt.Sprintf(HFieldInfoGatewaySID, l.platform)).Int64()
return sid
}

View File

@@ -1,6 +1,7 @@
package utils package utils
import ( import (
"github.com/shopspring/decimal"
"math/rand" "math/rand"
"strconv" "strconv"
) )
@@ -21,3 +22,91 @@ func StringToInt64(s string) int64 {
} }
return i return i
} }
// Int64ToString converts int64 to string
func Int64ToString(i int64) string {
return strconv.FormatInt(i, 10)
}
// AddFloat64 对浮点数求和
func AddFloat64(places int32, number ...float64) float64 {
if len(number) == 0 {
return 0
}
result := decimal.NewFromFloat(0)
for _, n := range number {
result = result.Add(decimal.NewFromFloat(n))
}
return result.Round(places).InexactFloat64()
}
// SubFloat64 对浮点数求差
func SubFloat64(places int32, number ...float64) float64 {
if len(number) == 0 {
return 0
}
result := decimal.NewFromFloat(number[0])
for i := 1; i < len(number); i++ {
result = result.Sub(decimal.NewFromFloat(number[i]))
}
return result.Round(places).InexactFloat64()
}
// MulFloat64 对浮点数求积
func MulFloat64(places int32, number ...float64) float64 {
if len(number) == 0 {
return 0
}
result := decimal.NewFromFloat(1)
for _, n := range number {
result = result.Mul(decimal.NewFromFloat(n))
}
return result.Round(places).InexactFloat64()
}
// DivFloat64 对浮点数求商
func DivFloat64(places int32, number ...float64) float64 {
if len(number) == 0 {
return 0
}
result := decimal.NewFromFloat(number[0])
for i := 1; i < len(number); i++ {
if number[i] == 0 {
return 0 // 避免除以零
}
result = result.Div(decimal.NewFromFloat(number[i]))
}
return result.Round(places).InexactFloat64()
}
// MaxInt32 返回两个 int32 中的较大值
func MaxInt32(a, b int32) int32 {
if a > b {
return a
}
return b
}
// MinInt32 返回两个 int32 中的较小值
func MinInt32(a, b int32) int32 {
if a < b {
return a
}
return b
}
// MaxFloat64 返回两个 float64 中的较大值
func MaxFloat64(a, b float64) float64 {
if a > b {
return a
}
return b
}
// MinFloat64 返回两个 float64 中的较小值
func MinFloat64(a, b float64) float64 {
if a < b {
return a
}
return b
}

62
utils/page.go Normal file
View File

@@ -0,0 +1,62 @@
package utils
import (
"math"
"git.hlsq.asia/alex/proto/proto/rs/rscommon"
"gorm.io/gen/field"
)
func PageGetOffSet(page *rscommon.PageArgs) int {
if page == nil || page.PageSize <= 0 {
return 0
}
return int((page.PageIndex - 1) * page.PageSize)
}
func CalcTotalPage(totalCount, pageSize int32) int32 {
if pageSize <= 0 {
return 0
}
return int32(math.Ceil(float64(totalCount) / float64(pageSize)))
}
func BuildPageInfoReply(page *rscommon.PageArgs, totalCount int32) *rscommon.PageInfoReply {
if page == nil {
page = &rscommon.PageArgs{PageIndex: 1, PageSize: 10}
}
if page.PageSize <= 0 {
page.PageSize = 10
}
if page.PageIndex <= 0 {
page.PageIndex = 1
}
if totalCount <= 0 {
totalCount = 0
return &rscommon.PageInfoReply{
PageIndex: page.PageIndex,
PageSize: page.PageSize,
TotalCount: totalCount,
}
}
return &rscommon.PageInfoReply{
PageIndex: page.PageIndex,
PageSize: page.PageSize,
TotalCount: totalCount,
}
}
func GetOrderInfo(orderList []*rscommon.OrderInfo, getField func(field string) field.OrderExpr) []field.Expr {
orders := make([]field.Expr, 0, len(orderList))
for _, order := range orderList {
expr := getField(order.Field)
if expr != nil {
if order.Asc {
orders = append(orders, expr.Asc())
} else {
orders = append(orders, expr.Desc())
}
}
}
return orders
}

33
utils/pool_object.go Normal file
View File

@@ -0,0 +1,33 @@
package utils
import (
"sync"
)
type ObjectPool[T any] struct {
pool sync.Pool
}
func NewObjectPool[T any]() *ObjectPool[T] {
return &ObjectPool[T]{
pool: sync.Pool{
New: func() any {
return new(T)
},
},
}
}
func (p *ObjectPool[T]) Get() *T {
return p.pool.Get().(*T)
}
func (p *ObjectPool[T]) Put(obj *T) {
*obj = zero[T]()
p.pool.Put(obj)
}
func zero[T any]() T {
var z T
return z
}

View File

@@ -1,6 +1,7 @@
package utils package utils
import ( import (
"git.hlsq.asia/alex/service-common/log"
"sync" "sync"
) )
@@ -27,6 +28,11 @@ func WorkerPool(tasks []interface{}, taskFunc func(interface{}), maxWorkers ...i
wg.Add(1) wg.Add(1)
go func() { go func() {
defer wg.Done() defer wg.Done()
defer func() {
if e := recover(); e != nil {
log.Errorf("WorkerPool panic: %v", e)
}
}()
for task := range jobs { for task := range jobs {
taskFunc(task) taskFunc(task)
} }

19
utils/qr.go Normal file
View File

@@ -0,0 +1,19 @@
package utils
import (
"encoding/base64"
"github.com/skip2/go-qrcode"
)
func GetQRCodeIO(content string, size ...int) string {
s := 260 // 写死尺寸 260*260
if len(size) > 0 {
s = size[0]
}
png, err := qrcode.Encode(content, qrcode.High, s)
if err != nil {
return ""
}
return "data:image/png;base64," + base64.StdEncoding.EncodeToString(png)
}

59
utils/replay.go Normal file
View File

@@ -0,0 +1,59 @@
package utils
import (
"context"
"fmt"
"git.hlsq.asia/alex/service-common/db/redis"
"git.hlsq.asia/alex/service-common/net/http/httpresp"
"google.golang.org/grpc/metadata"
"time"
)
const (
replayTTL = 2 * time.Minute // 防重放缓存有效期
lockTTL = 10 * time.Second // 分布式锁有效期
)
// WrapPreventReplay 防止重放请求
func WrapPreventReplay[T any](ctx context.Context, usn int64, fun func() (T, error)) (T, error) {
var zero T
key := ""
if md, ok := metadata.FromIncomingContext(ctx); ok {
ridArr := md.Get("Request-Id")
if len(ridArr) == 0 || ridArr[0] == "" {
return fun()
}
key = fmt.Sprintf("cache:replay:%v:%v", usn, ridArr[0])
} else {
return fun()
}
// 先查缓存,命中直接返回
if val := getReplayCache[T](ctx, key); val != nil {
return *val, nil
}
// 尝试抢分布式锁,抢到就执行,没抢到报错
lockKey := fmt.Sprintf("%s:lock", key)
locked, err := redis.GetClient().SetNX(ctx, lockKey, "1", lockTTL).Result()
if err == nil && locked {
defer redis.GetClient().Del(ctx, lockKey)
result, err := fun()
// 这里报错了是没有缓存的
if err != nil {
return zero, err
}
redis.GetCacheClient().Set(ctx, key, result, replayTTL)
return result, nil
}
return zero, httpresp.RequestTooFast
}
// getReplayCache 从 Redis 读取重放缓存
func getReplayCache[T any](ctx context.Context, key string) *T {
var dst T
if redis.GetCacheClient().Get(ctx, key, &dst) {
return &dst
}
return nil
}

69
utils/session.go Normal file
View File

@@ -0,0 +1,69 @@
package utils
import (
"context"
"google.golang.org/grpc/metadata"
"strconv"
"strings"
)
type UserSession struct {
USN int64 `json:"usn" redis:"usn"`
IP string `json:"ip" redis:"ip"`
UserAgent string `json:"ua" redis:"ua"`
AccessToken string `json:"at" redis:"at"`
RefreshToken string `json:"rt" redis:"rt"`
}
func (us *UserSession) GetUsnKey() string {
return "usn"
}
func (us *UserSession) GetAccessTokenKey() string {
return "at"
}
func (us *UserSession) GetRefreshTokenKey() string {
return "rt"
}
// Deprecated: 请使用 ShouldGetUsn 替代,示例:
// usn := utils.ShouldGetUsn(ctx)
// 不需要判断 usn 是否为 0,只有不鉴权接口的 usn 才可能是 0。
func ShouldBindUsn(ctx context.Context, usn *int64) bool {
if md, ok := metadata.FromIncomingContext(ctx); ok {
usnArr := md.Get("X-Usn")
if len(usnArr) == 0 || usnArr[0] == "" {
return false
}
*usn = StringToInt64(usnArr[0])
}
return *usn != 0
}
func ShouldGetUsn(ctx context.Context) int64 {
if md, ok := metadata.FromIncomingContext(ctx); ok {
usnArr := md.Get("X-Usn")
if len(usnArr) == 0 || usnArr[0] == "" {
return 0
}
return StringToInt64(usnArr[0])
}
return 0
}
func GetPlatformAndUsn(token string) (int32, int64, bool) {
str := strings.Split(token, ":")
if len(str) != 3 {
return 0, 0, false
}
platform, err := strconv.Atoi(str[0])
if err != nil {
return 0, 0, false
}
usn, err := strconv.Atoi(str[1])
if err != nil {
return 0, 0, false
}
return int32(platform), int64(usn), true
}

View File

@@ -1,14 +1,19 @@
package utils package utils
import ( import (
"github.com/bwmarrin/snowflake" "github.com/sony/sonyflake/v2"
"log" "log"
) )
var instance *snowflake.Node var instance *sonyflake.Sonyflake
func InitSnowflake(node int64) *snowflake.Node { func InitSnowflake(node int64) *sonyflake.Sonyflake {
n, err := snowflake.NewNode(node) n, err := sonyflake.New(sonyflake.Settings{
BitsMachineID: 10,
MachineID: func() (int, error) {
return int(node), nil
},
})
if err != nil { if err != nil {
log.Fatalf("create snowflake's node failed: %v", err) log.Fatalf("create snowflake's node failed: %v", err)
} }
@@ -16,9 +21,10 @@ func InitSnowflake(node int64) *snowflake.Node {
return instance return instance
} }
func SnowflakeInstance() *snowflake.Node { func SnowflakeInt64() int64 {
if instance == nil { if instance == nil {
log.Fatal("snowflake's not init") log.Fatal("snowflake's not init")
} }
return instance id, _ := instance.NextID()
return id
} }

49
utils/string.go Normal file
View File

@@ -0,0 +1,49 @@
package utils
import (
"crypto/md5"
"encoding/hex"
"math/rand"
)
// GetMD5Encode 获取Md5编码
func GetMD5Encode(data string) string {
h := md5.New()
h.Write([]byte(data))
return hex.EncodeToString(h.Sum(nil))
}
const (
StringChars1 = "0123456789"
StringChars2 = "abcdefghijklmnopqrstuvwxyz"
StringChars3 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
StringChars4 = "0123456789abcdefghijklmnopqrstuvwxyz"
StringChars5 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
StringChars6 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
StringChars7 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
)
// RandomString 获取随机字符串
func RandomString(chars string, length int8) string {
result := make([]byte, length)
for i := int8(0); i < length; i++ {
result[i] = chars[rand.Intn(len(chars))]
if i == 0 && result[i] == '0' {
i--
}
}
return string(result)
}
// GetDisplayWidth 获取字符串长度
func GetDisplayWidth(text string) int {
width := 0
for _, r := range text {
if r <= 0x7F {
width += 1 // ASCII,半角
} else {
width += 2 // CJK、日文假名等,全角
}
}
return width
}

34
utils/test.go Normal file
View File

@@ -0,0 +1,34 @@
package utils
import (
"bytes"
"encoding/json"
"git.hlsq.asia/alex/service-common/net/http/httpresp"
"github.com/gin-gonic/gin"
"github.com/stretchr/testify/suite"
"net/http/httptest"
)
// 给测试用例提供一些通用函数
// CreateTestContext 创建测试用例的上下文
func CreateTestContext(method, path string, body interface{}) (*httptest.ResponseRecorder, *gin.Context) {
w := httptest.NewRecorder()
c, _ := gin.CreateTestContext(w)
var buf bytes.Buffer
if body != nil {
_ = json.NewEncoder(&buf).Encode(body)
}
req := httptest.NewRequest(method, path, &buf)
req.Header.Set("Content-Type", "application/json")
c.Request = req
return w, c
}
// AssertResponse 断言返回值
func AssertResponse(ts *suite.Suite, w *httptest.ResponseRecorder, httpCode int, code *httpresp.Code) {
ts.Assert().Equal(httpCode, w.Code)
var response map[string]interface{}
ts.Assert().NoError(json.Unmarshal(w.Body.Bytes(), &response))
ts.Assert().Equal(float64(code.Code()), response["code"])
}

26
utils/time.go Normal file
View File

@@ -0,0 +1,26 @@
package utils
import (
"math"
"time"
)
// CalcDaysDiff 计算两个日期相差多少天
func CalcDaysDiff(one, two time.Time) int32 {
oneZero := time.Date(
one.Year(),
one.Month(),
one.Day(),
0, 0, 0, 0,
time.Local,
)
twoZero := time.Date(
two.Year(),
two.Month(),
two.Day(),
0, 0, 0, 0,
time.Local,
)
// 计算相差天数
return int32(math.Abs(oneZero.Sub(twoZero).Hours() / 24))
}