Compare commits

...

58 Commits

Author SHA1 Message Date
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
3ea3a3ac6d feat 初次提交 2026-01-03 14:26:09 +08:00
18eb946934 .gitignore 2026-01-03 14:17:26 +08:00
73 changed files with 11077 additions and 1 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
.idea
*/.idea

193
README.md
View File

@@ -1,3 +1,194 @@
# common
公共代码集合
公共代码集合
---
## ✅ 微服务十大核心原则(实战导向)
> 这些不是理论教条,而是无数团队踩坑后总结出的“生存法则”。
---
### 1. **单一职责 & 高内聚Single Responsibility**
- 每个微服务应围绕 **一个明确的业务能力**(如“用户管理”、“支付”、“通知”)。
- ❌ 不要按技术分层拆服务(如“所有 DB 服务”、“所有 API 服务”)。
- ✅ 建议用 **DDD领域驱动设计** 划分限界上下文Bounded Context
> 📌 口诀:**“一个服务,一个事”**
---
### 2. **自治性Autonomy**
- 服务应能 **独立开发、测试、部署、扩展、故障恢复**
- 依赖越少越好;跨服务调用必须有 **降级、熔断、超时** 机制。
- 使用 **契约测试Contract Testing** 保证接口兼容(如 Pact
> 🔧 工具推荐:
> - gRPC + Protobuf强契约
> - OpenAPIREST
> - WireMock / Pact契约测试
---
### 3. **数据私有Database per Service** ← 你已掌握!
- 每个服务独占数据存储,**禁止跨服务直连数据库**。
- 跨服务数据交互靠:
- **同步**APIgRPC/HTTP
- **异步**事件Kafka / RabbitMQ / Pulsar
> 💡 技巧:用 **事件溯源Event Sourcing + CQRS** 构建复杂查询视图。
---
### 4. **无状态Stateless**
- 服务实例本身不保存会话或状态(状态存 Redis / DB / Cookie
- 好处:**水平扩展容易**K8s 可随意扩缩容。
> ⚠️ 例外:批处理、流计算等有状态场景可用 StatefulSet但要谨慎。
---
### 5. **可观测性Observability三件套**
微服务没有可观测性 = 盲人开车!
| 组件 | 作用 | 工具推荐 |
|------|------|--------|
| **Logging** | 记录结构化日志 | Zap / Logrus + Loki / ELK |
| **Metrics** | 监控性能指标 | Prometheus + Grafana |
| Assistant | 追踪请求链路 | Jaeger / Zipkin / OpenTelemetry |
> ✅ 必做:
> - 所有日志带 `trace_id`
> - 所有 gRPC 调用自动埋点
> - 关键路径加自定义指标(如“登录成功率”)
---
### 6. **弹性设计Resilience**
网络不可靠!必须假设:
- 其他服务会宕机
- 网络会延迟或丢包
✅ 必备机制:
- **超时Timeout**:每个调用设上限(如 1s
- **重试Retry**:带退避策略(指数退避)
- **熔断Circuit Breaker**:失败太多就短路(如 Hystrix / Sentinel
- **限流Rate Limiting**:保护自己不被压垮
- **降级Fallback**:返回默认值或缓存数据
> 🛠 Go 推荐库:
> - `go-resiliency`
> - `sony/gobreaker`
> - 自研中间件(结合 context + retry
---
### 7. **API 优先API-First Design**
- 先定义 `.proto`gRPC或 OpenAPIREST再写代码。
- 客户端 SDK 自动生成(如 `protoc-gen-go`)。
- 版本管理:**向后兼容优先**,避免频繁改接口。
> 📁 目录建议:
> ```
> api/
> ├── user/v1/user.proto
> └── order/v1/order.proto
> ```
---
### 8. **基础设施即代码IaC & GitOps**
- 数据库、K8s、网关配置全部代码化Terraform / Helm / Kustomize
- 所有变更通过 Git PR 触发自动化部署。
- 环境一致性dev / staging / prod 配置几乎相同。
> ✅ 好处:**“一键重建整个环境”**
---
### 9. **安全内建Security by Default**
- **mTLS**服务间通信加密Istio / Linkerd
- **RBAC**:基于角色的访问控制
- **敏感信息**:用 Vault / K8s Secret 管理,不硬编码
- **输入校验**:所有 API 参数严格验证(如 `validator.v10`
> 🔒 原则:**“零信任网络”** —— 不信任任何内部流量。
---
### 10. **演进式设计Evolutionary Architecture**
- 不追求“一次性完美架构”
-**Strangler Fig Pattern绞杀者模式** 逐步替换旧系统
- 定期做 **架构重构****技术债清理**
> 🌱 微服务是“种出来的”,不是“画出来的”。
---
## 🧱 推荐架构分层Go 微服务)
```
user-service/
├── api/ # .proto 文件(对外契约)
├── cmd/ # main 入口
├── internal/
│ ├── handler/ # gRPC/HTTP handlers薄层
│ ├── service/ # 业务逻辑(核心)
│ ├── repository/ # 数据访问(接口 + mysql 实现)
│ └── model/ # 领域模型(与 DB 解耦)
├── pkg/ # 可共享工具(谨慎!)
├── deploy/ # K8s / Docker 配置
└── go.mod
```
> 🔑 关键:`internal/` 禁止被外部 import强制通过 API 交互。
---
## 🚫 微服务常见反模式(务必避开!)
| 反模式 | 后果 |
|-------|------|
| 分布式单体 | 失去微服务所有优势 |
| 共享数据库 | 强耦合,无法独立演进 |
| 同步调用链过长A→B→C→D | 故障放大,雪崩风险 |
| 无监控无告警 | 出问题找不到原因 |
| 手动部署 | 发布慢,易出错 |
---
## ✅ 最后建议:从小做起,逐步完善
1. **先保证“能跑”**:一个服务 + 独立 DB + gRPC API
2. **加上可观测性**:日志 + Metrics + Tracing
3. **加上弹性机制**:超时 + 重试
4. **加上 CI/CD**:自动化测试 & 部署
5. **再考虑事件驱动、CQRS、Service Mesh...**
> 🌟 **好的微服务架构不是设计出来的,而是在约束和实践中演化出来的。**
---
# 增加服务器步骤
代码
1. go module 命名:`git.hlsq.asia/mmorpg/service-${服务名}`
2. `deploy、config` 修改
common
1.`discover\common\define.go` 定义服务发现
2.`net\grpc\service` 实现客户端发现
public
1.`Proto\RpcServer\sources` 定义gRPC服务
db
1. 创建独立db命名为`${服务名}_db`
quickly
1. `MySQL Model` 增加数据库配置
2. `更新Common` 增加项目配置
gateway
1. 在 `internal\net\http_gateway\router.go` 定义路由

78
config/config.go Normal file
View File

@@ -0,0 +1,78 @@
package config
type AppConfig struct {
Name string `yaml:"name"`
}
type LogConfig struct {
Debug bool `yaml:"debug"`
MaxSize int32 `yaml:"maxSize"`
MaxBackups int32 `yaml:"maxBackups"`
MaxAge int32 `yaml:"maxAge"`
Level string `yaml:"level"`
}
type MetricConfig struct {
Prometheus *struct {
Address string `yaml:"address"`
Port int32 `yaml:"port"`
} `yaml:"prometheus"`
Jaeger *struct {
Endpoint string `yaml:"endpoint"`
} `yaml:"jaeger"`
}
type DBConfig struct {
Etcd *EtcdConfig `yaml:"etcd"`
MySQL map[string]*MySQLConfig `yaml:"mysql"`
Mongo map[string]*MongoConfig `yaml:"mongo"`
Redis *RedisConfig `yaml:"redis"`
Kafka *KafkaConfig `yaml:"kafka"`
}
type EtcdConfig struct {
Endpoints []string `yaml:"endpoints"`
}
type MySQLConfig struct {
Dsn string `yaml:"dsn"`
MaxOpenConn int32 `yaml:"maxOpenConn"`
MaxIdleConn int32 `yaml:"maxIdleConn"`
ConnMaxLifetimeSec int32 `yaml:"connMaxLifetimeSec"`
ConnMaxIdleTimeSec int32 `yaml:"connMaxIdleTimeSec"`
LogLevel string `yaml:"logLevel"`
}
type MongoConfig struct {
URI string `yaml:"uri"`
}
type RedisConfig struct {
Addr string `yaml:"addr"`
Password string `yaml:"password"`
DB int `yaml:"db"`
}
type KafkaConfig struct {
Brokers []string `yaml:"brokers"`
}
type ServeConfig struct {
Grpc *GrpcConfig `yaml:"grpc"`
Socket *struct {
Web *AddressConfig `yaml:"web"`
Raw *AddressConfig `yaml:"raw"`
} `yaml:"socket"`
Http *AddressConfig `yaml:"http"`
}
type GrpcConfig struct {
Address string `yaml:"address"`
Port int32 `yaml:"port"`
TTL int64 `yaml:"ttl"`
}
type AddressConfig struct {
Address string `yaml:"address"`
Port int32 `yaml:"port"`
}

42
config/loader.go Normal file
View File

@@ -0,0 +1,42 @@
package config
import (
"encoding/json"
"fmt"
"github.com/spf13/viper"
"strings"
)
const (
envConfigPrefix = "XH_G"
)
// LoadConfig 加载并返回应用配置
func LoadConfig[T any](configDir string, configPtr *T) (*T, error) {
v := viper.New()
v.SetEnvPrefix(envConfigPrefix)
v.AutomaticEnv()
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
env := v.GetString("env")
if env == "" {
env = "dev"
}
v.SetConfigName(fmt.Sprintf("config.%s", strings.ToLower(env)))
v.AddConfigPath(configDir)
v.SetConfigType("yaml")
if err := v.ReadInConfig(); err != nil {
return nil, fmt.Errorf("failed to read config: %w", err)
}
if err := v.Unmarshal(&configPtr); err != nil {
return nil, fmt.Errorf("failed to unmarshal config: %w", err)
}
marshal, _ := json.Marshal(configPtr)
fmt.Printf("Configuration loading completed: %v\n", string(marshal))
return configPtr, nil
}

80
db/etcd/client.go Normal file
View File

@@ -0,0 +1,80 @@
package etcd
import (
"context"
"git.hlsq.asia/mmorpg/service-common/config"
"go.etcd.io/etcd/client/v3"
"time"
)
var instance *Client
type Client struct {
cli *clientv3.Client
}
// Init 初始化
func Init(cfg *config.EtcdConfig) error {
client, err := clientv3.New(clientv3.Config{
Endpoints: cfg.Endpoints,
DialTimeout: 5 * time.Second,
})
instance = &Client{
cli: client,
}
return err
}
// Close 关闭
func Close() error {
if instance != nil && instance.cli != nil {
return instance.cli.Close()
}
return nil
}
func GetClient() *Client {
return instance
}
func (c *Client) Raw() *clientv3.Client {
return c.cli
}
// Get 获取数据
func (c *Client) Get(key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error) {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
return c.cli.Get(ctx, key, opts...)
}
// Put 创建数据
func (c *Client) Put(key, val string, opts ...clientv3.OpOption) (*clientv3.PutResponse, error) {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
return c.cli.Put(ctx, key, val, opts...)
}
// Grant 创建租约
func (c *Client) Grant(ttl int64) (*clientv3.LeaseGrantResponse, error) {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
return c.cli.Grant(ctx, ttl)
}
// KeepAlive 保活租约
func (c *Client) KeepAlive(id clientv3.LeaseID) (<-chan *clientv3.LeaseKeepAliveResponse, error) {
return c.cli.KeepAlive(context.Background(), id)
}
// Revoke 撤销租约
func (c *Client) Revoke(id clientv3.LeaseID) (*clientv3.LeaseRevokeResponse, error) {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
return c.cli.Revoke(ctx, id)
}
// Watch 监听数据
func (c *Client) Watch(key string, opts ...clientv3.OpOption) clientv3.WatchChan {
return c.cli.Watch(context.Background(), key, opts...)
}

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/mmorpg/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 = false
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
}

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

@@ -0,0 +1,109 @@
package kafka
import (
"context"
"encoding/json"
"errors"
"fmt"
"git.hlsq.asia/mmorpg/service-common/log"
"git.hlsq.asia/mmorpg/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"
"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]Topic)
for _, v := range t {
topicArr = append(topicArr, v.Name())
handlerMap[v.Name()] = v
}
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 nil
}
type Handler func(context.Context, []byte) error
type handler struct {
handler map[string]Topic
}
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 message := range claim.Messages() {
ctx := NewCarrier().ExtractConsumer(message.Headers)
_, span := otel.Tracer("common.db.kafka").Start(ctx, "kafka.consume")
cb := h.handler[message.Topic]
if cb == nil {
span.SetStatus(otelcodes.Error, "handler not found")
span.End()
return utils.ErrorsWrap(errors.New("handler not found"))
}
if err := json.Unmarshal(message.Value, cb); err != nil {
span.SetStatus(otelcodes.Error, "handler json.Unmarshal error")
span.End()
return utils.ErrorsWrap(err, "handler json.Unmarshal error")
}
if err := cb.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()
return utils.ErrorsWrap(err, "kafka handler error")
}
sess.MarkMessage(message, "")
span.End()
}
sess.Commit()
return nil
}
func consumerError() {
for err := range client.consumer.Errors() {
log.Errorf("kafka consumer error: %v", err)
}
}

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

@@ -0,0 +1,35 @@
package kafka
import (
"context"
"encoding/json"
"github.com/IBM/sarama"
"go.opentelemetry.io/otel"
otelcodes "go.opentelemetry.io/otel/codes"
)
func NewProducer() *Producer {
return &Producer{}
}
type Producer struct {
}
func (c *Producer) Produce(ctx context.Context, data Topic) {
marshal, _ := json.Marshal(data)
msg := &sarama.ProducerMessage{
Topic: data.Name(),
Value: sarama.ByteEncoder(marshal),
Headers: NewCarrier().Inject(ctx),
}
client.producer.Input() <- msg
}
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
}

70
db/mongo/client.go Normal file
View File

@@ -0,0 +1,70 @@
package mongo
import (
"context"
"git.hlsq.asia/mmorpg/service-common/config"
"git.hlsq.asia/mmorpg/service-common/log"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
type DBName string
var clients = make(map[DBName]*mongo.Client)
func Init(cfg map[string]*config.MongoConfig) error {
for name, oneConfig := range cfg {
if client, err := initOneClient(oneConfig); err != nil {
return err
} else {
clients[DBName(name)] = client
}
}
return nil
}
func initOneClient(cfg *config.MongoConfig) (*mongo.Client, error) {
opts := options.Client().
ApplyURI(cfg.URI)
client, err := mongo.Connect(context.Background(), opts)
if err != nil {
return nil, err
}
return client, nil
}
// GetClient 返回 mongo.Client你可以通过 .Database("xxx") 获取具体数据库
func GetClient(dbName DBName) *mongo.Client {
if c, ok := clients[dbName]; ok {
return c
}
log.Errorf("mongo client %s not found", dbName)
return nil
}
// GetDB 是便捷方法,直接返回 *mongo.Database假设 dbName 对应数据库名)
// 如果你的配置中 dbName 和实际数据库名一致,可这样用
func GetDB(dbName DBName) *mongo.Database {
client := GetClient(dbName)
if client == nil {
return nil
}
// 假设配置中的 key 就是数据库名;若需分离,可在 config 中加字段
return client.Database(string(dbName))
}
func Close() error {
if clients == nil {
return nil
}
for name, client := range clients {
if client != nil {
if err := client.Disconnect(context.Background()); err != nil {
log.Errorf("close mongo client %s error: %v", name, err)
}
}
}
return nil
}

85
db/mysql/client.go Normal file
View File

@@ -0,0 +1,85 @@
package mysql
import (
"git.hlsq.asia/mmorpg/service-common/config"
"git.hlsq.asia/mmorpg/service-common/log"
"gorm.io/driver/mysql"
"gorm.io/gorm"
"gorm.io/gorm/logger"
"time"
)
type DBName string
var dbs = make(map[DBName]*gorm.DB)
func Init(cfg map[string]*config.MySQLConfig) error {
for name, oneConfig := range cfg {
if db, err := initOneDB(oneConfig); err != nil {
return err
} else {
dbs[DBName(name)] = db
}
}
return nil
}
func initOneDB(cfg *config.MySQLConfig) (*gorm.DB, error) {
db, err := gorm.Open(
mysql.Open(cfg.Dsn),
&gorm.Config{
TranslateError: true,
Logger: logger.Default.LogMode(parseLogLevel(cfg.LogLevel)),
},
)
if err != nil {
return nil, err
}
sqlDB, err := db.DB()
if err != nil {
return nil, err
}
sqlDB.SetMaxOpenConns(int(cfg.MaxOpenConn))
sqlDB.SetMaxIdleConns(int(cfg.MaxIdleConn))
sqlDB.SetConnMaxLifetime(time.Duration(cfg.ConnMaxLifetimeSec) * time.Second)
sqlDB.SetConnMaxIdleTime(time.Duration(cfg.ConnMaxIdleTimeSec) * time.Second)
return db, nil
}
func parseLogLevel(logLevel string) logger.LogLevel {
switch logLevel {
case "silent":
return logger.Silent
case "error":
return logger.Error
case "warn":
return logger.Warn
case "info":
return logger.Info
}
return logger.Info
}
func GetDB(dbName DBName) *gorm.DB {
if q, ok := dbs[dbName]; ok {
return q
}
log.Errorf("db %s not found", dbName)
return nil
}
func Close() error {
if dbs == nil {
return nil
}
for name, db := range dbs {
if sqlDB, _ := db.DB(); sqlDB != nil {
if err := sqlDB.Close(); err != nil {
log.Errorf("close db %s error: %v", name, err)
}
}
}
return nil
}

50
db/redis/cache_client.go Normal file
View File

@@ -0,0 +1,50 @@
package redis
import (
"context"
"encoding/json"
"github.com/panjf2000/gnet/v2/pkg/logging"
"github.com/redis/go-redis/v9"
"time"
)
var cacheInstance *CacheClient
type CacheClient struct {
cli *redis.Client
logger logging.Logger
}
func GetCacheClient() *CacheClient {
return cacheInstance
}
func (c *CacheClient) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) {
bytes, err := json.Marshal(value)
if err != nil {
c.logger.Errorf("Set json.Marshal error: %v, key: %v, value: %v", err, key, value)
return
}
if err = c.cli.Set(ctx, key, bytes, expiration).Err(); err != nil {
c.logger.Errorf("Set redis.Set error: %v, key: %v, value: %v", err, key, value)
}
}
func (c *CacheClient) Del(ctx context.Context, keys ...string) {
if err := c.cli.Del(ctx, keys...).Err(); err != nil {
c.logger.Errorf("Set redis.Del error: %v, keys: %v", err, keys)
}
}
// Get 获取数据
func (c *CacheClient) Get(ctx context.Context, key string, dst interface{}) bool {
data, err := c.cli.Get(ctx, key).Bytes()
if err != nil {
return false
}
if err = json.Unmarshal(data, dst); err != nil {
c.logger.Errorf("Get json.Unmarshal error: %v, key: %v", err, key)
return false
}
return true
}

86
db/redis/client.go Normal file
View File

@@ -0,0 +1,86 @@
package redis
import (
"context"
"git.hlsq.asia/mmorpg/service-common/config"
"git.hlsq.asia/mmorpg/service-common/log"
"github.com/redis/go-redis/v9"
"time"
)
var instance *Client
type Client struct {
cli *redis.Client
}
func Init(cfg *config.RedisConfig) error {
client := redis.NewClient(&redis.Options{
Addr: cfg.Addr,
Password: cfg.Password,
DB: cfg.DB,
})
instance = &Client{
cli: client,
}
cacheInstance = &CacheClient{
cli: client,
}
if logger := log.GetLogger(); logger != nil {
cacheInstance.logger = logger.Named("CACHE")
}
_, err := client.Ping(context.Background()).Result()
return err
}
func Close() error {
if instance != nil && instance.cli != nil {
return instance.cli.Close()
}
return nil
}
func GetClient() *Client {
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)
}
func (c *Client) SetNX(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.BoolCmd {
return c.cli.SetNX(ctx, key, value, expiration)
}
func (c *Client) Get(ctx context.Context, key string) *redis.StringCmd {
return c.cli.Get(ctx, key)
}
func (c *Client) HSet(ctx context.Context, key string, values ...interface{}) *redis.IntCmd {
return c.cli.HSet(ctx, key, values...)
}
func (c *Client) HGet(ctx context.Context, key, field string) *redis.StringCmd {
return c.cli.HGet(ctx, key, field)
}
func (c *Client) HGetAll(ctx context.Context, key string) *redis.MapStringStringCmd {
return c.cli.HGetAll(ctx, key)
}
func (c *Client) HDel(ctx context.Context, key string, fields ...string) *redis.IntCmd {
return c.cli.HDel(ctx, key, fields...)
}
func (c *Client) Pipeline() redis.Pipeliner {
return c.cli.Pipeline()
}
func (c *Client) ScriptLoad(ctx context.Context, script string) *redis.StringCmd {
return c.cli.ScriptLoad(ctx, script)
}
func (c *Client) EvalSha(ctx context.Context, sha1 string, keys []string, args ...interface{}) *redis.Cmd {
return c.cli.EvalSha(ctx, sha1, keys, args...)
}

44
discover/common/define.go Normal file
View File

@@ -0,0 +1,44 @@
package common
type ListenerType int
const (
ListenerTypeNewServer = 1 // 服务启动
ListenerTypeCloseServer = 2 // 服务关闭
ListenerTypeNewInstance = 3 // 副本启动
ListenerTypeCloseInstance = 4 // 副本关闭
)
var (
KeyDiscover = "xh-discover"
KeyDiscoverService = KeyDiscover + "/service"
KeyDiscoverInstance = KeyDiscover + "/instance"
)
var (
KeyDiscoverServiceNameGateway = "gateway" // 网关服
KeyDiscoverServiceNameScene = "scene" // 场景服
KeyDiscoverServiceNameUser = "user" // 用户中心
KeyDiscoverServiceNameQgdzs = "qgdzs" // 奇怪的知识-服务端
)
var (
KeyDiscoverGateway = KeyDiscoverService + "/" + KeyDiscoverServiceNameGateway // 网关服
KeyDiscoverScene = KeyDiscoverService + "/" + KeyDiscoverServiceNameScene // 场景服
KeyDiscoverUser = KeyDiscoverService + "/" + KeyDiscoverServiceNameUser // 用户中心
KeyDiscoverQgdzs = KeyDiscoverService + "/" + KeyDiscoverServiceNameQgdzs // 奇怪的知识-服务端
)
// ServiceProvider 服务提供者
type ServiceProvider struct {
Target string
SID int64
Addr string
}
// InstanceProvider 副本提供者
type InstanceProvider struct {
InstanceID int // 副本ID
UniqueNo int64 // 副本唯一编号
SID int64
}

25
discover/common/tool.go Normal file
View File

@@ -0,0 +1,25 @@
package common
import (
"git.hlsq.asia/mmorpg/service-common/db/etcd"
"git.hlsq.asia/mmorpg/service-common/log"
clientv3 "go.etcd.io/etcd/client/v3"
)
// NewLeaseAndKeepAlive 创建租约并保活
func NewLeaseAndKeepAlive(ttl int64) (clientv3.LeaseID, error) {
lease, err := etcd.GetClient().Grant(ttl)
if err != nil {
return 0, err
}
chKeepAlive, err := etcd.GetClient().KeepAlive(lease.ID)
if err != nil {
return 0, err
}
go func(leaseID clientv3.LeaseID) {
for range chKeepAlive {
}
log.Warnf("Lease %x expired or revoked", leaseID)
}(lease.ID)
return lease.ID, nil
}

81
discover/instance.go Normal file
View File

@@ -0,0 +1,81 @@
package discover
import (
"fmt"
"git.hlsq.asia/mmorpg/service-common/db/etcd"
"git.hlsq.asia/mmorpg/service-common/discover/common"
"git.hlsq.asia/mmorpg/service-common/log"
"git.hlsq.asia/mmorpg/service-common/utils"
clientv3 "go.etcd.io/etcd/client/v3"
"sync"
)
// 大量读少量写的情况下读写锁比同步Map更高效
var (
instanceMU = sync.RWMutex{}
instanceM = make(map[int64]int64) // [uniqueNo]sid
instanceLeaseM = make(map[int64]clientv3.LeaseID) // [uniqueNo]
)
func init() {
RegisterListener(common.ListenerTypeNewInstance, onInstanceStart)
RegisterListener(common.ListenerTypeCloseInstance, onInstanceStop)
}
// FindInstanceByUniqueNo 根据唯一标识查询副本
func FindInstanceByUniqueNo(uniqueNO int64) (sid int64) {
instanceMU.RLock()
defer instanceMU.RUnlock()
if c, ok := instanceM[uniqueNO]; ok {
return c
}
return
}
// RegisterInstance 注册副本
func RegisterInstance(sid int64, instanceID int32, uniqueNo int64, ttl int64) error {
serverMU.Lock()
defer serverMU.Unlock()
leaseID, err := common.NewLeaseAndKeepAlive(ttl)
if err != nil {
return err
}
key := fmt.Sprintf("%v/%v/%v", common.KeyDiscoverInstance, instanceID, uniqueNo)
_, err = etcd.GetClient().Put(key, utils.Int64ToString(sid), clientv3.WithLease(leaseID))
if err != nil {
return err
}
instanceLeaseM[uniqueNo] = leaseID
return nil
}
// UnRegisterInstance 解注册副本
func UnRegisterInstance(uniqueNo int64) {
serverMU.Lock()
defer serverMU.Unlock()
if leaseID, ok := instanceLeaseM[uniqueNo]; ok {
_, err := etcd.GetClient().Revoke(leaseID)
if err != nil {
log.Errorf("UnRegisterInstance err: %v", err)
}
delete(instanceLeaseM, uniqueNo)
}
}
// 某个副本启动了
func onInstanceStart(data any) {
if provider, ok := data.(*common.InstanceProvider); ok {
instanceMU.Lock()
defer instanceMU.Unlock()
instanceM[provider.UniqueNo] = provider.SID
}
}
// 某个副本关闭了
func onInstanceStop(data any) {
if provider, ok := data.(*common.InstanceProvider); ok {
instanceMU.Lock()
defer instanceMU.Unlock()
delete(instanceM, provider.UniqueNo)
}
}

132
discover/listener.go Normal file
View File

@@ -0,0 +1,132 @@
package discover
import (
"context"
"fmt"
"git.hlsq.asia/mmorpg/service-common/db/etcd"
"git.hlsq.asia/mmorpg/service-common/discover/common"
"git.hlsq.asia/mmorpg/service-common/log"
"git.hlsq.asia/mmorpg/service-common/utils"
"go.etcd.io/etcd/api/v3/mvccpb"
clientv3 "go.etcd.io/etcd/client/v3"
"strconv"
"strings"
"sync"
)
var (
wg = &sync.WaitGroup{}
listenerMU = &sync.RWMutex{}
listener = make(map[common.ListenerType][]func(data any))
stopFunc context.CancelFunc
)
// RegisterListener 注册服务变动监听
func RegisterListener(t common.ListenerType, cb func(data any)) {
listenerMU.Lock()
defer listenerMU.Unlock()
arr := listener[t]
if arr == nil {
arr = make([]func(data any), 0)
}
arr = append(arr, cb)
listener[t] = arr
}
// 根据类型触发回调
func onCBByType(t common.ListenerType, data any) {
listenerMU.RLock()
defer listenerMU.RUnlock()
for _, f := range listener[t] {
f(data)
}
}
func Listen(ready *sync.WaitGroup) {
var stopCtx context.Context
stopCtx, stopFunc = context.WithCancel(context.Background())
wg.Add(1)
go func() {
defer wg.Done()
log.Infof(fmt.Sprintf("Discover start listen..."))
// 服务
serviceAll, _ := etcd.GetClient().Get(common.KeyDiscoverService, clientv3.WithPrefix())
for _, kv := range serviceAll.Kvs {
onServerChange(clientv3.EventTypePut, string(kv.Key), string(kv.Value))
}
chService := etcd.GetClient().Watch(common.KeyDiscoverService, clientv3.WithPrefix(), clientv3.WithRev(serviceAll.Header.Revision+1))
// 副本
instanceAll, _ := etcd.GetClient().Get(common.KeyDiscoverInstance, clientv3.WithPrefix())
for _, kv := range instanceAll.Kvs {
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())
// 准备好了
ready.Done()
for {
select {
case msg := <-chService:
for _, event := range msg.Events {
onServerChange(event.Type, string(event.Kv.Key), string(event.Kv.Value))
}
case msg := <-chInstance:
for _, event := range msg.Events {
onInstanceChange(event.Type, string(event.Kv.Key), string(event.Kv.Value), event.PrevKv)
}
case <-stopCtx.Done():
return
}
}
}()
}
// 服务发生变化
func onServerChange(t mvccpb.Event_EventType, key, value string) {
split := strings.Split(key, "/")
if len(split) != 4 {
return
}
switch t {
case clientv3.EventTypePut:
onCBByType(common.ListenerTypeNewServer, &common.ServiceProvider{
Target: common.KeyDiscoverService + "/" + split[2],
SID: utils.StringToInt64(split[3]),
Addr: value,
})
case clientv3.EventTypeDelete:
onCBByType(common.ListenerTypeCloseServer, &common.ServiceProvider{
Target: common.KeyDiscoverService + "/" + split[2],
SID: utils.StringToInt64(split[3]),
})
}
}
// 副本发生变化
func onInstanceChange(t mvccpb.Event_EventType, key, value string, preKv *mvccpb.KeyValue) {
split := strings.Split(key, "/")
if len(split) != 4 {
return
}
instanceID, _ := strconv.Atoi(split[2])
switch t {
case clientv3.EventTypePut:
onCBByType(common.ListenerTypeNewInstance, &common.InstanceProvider{
InstanceID: instanceID,
UniqueNo: utils.StringToInt64(split[3]),
SID: utils.StringToInt64(value),
})
case clientv3.EventTypeDelete:
onCBByType(common.ListenerTypeCloseInstance, &common.InstanceProvider{
InstanceID: instanceID,
UniqueNo: utils.StringToInt64(split[3]),
SID: utils.StringToInt64(string(preKv.Value)),
})
}
}
func Close() {
if stopFunc != nil {
stopFunc()
wg.Wait()
}
}

100
discover/server.go Normal file
View File

@@ -0,0 +1,100 @@
package discover
import (
"fmt"
"git.hlsq.asia/mmorpg/service-common/db/etcd"
"git.hlsq.asia/mmorpg/service-common/discover/common"
"git.hlsq.asia/mmorpg/service-common/log"
"git.hlsq.asia/mmorpg/service-common/net/grpc/grpc_conn"
clientv3 "go.etcd.io/etcd/client/v3"
"google.golang.org/grpc"
"sync"
)
// 大量读少量写的情况下读写锁比同步Map更高效
var (
serverMU = sync.RWMutex{}
conn = make(map[string]*grpc_conn.GrpcConnectionMgr)
serverLeaseM = make(map[int64]clientv3.LeaseID)
)
func init() {
RegisterListener(common.ListenerTypeNewServer, onServerStart)
RegisterListener(common.ListenerTypeCloseServer, onServerStop)
}
// FindServer 根据SID或随机查找服务
func FindServer(target string, sid ...int64) (*grpc.ClientConn, error) {
serverMU.RLock()
defer serverMU.RUnlock()
if v, ok := conn[target]; ok {
return v.Load(sid...)
}
return nil, fmt.Errorf("cannot find server")
}
func FindServerAll(target string) map[int64]*grpc.ClientConn {
serverMU.RLock()
defer serverMU.RUnlock()
if v, ok := conn[target]; ok {
return v.LoadAll()
}
return make(map[int64]*grpc.ClientConn)
}
// RegisterGrpcServer 注册服务提供者
func RegisterGrpcServer(target string, sid int64, addr string, ttl int64) error {
serverMU.Lock()
defer serverMU.Unlock()
leaseID, err := common.NewLeaseAndKeepAlive(ttl)
if err != nil {
return err
}
_, err = etcd.GetClient().Put(fmt.Sprintf("%v/%v", target, sid), addr, clientv3.WithLease(leaseID))
if err != nil {
return err
}
serverLeaseM[sid] = leaseID
return nil
}
// UnRegisterGrpcServer 解注册服务提供者
func UnRegisterGrpcServer(sid int64) {
serverMU.Lock()
defer serverMU.Unlock()
if leaseID, ok := serverLeaseM[sid]; ok {
_, err := etcd.GetClient().Revoke(leaseID)
if err != nil {
log.Errorf("server.go UnRegisterGrpcServer err: %v", err)
}
delete(serverLeaseM, sid)
}
}
// 某个服务启动了
func onServerStart(data any) {
if provider, ok := data.(*common.ServiceProvider); ok {
serverMU.Lock()
defer serverMU.Unlock()
if v, ok := conn[provider.Target]; ok {
v.Store(provider.SID, provider.Addr)
} else {
mgr := grpc_conn.NewGrpcConnectionMgr()
mgr.Store(provider.SID, provider.Addr)
conn[provider.Target] = mgr
}
}
}
// 某个服务关闭了
func onServerStop(data any) {
if provider, ok := data.(*common.ServiceProvider); ok {
serverMU.Lock()
defer serverMU.Unlock()
if v, ok := conn[provider.Target]; ok {
if v.Delete(provider.SID) == 0 {
delete(conn, provider.Target)
}
}
}
}

127
go.mod Normal file
View File

@@ -0,0 +1,127 @@
module git.hlsq.asia/mmorpg/service-common
go 1.24.0
require (
github.com/IBM/sarama v1.46.3
github.com/bwmarrin/snowflake v0.3.0
github.com/gin-gonic/gin v1.11.0
github.com/gobwas/ws v1.4.0
github.com/golang-jwt/jwt/v5 v5.3.0
github.com/golang/mock v1.6.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3
github.com/natefinch/lumberjack v2.0.0+incompatible
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/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/client/v3 v3.6.1
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
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217
google.golang.org/grpc v1.77.0
google.golang.org/protobuf v1.36.10
gorm.io/driver/mysql v1.6.0
gorm.io/gorm v1.31.1
)
require (
filippo.io/edwards25519 v1.1.0 // indirect
github.com/BurntSushi/toml v1.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bytedance/gopkg v0.1.3 // indirect
github.com/bytedance/sonic v1.14.2 // indirect
github.com/bytedance/sonic/loader v0.4.0 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cloudwego/base64x v0.1.6 // indirect
github.com/coreos/go-semver v0.3.1 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/eapache/go-resiliency v1.7.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.11 // indirect
github.com/gin-contrib/sse v1.1.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.28.0 // indirect
github.com/go-sql-driver/mysql v1.8.1 // indirect
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
github.com/gobwas/httphead v0.1.0 // indirect
github.com/gobwas/pool v0.2.1 // indirect
github.com/goccy/go-json v0.10.5 // indirect
github.com/goccy/go-yaml v1.19.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
github.com/jcmturner/gofork v1.7.6 // indirect
github.com/jcmturner/gokrb5/v8 v8.4.4 // indirect
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.18.1 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/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/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/pierrec/lz4/v4 v4.1.22 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.62.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/quic-go/qpack v0.6.0 // indirect
github.com/quic-go/quic-go v0.57.1 // indirect
github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9 // indirect
github.com/sagikazarmark/locafero v0.11.0 // indirect
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect
github.com/spf13/afero v1.15.0 // indirect
github.com/spf13/cast v1.10.0 // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.3.1 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // 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.6.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/arch v0.23.0 // indirect
golang.org/x/crypto v0.45.0 // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/sync v0.18.0 // indirect
golang.org/x/sys v0.39.0 // indirect
golang.org/x/text v0.31.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

351
go.sum Normal file
View File

@@ -0,0 +1,351 @@
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/IBM/sarama v1.46.3 h1:njRsX6jNlnR+ClJ8XmkO+CM4unbrNr/2vB5KK6UA+IE=
github.com/IBM/sarama v1.46.3/go.mod h1:GTUYiF9DMOZVe3FwyGT+dtSPceGFIgA+sPc5u6CBwko=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0=
github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE=
github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M=
github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM=
github.com/bytedance/sonic v1.14.2 h1:k1twIoe97C1DtYUo+fZQy865IuHia4PR5RPiuGPPIIE=
github.com/bytedance/sonic v1.14.2/go.mod h1:T80iDELeHiHKSc0C9tubFygiuXoGzrkjKzX2quAx980=
github.com/bytedance/sonic/loader v0.4.0 h1:olZ7lEqcxtZygCK9EKYKADnpQoYkRQxaeY2NYzevs+o=
github.com/bytedance/sonic/loader v0.4.0/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo=
github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M=
github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU=
github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4=
github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec=
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/eapache/go-resiliency v1.7.0 h1:n3NRTnBn5N0Cbi/IeOHuQn9s2UwVUH7Ga0ZWcP+9JTA=
github.com/eapache/go-resiliency v1.7.0/go.mod h1:5yPzW0MIvSe0JDsv0v+DvcjEv2FyD6iZYSs1ZI+iQho=
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 h1:Oy0F4ALJ04o5Qqpdz8XLIpNA3WM/iSIXqxtqo7UGVws=
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3/go.mod h1:YvSRo5mw33fLEx1+DlK6L2VV43tJt5Eyel9n9XBcR+0=
github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc=
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
github.com/gabriel-vasile/mimetype v1.4.11 h1:AQvxbp830wPhHTqc1u7nzoLT+ZFxGY7emj5DR5DYFik=
github.com/gabriel-vasile/mimetype v1.4.11/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w=
github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM=
github.com/gin-gonic/gin v1.11.0 h1:OW/6PLjyusp2PPXtyxKHU0RbX6I/l28FTdDlae5ueWk=
github.com/gin-gonic/gin v1.11.0/go.mod h1:+iq/FyxlGzII0KHiBGjuNn4UNENUlKbGlNmc+W50Dls=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.28.0 h1:Q7ibns33JjyW48gHkuFT91qX48KG0ktULL6FgHdG688=
github.com/go-playground/validator/v10 v10.28.0/go.mod h1:GoI6I1SjPBh9p7ykNE/yj3fFYbyDOpwMn5KXd+m2hUU=
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs=
github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU=
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og=
github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
github.com/gobwas/ws v1.4.0 h1:CTaoG1tojrh4ucGPcoJFiAQUAsEWekEWvLy7GsVNqGs=
github.com/gobwas/ws v1.4.0/go.mod h1:G3gNqMNtPppf5XUz7O4shetPpcZ1VJ7zt18dlUeakrc=
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/goccy/go-yaml v1.19.0 h1:EmkZ9RIsX+Uq4DYFowegAuJo8+xdX3T/2dwNPXbxEYE=
github.com/goccy/go-yaml v1.19.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo=
github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 h1:NmZ1PKzSTQbuGHw9DGPFomqkkLWMC+vZCkfs+FHv1Vg=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3/go.mod h1:zQrxl1YP88HQlA6i9c63DSVPFklWpGX4OWAc9bFuaH4=
github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8=
github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs=
github.com/jcmturner/dnsutils/v2 v2.0.0 h1:lltnkeZGL0wILNvrNiVCR6Ro5PGU/SeBvVO/8c/iPbo=
github.com/jcmturner/dnsutils/v2 v2.0.0/go.mod h1:b0TnjGOvI/n42bZa+hmXL+kFJZsFT7G4t3HTlQ184QM=
github.com/jcmturner/gofork v1.7.6 h1:QH0l3hzAU1tfT3rZCnW5zXl+orbkNMMRGJfdJjHVETg=
github.com/jcmturner/gofork v1.7.6/go.mod h1:1622LH6i/EZqLloHfE7IeZ0uEJwMSUyQ/nDd82IeqRo=
github.com/jcmturner/goidentity/v6 v6.0.1 h1:VKnZd2oEIMorCTsFBnJWbExfNN7yZr3EhJAxwOkZg6o=
github.com/jcmturner/goidentity/v6 v6.0.1/go.mod h1:X1YW3bgtvwAXju7V3LCIMpY0Gbxyjn/mY9zx4tFonSg=
github.com/jcmturner/gokrb5/v8 v8.4.4 h1:x1Sv4HaTpepFkXbt2IkL29DXRf8sOfZXo8eRKh687T8=
github.com/jcmturner/gokrb5/v8 v8.4.4/go.mod h1:1btQEpgT6k+unzCwX1KdWMEwPPkkgBtP+F6aCACiMrs=
github.com/jcmturner/rpc/v2 v2.0.3 h1:7FXXj8Ti1IaVFpSAziCZWNzbNuZmnvw/i6CqLNdWfZY=
github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co=
github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0=
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE=
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/go.mod h1:Wi9p2TTF5DG5oU+6YfsmYQpsTIOm0B1VNzQg9Mw6nPk=
github.com/panjf2000/ants/v2 v2.11.3 h1:AfI0ngBoXJmYOpDh9m516vjqoUu2sLrIVgppI9TZVpg=
github.com/panjf2000/ants/v2 v2.11.3/go.mod h1:8u92CYMUc6gyvTIw8Ru7Mt7+/ESnJahz5EVtqfrilek=
github.com/panjf2000/gnet/v2 v2.9.7 h1:6zW7Jl3oAfXwSuh1PxHLndoL2MQRWx0AJR6aaQjxUgA=
github.com/panjf2000/gnet/v2 v2.9.7/go.mod h1:WQTxDWYuQ/hz3eccH0FN32IVuvZ19HewEWx0l62fx7E=
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
github.com/pierrec/lz4/v4 v4.1.22 h1:cKFw6uJDK+/gfw5BcDL0JL5aBsAFdsIT18eRtLj7VIU=
github.com/pierrec/lz4/v4 v4.1.22/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ2Io=
github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I=
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8=
github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII=
github.com/quic-go/quic-go v0.57.1 h1:25KAAR9QR8KZrCZRThWMKVAwGoiHIrNbT72ULHTuI10=
github.com/quic-go/quic-go v0.57.1/go.mod h1:ly4QBAjHA2VhdnxhojRsCUOeJwKYg+taDlos92xb1+s=
github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9 h1:bsUq1dX0N8AOIL7EB/X911+m4EHsnWEHeJ0c+3TTBrg=
github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/redis/go-redis/v9 v9.10.0 h1:FxwK3eV8p/CQa0Ch276C7u2d0eNC9kCmAYQ7mCXCzVs=
github.com/redis/go-redis/v9 v9.10.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/sagikazarmark/locafero v0.11.0 h1:1iurJgmM9G3PA/I+wWYIOw/5SyBtxapeHDcg+AAIFXc=
github.com/sagikazarmark/locafero v0.11.0/go.mod h1:nVIGvgyzw595SUSUE6tvCp3YYTeHs15MvlmU87WwIik=
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 h1:+jumHNA0Wrelhe64i8F6HNlS8pkoyMv5sreGx2Ry5Rw=
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8/go.mod h1:3n1Cwaq1E1/1lhQhtRK2ts/ZwZEhjcQeJQ1RuC6Q/8U=
github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I=
github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg=
github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY=
github.com/spf13/cast v1.10.0/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo=
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.21.0 h1:x5S+0EU27Lbphp4UKm1C+1oQO+rKx36vfCoaVebLFSU=
github.com/spf13/viper v1.21.0/go.mod h1:P0lhsswPGWD/1lZJ9ny3fYnVqxiegrlNrEmgLjbTCAY=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.3.1 h1:waO7eEiFDwidsBN6agj1vJQ4AG7lh2yqXyOXqhgQuyY=
github.com/ugorji/go/codec v1.3.1/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY=
github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4=
github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8=
github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM=
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM=
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.etcd.io/etcd/api/v3 v3.6.1 h1:yJ9WlDih9HT457QPuHt/TH/XtsdN2tubyxyQHSHPsEo=
go.etcd.io/etcd/api/v3 v3.6.1/go.mod h1:lnfuqoGsXMlZdTJlact3IB56o3bWp1DIlXPIGKRArto=
go.etcd.io/etcd/client/pkg/v3 v3.6.1 h1:CxDVv8ggphmamrXM4Of8aCC8QHzDM4tGcVr9p2BSoGk=
go.etcd.io/etcd/client/pkg/v3 v3.6.1/go.mod h1:aTkCp+6ixcVTZmrJGa7/Mc5nMNs59PEgBbq+HCmWyMc=
go.etcd.io/etcd/client/v3 v3.6.1 h1:KelkcizJGsskUXlsxjVrSmINvMMga0VWwFF0tSPGEP0=
go.etcd.io/etcd/client/v3 v3.6.1/go.mod h1:fCbPUdjWNLfx1A6ATo9syUmFVxqHH9bCnPLBZmnLmMY=
go.mongodb.org/mongo-driver v1.17.6 h1:87JUG1wZfWsr6rIz3ZmpH90rL5tea7O3IHuSwHUpsss=
go.mongodb.org/mongo-driver v1.17.6/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ=
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.64.0 h1:RN3ifU8y4prNWeEnQp2kRRHz8UwonAEYZl8tUzHEXAk=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.64.0/go.mod h1:habDz3tEWiFANTo6oUE99EmaFUrCNYAAg3wiVmusm70=
go.opentelemetry.io/otel v1.39.0 h1:8yPrr/S0ND9QEfTfdP9V+SiwT4E0G7Y5MO7p85nis48=
go.opentelemetry.io/otel v1.39.0/go.mod h1:kLlFTywNWrFyEdH0oj2xK0bFYZtHRYUdv1NklR/tgc8=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.39.0 h1:f0cb2XPmrqn4XMy9PNliTgRKJgS5WcL/u0/WRYGz4t0=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.39.0/go.mod h1:vnakAaFckOMiMtOIhFI2MNH4FYrZzXCYxmb1LlhoGz8=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.39.0 h1:in9O8ESIOlwJAEGTkkf34DesGRAc/Pn8qJ7k3r/42LM=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.39.0/go.mod h1:Rp0EXBm5tfnv0WL+ARyO/PHBEaEAT8UUHQ6AGJcSq6c=
go.opentelemetry.io/otel/metric v1.39.0 h1:d1UzonvEZriVfpNKEVmHXbdf909uGTOQjA0HF0Ls5Q0=
go.opentelemetry.io/otel/metric v1.39.0/go.mod h1:jrZSWL33sD7bBxg1xjrqyDjnuzTUB0x1nBERXd7Ftcs=
go.opentelemetry.io/otel/sdk v1.39.0 h1:nMLYcjVsvdui1B/4FRkwjzoRVsMK8uL/cj0OyhKzt18=
go.opentelemetry.io/otel/sdk v1.39.0/go.mod h1:vDojkC4/jsTJsE+kh+LXYQlbL8CgrEcwmt1ENZszdJE=
go.opentelemetry.io/otel/sdk/metric v1.39.0 h1:cXMVVFVgsIf2YL6QkRF4Urbr/aMInf+2WKg+sEJTtB8=
go.opentelemetry.io/otel/sdk/metric v1.39.0/go.mod h1:xq9HEVH7qeX69/JnwEfp6fVq5wosJsY1mt4lLfYdVew=
go.opentelemetry.io/otel/trace v1.39.0 h1:2d2vfpEDmCJ5zVYz7ijaJdOF59xLomrvj7bjt6/qCJI=
go.opentelemetry.io/otel/trace v1.39.0/go.mod h1:88w4/PnZSazkGzz/w84VHpQafiU4EtqqlVdxWy+rNOA=
go.opentelemetry.io/proto/otlp v1.9.0 h1:l706jCMITVouPOqEnii2fIAuO3IVGBRPV5ICjceRb/A=
go.opentelemetry.io/proto/otlp v1.9.0/go.mod h1:xE+Cx5E/eEHw+ISFkwPLwCZefwVjY+pqKg1qcK03+/4=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
golang.org/x/arch v0.23.0 h1:lKF64A2jF6Zd8L0knGltUnegD62JMFBiCPBmQpToHhg=
golang.org/x/arch v0.23.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I=
golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 h1:fCvbg86sFXwdrl5LgVcTEvNC+2txB5mgROGmRL5mrls=
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217/go.mod h1:+rXWjjaukWZun3mLfjmVnQi18E1AsFbDN9QdJ5YXLto=
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 h1:gRkg/vSppuSQoDjxyiGfN4Upv/h/DQmIR10ZU8dh4Ww=
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk=
google.golang.org/grpc v1.77.0 h1:wVVY6/8cGA6vvffn+wWK5ToddbgdU3d8MNENr4evgXM=
google.golang.org/grpc v1.77.0/go.mod h1:z0BY1iVj0q8E1uSQCjL9cppRj+gnZjzDnzV0dHhrNig=
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/driver/mysql v1.6.0 h1:eNbLmNTpPpTOVZi8MMxCi2aaIm0ZpInbORNXDwyLGvg=
gorm.io/driver/mysql v1.6.0/go.mod h1:D/oCC2GWK3M/dqoLxnOlaNKmXz8WNTfcS9y5ovaSqKo=
gorm.io/gorm v1.31.1 h1:7CA8FTFz/gRfgqgpeKIBcervUn3xSyPUmr6B2WXJ7kg=
gorm.io/gorm v1.31.1/go.mod h1:XyQVbO2k6YkOis7C2437jSit3SsDK72s7n7rsSHd+Gs=

23
log/level.go Normal file
View File

@@ -0,0 +1,23 @@
package log
import (
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
var logLevelMap = map[string]zapcore.Level{
"panic": zap.DPanicLevel,
"fatal": zap.FatalLevel,
"error": zap.ErrorLevel,
"warn": zap.WarnLevel,
"info": zap.InfoLevel,
"debug": zap.DebugLevel,
}
// GetLogLevel get the logLevel from logLevelName
func GetLogLevel(logLevelName string) zapcore.Level {
if v, ok := logLevelMap[logLevelName]; ok {
return v
}
return zap.DebugLevel
}

66
log/log.go Normal file
View File

@@ -0,0 +1,66 @@
package log
import "go.uber.org/zap"
var globalLogger *zap.SugaredLogger
// SetLogger 设置日志记录器
func SetLogger(logger *zap.SugaredLogger) {
if logger == nil {
return
}
globalLogger = logger
}
func GetLogger() *zap.SugaredLogger {
return globalLogger
}
// Debugf 打印调试模板日志
func Debugf(format string, a ...interface{}) {
if globalLogger != nil {
globalLogger.Debugf(format, a...)
}
}
// Infof 打印信息模板日志
func Infof(format string, a ...interface{}) {
if globalLogger != nil {
globalLogger.Infof(format, a...)
}
}
// Warnf 打印警告模板日志
func Warnf(format string, a ...interface{}) {
if globalLogger != nil {
globalLogger.Warnf(format, a...)
}
}
// Errorf 打印错误模板日志
func Errorf(format string, a ...interface{}) {
if globalLogger != nil {
globalLogger.Errorf(format, a...)
}
}
// Panicf 打印Panic模板日志
func Panicf(format string, a ...interface{}) {
if globalLogger != nil {
globalLogger.Panicf(format, a...)
}
}
// Fatalf 打印致命错误模板日志
func Fatalf(format string, a ...interface{}) {
if globalLogger != nil {
globalLogger.Fatalf(format, a...)
}
}
// Close 关闭日志
func Close() {
if globalLogger != nil {
_ = globalLogger.Sync()
}
}

64
log/log_zap.go Normal file
View File

@@ -0,0 +1,64 @@
package log
import (
"git.hlsq.asia/mmorpg/service-common/config"
"github.com/natefinch/lumberjack"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"os"
)
func Init(cfg *config.LogConfig) {
// 格式配置
jsonConfig := zapcore.EncoderConfig{
MessageKey: "M",
LevelKey: "L",
TimeKey: "T",
NameKey: "N",
CallerKey: "C",
FunctionKey: zapcore.OmitKey,
StacktraceKey: "S",
LineEnding: zapcore.DefaultLineEnding,
EncodeLevel: zapcore.CapitalLevelEncoder,
EncodeTime: zapcore.TimeEncoderOfLayout("01-02 15:04:05.000"),
EncodeDuration: zapcore.SecondsDurationEncoder,
EncodeCaller: zapcore.ShortCallerEncoder,
EncodeName: func(loggerName string, enc zapcore.PrimitiveArrayEncoder) {
enc.AppendString("[" + loggerName + "]")
},
ConsoleSeparator: " ",
}
// 日志输出到控制台和文件
writeSyncer := []zapcore.WriteSyncer{zapcore.AddSync(os.Stdout)}
if !cfg.Debug {
writeSyncer = append(writeSyncer, zapcore.AddSync(&lumberjack.Logger{
Filename: "./logs/log.log", // 日志文件位置
MaxSize: int(cfg.MaxSize), // 最大文件大小MB
MaxBackups: int(cfg.MaxBackups), // 保留旧文件的最大个数
MaxAge: int(cfg.MaxAge), // 保留旧文件的最大天数
Compress: false, // 是否压缩/归档旧文件
LocalTime: true,
}))
}
var encoder zapcore.Encoder
if cfg.Debug {
encoder = zapcore.NewConsoleEncoder(jsonConfig)
} else {
encoder = zapcore.NewJSONEncoder(jsonConfig)
}
logger := zap.New(zapcore.NewCore(
encoder,
zapcore.NewMultiWriteSyncer(writeSyncer...),
zap.NewAtomicLevelAt(GetLogLevel(cfg.Level)),
))
if cfg.Debug {
logger = logger.WithOptions(
zap.AddCaller(),
zap.AddCallerSkip(1),
zap.AddStacktrace(zapcore.ErrorLevel),
)
}
SetLogger(logger.Sugar())
}

61
module/db.go Normal file
View File

@@ -0,0 +1,61 @@
package module
import (
"git.hlsq.asia/mmorpg/service-common/config"
"git.hlsq.asia/mmorpg/service-common/db/etcd"
"git.hlsq.asia/mmorpg/service-common/db/kafka"
"git.hlsq.asia/mmorpg/service-common/db/mysql"
"git.hlsq.asia/mmorpg/service-common/db/redis"
"git.hlsq.asia/mmorpg/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
}
}
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)
}
return nil
}

21
module/discover.go Normal file
View File

@@ -0,0 +1,21 @@
package module
import (
"git.hlsq.asia/mmorpg/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/mmorpg/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/mmorpg/service-common/config"
"git.hlsq.asia/mmorpg/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/mmorpg/service-common/config"
"git.hlsq.asia/mmorpg/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
}

64
module/snowflake.go Normal file
View File

@@ -0,0 +1,64 @@
package module
import (
"context"
"errors"
"fmt"
"git.hlsq.asia/mmorpg/service-common/db/etcd"
"git.hlsq.asia/mmorpg/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")
}

53
module/tracer.go Normal file
View File

@@ -0,0 +1,53 @@
package module
import (
"context"
"git.hlsq.asia/mmorpg/service-common/config"
"git.hlsq.asia/mmorpg/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
}
m.tp = sdktrace.NewTracerProvider(
sdktrace.WithBatcher(exporter),
sdktrace.WithResource(resource.NewWithAttributes(
semconv.SchemaURL,
semconv.ServiceNameKey.String(m.ServiceName),
)),
)
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,24 @@
package grpc_client
import (
"git.hlsq.asia/mmorpg/service-common/discover"
"git.hlsq.asia/mmorpg/service-common/discover/common"
"git.hlsq.asia/mmorpg/service-common/proto/rs/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

@@ -0,0 +1,24 @@
package grpc_client
import (
"git.hlsq.asia/mmorpg/service-common/discover"
"git.hlsq.asia/mmorpg/service-common/discover/common"
"git.hlsq.asia/mmorpg/service-common/net/grpc/resolver"
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
)
func QgdzsNewClient(sid ...int64) (grpc_pb.QgdzsClient, error) {
c, err := discover.FindServer(common.KeyDiscoverQgdzs, sid...)
if err != nil {
return nil, err
}
return grpc_pb.NewQgdzsClient(c), nil
}
func QgdzsNewClientLB() (grpc_pb.QgdzsClient, error) {
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameQgdzs)
if err != nil {
return nil, err
}
return grpc_pb.NewQgdzsClient(c), nil
}

View File

@@ -0,0 +1,33 @@
package grpc_client
import (
"git.hlsq.asia/mmorpg/service-common/discover"
"git.hlsq.asia/mmorpg/service-common/discover/common"
"git.hlsq.asia/mmorpg/service-common/net/grpc/resolver"
"git.hlsq.asia/mmorpg/service-common/proto/rs/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

@@ -0,0 +1,24 @@
package grpc_client
import (
"git.hlsq.asia/mmorpg/service-common/discover"
"git.hlsq.asia/mmorpg/service-common/discover/common"
"git.hlsq.asia/mmorpg/service-common/net/grpc/resolver"
"git.hlsq.asia/mmorpg/service-common/proto/rs/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,83 @@
package grpc_client
import (
"context"
"fmt"
"git.hlsq.asia/mmorpg/service-common/log"
"google.golang.org/grpc"
"google.golang.org/protobuf/proto"
"sync"
)
type GatewayFun int
const (
FunToClient GatewayFun = iota
)
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.ToClient(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
}
func gatewayKey(sid int64, fun GatewayFun) string {
return fmt.Sprintf("%v-%v", sid, fun)
}

View File

@@ -0,0 +1,83 @@
package grpc_client
import (
"context"
"fmt"
"git.hlsq.asia/mmorpg/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

@@ -0,0 +1,43 @@
package grpc_conn
import (
"git.hlsq.asia/mmorpg/service-common/log"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/keepalive"
"time"
)
type GrpcConnection struct {
sid int64
conn *grpc.ClientConn
}
func NewGrpcConnection(sid int64, address string) (*GrpcConnection, error) {
p := &GrpcConnection{
sid: sid,
}
conn, err := grpc.NewClient(
address,
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithStatsHandler(otelgrpc.NewClientHandler()),
grpc.WithKeepaliveParams(
keepalive.ClientParameters{
Time: 30 * time.Second, // 保活探测包发送的时间间隔
Timeout: 10 * time.Second, // 保活探测包的超时时间
PermitWithoutStream: true,
},
),
)
if err != nil {
log.Errorf("create grpc err: %v, sid: %v, addr: %v", err, sid, address)
return nil, err
}
p.conn = conn
return p, nil
}
func (g *GrpcConnection) GetConnection() *grpc.ClientConn {
return g.conn
}

View File

@@ -0,0 +1,62 @@
package grpc_conn
import (
"fmt"
"git.hlsq.asia/mmorpg/service-common/log"
"google.golang.org/grpc"
"math/rand"
)
type GrpcConnectionMgr struct {
poolM map[int64]*GrpcConnection
poolS []*GrpcConnection
}
func NewGrpcConnectionMgr() *GrpcConnectionMgr {
return &GrpcConnectionMgr{
poolM: make(map[int64]*GrpcConnection),
poolS: make([]*GrpcConnection, 0),
}
}
func (p *GrpcConnectionMgr) Store(sid int64, addr string) {
pool, err := NewGrpcConnection(sid, addr)
if err != nil {
log.Errorf("create grpc err: %v, sid: %v, addr: %v", err, sid, addr)
return
}
p.poolM[sid] = pool
p.poolS = append(p.poolS, pool)
}
func (p *GrpcConnectionMgr) Delete(sid int64) int {
delete(p.poolM, sid)
for i, pool := range p.poolS {
if pool.sid == sid {
p.poolS = append(p.poolS[:i], p.poolS[i+1:]...)
break
}
}
return len(p.poolS)
}
func (p *GrpcConnectionMgr) Load(sid ...int64) (*grpc.ClientConn, error) {
var pool *GrpcConnection
if len(sid) > 0 && sid[0] != 0 {
pool = p.poolM[sid[0]]
} else {
pool = p.poolS[rand.Intn(len(p.poolS))]
}
if pool == nil {
return nil, fmt.Errorf("cannot find connection")
}
return pool.GetConnection(), nil
}
func (p *GrpcConnectionMgr) LoadAll() map[int64]*grpc.ClientConn {
sidM := make(map[int64]*grpc.ClientConn)
for sid, pool := range p.poolM {
sidM[sid] = pool.GetConnection()
}
return sidM
}

42
net/grpc/resolver/conn.go Normal file
View File

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

View File

@@ -0,0 +1,84 @@
package resolver
import (
"context"
"git.hlsq.asia/mmorpg/service-common/db/etcd"
"git.hlsq.asia/mmorpg/service-common/discover/common"
"git.hlsq.asia/mmorpg/service-common/log"
"go.etcd.io/etcd/client/v3"
"google.golang.org/grpc/resolver"
"strings"
)
const etcdSchema = "etcd"
func init() {
resolver.Register(&etcdBuilder{})
}
type etcdBuilder struct{}
func (*etcdBuilder) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOptions) (resolver.Resolver, error) {
serviceName := strings.TrimPrefix(target.URL.Path, "/")
r := &etcdResolver{
serviceName: serviceName,
cc: cc,
}
r.start()
return r, nil
}
func (*etcdBuilder) Scheme() string { return etcdSchema }
type etcdResolver struct {
serviceName string
cc resolver.ClientConn
ctx context.Context
cancel context.CancelFunc
}
func (r *etcdResolver) start() {
r.ctx, r.cancel = context.WithCancel(context.Background())
r.update()
go r.watch()
}
func (r *etcdResolver) getPrefix() string {
return common.KeyDiscoverService + "/" + r.serviceName
}
func (r *etcdResolver) update() {
resp, err := etcd.GetClient().Get(r.getPrefix(), clientv3.WithPrefix())
if err != nil {
log.Errorf("etcd resolver get error: %v", err)
return
}
var addrArray []resolver.Address
for _, kv := range resp.Kvs {
addr := string(kv.Value)
if addr != "" {
addrArray = append(addrArray, resolver.Address{Addr: addr})
}
}
_ = r.cc.UpdateState(resolver.State{Addresses: addrArray})
}
func (r *etcdResolver) watch() {
watchCh := etcd.GetClient().Watch(r.getPrefix(), clientv3.WithPrefix())
for w := range watchCh {
if w.Err() != nil {
continue
}
r.update()
}
}
func (r *etcdResolver) ResolveNow(resolver.ResolveNowOptions) {
r.update()
}
func (r *etcdResolver) Close() {
r.cancel()
}

View File

@@ -0,0 +1,35 @@
package resolver
import (
"google.golang.org/grpc"
"sync"
)
var (
mu = sync.RWMutex{}
conn = make(map[string]*grpc.ClientConn)
)
func GetGrpcClientConn(target string) (*grpc.ClientConn, error) {
mu.RLock()
if c, ok := conn[target]; ok && c != nil {
mu.RUnlock()
return c, nil
}
mu.RUnlock()
mu.Lock()
defer mu.Unlock()
if c, ok := conn[target]; ok && c != nil {
return c, nil
}
newConn, err := NewGrpcConnection(target)
if err != nil {
return nil, err
}
conn[target] = newConn
return newConn, nil
}

View File

@@ -0,0 +1,60 @@
package service
import (
"context"
"fmt"
"git.hlsq.asia/mmorpg/service-common/log"
"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"
"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) 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()
reqString := fmt.Sprintf("[usn:%v] method: %s, Request: %v", usn, info.FullMethod, req)
span.SetAttributes(attribute.String("rpc.req", reqString))
log.Infof(reqString)
start := time.Now()
resp, err = handler(ctx, req)
respString := fmt.Sprintf("[usn:%v] method: %s, Duration: %v, Response: %v, Error: %v", usn, info.FullMethod, time.Since(start), resp, 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())),
))
}
span.SetStatus(otelcodes.Error, err.Error())
}
return
}

104
net/grpc/service/service.go Normal file
View File

@@ -0,0 +1,104 @@
package service
import (
"fmt"
"git.hlsq.asia/mmorpg/service-common/config"
"git.hlsq.asia/mmorpg/service-common/discover"
"git.hlsq.asia/mmorpg/service-common/log"
"git.hlsq.asia/mmorpg/service-common/utils"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"google.golang.org/grpc"
"google.golang.org/grpc/health"
"google.golang.org/grpc/health/grpc_health_v1"
"google.golang.org/grpc/keepalive"
"net"
"sync"
"time"
)
type IService interface {
Init(ready *sync.WaitGroup)
SetReady()
Close()
}
type Base struct {
Target string
ServiceName string
SID int64
Serve *grpc.Server
Cfg *config.GrpcConfig
OnCustomGrpcServerOption func() []grpc.ServerOption
OnInit func(serve *grpc.Server)
OnClose func()
wg *sync.WaitGroup
healthcheck *health.Server
}
func (s *Base) Init(ready *sync.WaitGroup) {
s.wg = &sync.WaitGroup{}
s.wg.Add(1)
s.SID = utils.SnowflakeInstance().Generate().Int64()
go func() {
defer s.wg.Done()
defer s.OnClose()
defer discover.UnRegisterGrpcServer(s.SID)
// 监听端口
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", s.Cfg.Port))
if err != nil {
log.Errorf("%v ListenPort err: %v", s.Target, err)
return
}
options := []grpc.ServerOption{
grpc.ChainUnaryInterceptor(
s.RecoveryInterceptor,
s.LoggingInterceptor,
),
grpc.StatsHandler(otelgrpc.NewServerHandler()),
grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{
MinTime: 20 * time.Second,
PermitWithoutStream: true,
}),
}
options = append(options, s.OnCustomGrpcServerOption()...)
s.Serve = grpc.NewServer(options...)
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", s.Cfg.Address, s.Cfg.Port), s.Cfg.TTL); err != nil {
log.Errorf("%v RegisterGrpcServer err: %v", s.Target, err)
return
}
// 准备好了
ready.Done()
if err = s.Serve.Serve(lis); err != nil {
log.Errorf("%v Serve err: %v", s.Target, err)
return
}
log.Infof("%v server stop.", s.Target)
}()
}
func (s *Base) SetReady() {
if s.healthcheck != nil {
s.healthcheck.SetServingStatus("", grpc_health_v1.HealthCheckResponse_SERVING)
}
}
func (s *Base) Close() {
if s.healthcheck != nil {
s.healthcheck.SetServingStatus("", grpc_health_v1.HealthCheckResponse_NOT_SERVING)
}
if s.Serve != nil {
s.Serve.GracefulStop()
s.wg.Wait()
}
}

View File

@@ -0,0 +1,49 @@
package http_resp
import (
"git.hlsq.asia/mmorpg/service-common/proto/rs/rs_common"
"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")
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(&rs_common.ErrorInfo{
Code: int32(c.Code()),
Msg: c.Error(),
})
return st.Err()
}

View File

@@ -0,0 +1,47 @@
package http_resp
import (
"github.com/gin-gonic/gin"
"net/http"
)
type RespJsonData struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data interface{} `json:"data,omitempty"`
}
func Success(data interface{}) *RespJsonData {
return &RespJsonData{
Code: OK.Code(),
Msg: OK.Error(),
Data: data,
}
}
func Error(code *Code) *RespJsonData {
return &RespJsonData{
Code: code.Code(),
Msg: code.Error(),
}
}
func JsonOK(c *gin.Context, data *RespJsonData) {
c.JSON(http.StatusOK, data)
}
func JsonBadRequest(c *gin.Context) {
c.JSON(http.StatusBadRequest, Error(ParamError))
}
func JsonMethodNotAllowed(c *gin.Context) {
c.JSON(http.StatusMethodNotAllowed, Error(MethodNotAllowed))
}
func JsonNotFound(c *gin.Context) {
c.JSON(http.StatusNotFound, Error(NotFound))
}
func JsonUnauthorized(c *gin.Context) {
c.JSON(http.StatusUnauthorized, Error(TokenInvalid))
}

48
net/socket/server.go Normal file
View File

@@ -0,0 +1,48 @@
package socket
import (
"time"
)
type Action int
const (
// None indicates that no action should occur following an event.
None Action = iota
// Close closes the connection.
Close
// Shutdown shutdowns the engine.
Shutdown
)
type OpCode byte
const (
OpContinuation OpCode = 0x0
OpText OpCode = 0x1
OpBinary OpCode = 0x2
OpClose OpCode = 0x8
OpPing OpCode = 0x9
OpPong OpCode = 0xa
)
// ISocketServer 由应用层实现
type ISocketServer interface {
OnOpen(ISocketConn) ([]byte, Action) // 开启连接
OnHandShake(ISocketConn) Action // 开始握手
OnMessage(ISocketConn, []byte) Action // 收到消息
OnPong(ISocketConn)
OnClose(ISocketConn, error) Action // 关闭连接
OnTick() (time.Duration, Action)
}
// ISocketConn 由网络层实现
type ISocketConn interface {
GetParam(key string) interface{}
SetParam(key string, values interface{})
RemoteAddr() string
Ping() error // 需要隔一段时间调用一下建议20s
Write(data []byte) error
Close() error
IsClose() bool
}

View File

@@ -0,0 +1,184 @@
package websocket
import (
"bytes"
"context"
"git.hlsq.asia/mmorpg/service-common/net/socket"
"github.com/panjf2000/gnet/v2"
"github.com/panjf2000/gnet/v2/pkg/logging"
"sync"
"time"
)
// WSServer 实现GNet库接口
type WSServer struct {
eng gnet.Engine
i socket.ISocketServer
logger logging.Logger // 日志
upgradeTimeout time.Duration // 升级超时时间
unUpgradeConn sync.Map
}
func NewWSServer(i socket.ISocketServer, logger logging.Logger, upgradeTimeout time.Duration) *WSServer {
if i == nil {
return nil
}
return &WSServer{
i: i,
logger: logger,
upgradeTimeout: upgradeTimeout,
unUpgradeConn: sync.Map{},
}
}
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 {
return gnet.Run(
s,
addr,
gnet.WithMulticore(multicore),
gnet.WithNumEventLoop(numEventLoop),
gnet.WithTCPNoDelay(tcpNoDelay),
gnet.WithReadBufferCap(readBufferCap),
gnet.WithWriteBufferCap(writeBufferCap),
gnet.WithLockOSThread(lockOSThread),
gnet.WithReusePort(reusePort),
gnet.WithTicker(ticker),
gnet.WithLogger(logger),
)
}
func (s *WSServer) Stop() error {
return s.eng.Stop(context.Background())
}
func (s *WSServer) OnBoot(eng gnet.Engine) gnet.Action {
s.eng = eng
return gnet.None
}
func (s *WSServer) OnShutdown(_ gnet.Engine) {
}
func (s *WSServer) OnOpen(c gnet.Conn) ([]byte, gnet.Action) {
ws := &WSConn{
Conn: c,
isUpgrade: false,
openTime: time.Now().Unix(),
buf: bytes.Buffer{},
logger: s.logger,
wsMessageBuf: wsMessageBuf{
curHeader: nil,
cachedBuf: bytes.Buffer{},
},
param: make(map[string]interface{}),
remoteAddr: c.RemoteAddr().String(),
}
c.SetContext(ws)
s.unUpgradeConn.Store(c.RemoteAddr().String(), ws)
d, a := s.i.OnOpen(ws)
return d, (gnet.Action)(a)
}
// OnClose fires when a connection has been closed.
// The parameter err is the last known connection error.
func (s *WSServer) OnClose(c gnet.Conn, err error) (action gnet.Action) {
s.unUpgradeConn.Delete(c.RemoteAddr().String())
ws, ok := c.Context().(*WSConn)
if ok {
ws.isClose = true
ws.logger.Warnf("connection close, err: %v", err)
return gnet.Action(s.i.OnClose(ws, err))
}
return
}
// OnTraffic fires when a local socket receives data from the peer.
func (s *WSServer) OnTraffic(c gnet.Conn) gnet.Action {
ws := c.Context().(*WSConn)
if action := ws.readBytesBuf(c); action != gnet.None {
return action
}
if !ws.isUpgrade {
data, action := ws.upgrade()
if len(data) > 0 {
s.unUpgradeConn.Delete(c.RemoteAddr().String())
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
}
if msg, err := ws.readWsMessages(); err != nil {
ws.logger.Errorf("read ws messages err: %v", err)
return gnet.Close
} else if msg != nil {
for _, m := range msg {
if socket.OpCode(m.OpCode) == socket.OpPong {
s.i.OnPong(ws)
continue
}
if socket.OpCode(m.OpCode) == socket.OpClose {
return gnet.Close
}
if socket.OpCode(m.OpCode) == socket.OpPing {
continue
}
a := s.i.OnMessage(ws, m.Payload)
if gnet.Action(a) != gnet.None {
return gnet.Action(a)
}
}
}
return gnet.None
}
// OnTick fires immediately after the engine starts and will fire again
// following the duration specified by the delay return value.
func (s *WSServer) OnTick() (delay time.Duration, action gnet.Action) {
now := time.Now().Unix()
delConn := make([]string, 0)
s.unUpgradeConn.Range(func(key, value interface{}) bool {
k, ok := key.(string)
if !ok {
return true
}
v, ok := value.(*WSConn)
if !ok {
return true
}
if now-v.openTime >= int64(s.upgradeTimeout.Seconds()) {
delConn = append(delConn, k)
}
return true
})
for _, k := range delConn {
wsConn, _ := s.unUpgradeConn.LoadAndDelete(k)
if wsConn == nil {
continue
}
v, ok := wsConn.(*WSConn)
if !ok {
continue
}
if err := v.Close(); err != nil {
v.logger.Errorf("upgrade ws time out close socket error: %v", err)
}
}
d, a := s.i.OnTick()
delay = d
action = gnet.Action(a)
return
}

View File

@@ -0,0 +1,202 @@
package websocket
import (
"bufio"
"bytes"
"errors"
"github.com/gobwas/ws"
"github.com/gobwas/ws/wsutil"
"github.com/panjf2000/gnet/v2"
"github.com/panjf2000/gnet/v2/pkg/logging"
"io"
"net/url"
)
// WSConn 实现ISocketConn接口
type WSConn struct {
gnet.Conn
buf bytes.Buffer
logger logging.Logger
isUpgrade bool // 是否已经升级
upgradeResp []byte // 升级响应
isClose bool
param map[string]interface{}
openTime int64 // 开启连接的时间
remoteAddr string // 远程ID地址
wsMessageBuf
}
type wsMessageBuf struct {
curHeader *ws.Header
cachedBuf bytes.Buffer
}
type readWrite struct {
io.Reader
io.Writer
}
func (w *WSConn) readBytesBuf(c gnet.Conn) gnet.Action {
size := c.InboundBuffered()
if size <= 0 {
return gnet.None
}
buf := make([]byte, size)
read, err := c.Read(buf)
if err != nil {
if w.logger != nil {
w.logger.Errorf("ws read bytes buf error", err)
}
return gnet.Close
}
if read < size {
if w.logger != nil {
w.logger.Errorf("read bytes len err! size: %d read: %d", size, read)
}
return gnet.Close
}
w.buf.Write(buf)
return gnet.None
}
func (w *WSConn) upgrade() (data []byte, action gnet.Action) {
buf := &w.buf
tmpReader := bytes.NewReader(buf.Bytes())
oldLen := tmpReader.Len()
result := &bytes.Buffer{}
tempWriter := bufio.NewWriter(result)
var err error = nil
up := ws.Upgrader{
OnRequest: w.OnRequest,
}
_, err = up.Upgrade(readWrite{tmpReader, tempWriter})
skipN := oldLen - tmpReader.Len()
if err != nil {
if errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) { //数据不完整
return
}
buf.Next(skipN)
if w.logger != nil {
w.logger.Errorf("ws upgrade err: %v", err.Error())
}
action = gnet.Close
return
}
buf.Next(skipN)
//if w.logger != nil {
// w.logger.Infof("ws upgrade success conn upgrade websocket protocol!")
//}
_ = tempWriter.Flush()
data = result.Bytes()
w.isUpgrade = true
return
}
func (w *WSConn) readWsMessages() (messages []wsutil.Message, err error) {
in := &w.buf
for {
if w.curHeader == nil {
if in.Len() < ws.MinHeaderSize { //头长度至少是2
return
}
var head ws.Header
//有可能不完整,构建新的 reader 读取 head 读取成功才实际对 in 进行读操作
tmpReader := bytes.NewReader(in.Bytes())
oldLen := tmpReader.Len()
head, err = ws.ReadHeader(tmpReader)
skipN := oldLen - tmpReader.Len()
if err != nil {
if errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) { //数据不完整
return messages, nil
}
in.Next(skipN)
return nil, err
}
_, err = io.CopyN(&w.cachedBuf, in, int64(skipN))
if err != nil {
return
}
w.curHeader = &head
}
dataLen := (int)(w.curHeader.Length)
if dataLen > 0 {
if in.Len() >= dataLen {
_, err = io.CopyN(&w.cachedBuf, in, int64(dataLen))
if err != nil {
return
}
} else { //数据不完整
if w.logger != nil {
w.logger.Debugf("ws read ws message incomplete data", in.Len(), dataLen)
}
return
}
}
if w.curHeader.Fin { //当前 header 已经是一个完整消息
messages, err = wsutil.ReadClientMessage(&w.cachedBuf, messages)
if err != nil {
return nil, err
}
w.cachedBuf.Reset()
}
w.curHeader = nil
}
}
func (w *WSConn) OnRequest(u []byte) error {
parsedURL, err := url.Parse(string(u))
if err != nil {
return err
}
for key, value := range parsedURL.Query() {
w.SetParam(key, value[0])
}
return nil
}
func (w *WSConn) GetParam(key string) interface{} {
return w.param[key]
}
func (w *WSConn) SetParam(key string, values interface{}) {
w.param[key] = values
}
func (w *WSConn) RemoteAddr() string {
return w.remoteAddr
}
func (w *WSConn) Write(data []byte) error {
return w.write(data, ws.OpBinary)
}
func (w *WSConn) Ping() (err error) {
return w.write(make([]byte, 0), ws.OpPing)
}
func (w *WSConn) Close() (err error) {
defer func(Conn gnet.Conn) {
err = Conn.Close()
}(w.Conn)
return w.write(make([]byte, 0), ws.OpClose)
}
func (w *WSConn) IsClose() bool {
return w.isClose
}
func (w *WSConn) write(data []byte, opCode ws.OpCode) error {
if w.isClose {
return errors.New("connection has close")
}
buf := bytes.Buffer{}
if err := wsutil.WriteServerMessage(&buf, opCode, data); err != nil {
return err
}
return w.Conn.AsyncWrite(buf.Bytes(), nil)
}

View File

@@ -0,0 +1,212 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: ./proto/rs/grpc_pb/service_user_grpc.pb.go
// Package mocks is a generated GoMock package.
package mocks
import (
context "context"
reflect "reflect"
grpc_pb "git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
gomock "github.com/golang/mock/gomock"
grpc "google.golang.org/grpc"
)
// MockUserClient is a mock of UserClient interface.
type MockUserClient struct {
ctrl *gomock.Controller
recorder *MockUserClientMockRecorder
}
// MockUserClientMockRecorder is the mock recorder for MockUserClient.
type MockUserClientMockRecorder struct {
mock *MockUserClient
}
// NewMockUserClient creates a new mock instance.
func NewMockUserClient(ctrl *gomock.Controller) *MockUserClient {
mock := &MockUserClient{ctrl: ctrl}
mock.recorder = &MockUserClientMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockUserClient) EXPECT() *MockUserClientMockRecorder {
return m.recorder
}
// GetUserInfo mocks base method.
func (m *MockUserClient) GetUserInfo(ctx context.Context, in *grpc_pb.GetUserInfoReq, opts ...grpc.CallOption) (*grpc_pb.GetUserInfoResp, error) {
m.ctrl.T.Helper()
varargs := []interface{}{ctx, in}
for _, a := range opts {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "GetUserInfo", varargs...)
ret0, _ := ret[0].(*grpc_pb.GetUserInfoResp)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetUserInfo indicates an expected call of GetUserInfo.
func (mr *MockUserClientMockRecorder) GetUserInfo(ctx, in interface{}, opts ...interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
varargs := append([]interface{}{ctx, in}, opts...)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserInfo", reflect.TypeOf((*MockUserClient)(nil).GetUserInfo), varargs...)
}
// PhoneLogin mocks base method.
func (m *MockUserClient) PhoneLogin(ctx context.Context, in *grpc_pb.PhoneLoginReq, opts ...grpc.CallOption) (*grpc_pb.PhoneLoginResp, error) {
m.ctrl.T.Helper()
varargs := []interface{}{ctx, in}
for _, a := range opts {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "PhoneLogin", varargs...)
ret0, _ := ret[0].(*grpc_pb.PhoneLoginResp)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// PhoneLogin indicates an expected call of PhoneLogin.
func (mr *MockUserClientMockRecorder) PhoneLogin(ctx, in interface{}, opts ...interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
varargs := append([]interface{}{ctx, in}, opts...)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PhoneLogin", reflect.TypeOf((*MockUserClient)(nil).PhoneLogin), varargs...)
}
// WxMiniLogin mocks base method.
func (m *MockUserClient) WxMiniLogin(ctx context.Context, in *grpc_pb.WxMiniLoginReq, opts ...grpc.CallOption) (*grpc_pb.WxMiniLoginResp, error) {
m.ctrl.T.Helper()
varargs := []interface{}{ctx, in}
for _, a := range opts {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "WxMiniLogin", varargs...)
ret0, _ := ret[0].(*grpc_pb.WxMiniLoginResp)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// WxMiniLogin indicates an expected call of WxMiniLogin.
func (mr *MockUserClientMockRecorder) WxMiniLogin(ctx, in interface{}, opts ...interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
varargs := append([]interface{}{ctx, in}, opts...)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WxMiniLogin", reflect.TypeOf((*MockUserClient)(nil).WxMiniLogin), varargs...)
}
// MockUserServer is a mock of UserServer interface.
type MockUserServer struct {
ctrl *gomock.Controller
recorder *MockUserServerMockRecorder
}
// MockUserServerMockRecorder is the mock recorder for MockUserServer.
type MockUserServerMockRecorder struct {
mock *MockUserServer
}
// NewMockUserServer creates a new mock instance.
func NewMockUserServer(ctrl *gomock.Controller) *MockUserServer {
mock := &MockUserServer{ctrl: ctrl}
mock.recorder = &MockUserServerMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockUserServer) EXPECT() *MockUserServerMockRecorder {
return m.recorder
}
// GetUserInfo mocks base method.
func (m *MockUserServer) GetUserInfo(arg0 context.Context, arg1 *grpc_pb.GetUserInfoReq) (*grpc_pb.GetUserInfoResp, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetUserInfo", arg0, arg1)
ret0, _ := ret[0].(*grpc_pb.GetUserInfoResp)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetUserInfo indicates an expected call of GetUserInfo.
func (mr *MockUserServerMockRecorder) GetUserInfo(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUserInfo", reflect.TypeOf((*MockUserServer)(nil).GetUserInfo), arg0, arg1)
}
// PhoneLogin mocks base method.
func (m *MockUserServer) PhoneLogin(arg0 context.Context, arg1 *grpc_pb.PhoneLoginReq) (*grpc_pb.PhoneLoginResp, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "PhoneLogin", arg0, arg1)
ret0, _ := ret[0].(*grpc_pb.PhoneLoginResp)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// PhoneLogin indicates an expected call of PhoneLogin.
func (mr *MockUserServerMockRecorder) PhoneLogin(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PhoneLogin", reflect.TypeOf((*MockUserServer)(nil).PhoneLogin), arg0, arg1)
}
// WxMiniLogin mocks base method.
func (m *MockUserServer) WxMiniLogin(arg0 context.Context, arg1 *grpc_pb.WxMiniLoginReq) (*grpc_pb.WxMiniLoginResp, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "WxMiniLogin", arg0, arg1)
ret0, _ := ret[0].(*grpc_pb.WxMiniLoginResp)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// WxMiniLogin indicates an expected call of WxMiniLogin.
func (mr *MockUserServerMockRecorder) WxMiniLogin(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WxMiniLogin", reflect.TypeOf((*MockUserServer)(nil).WxMiniLogin), arg0, arg1)
}
// mustEmbedUnimplementedUserServer mocks base method.
func (m *MockUserServer) mustEmbedUnimplementedUserServer() {
m.ctrl.T.Helper()
m.ctrl.Call(m, "mustEmbedUnimplementedUserServer")
}
// mustEmbedUnimplementedUserServer indicates an expected call of mustEmbedUnimplementedUserServer.
func (mr *MockUserServerMockRecorder) mustEmbedUnimplementedUserServer() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "mustEmbedUnimplementedUserServer", reflect.TypeOf((*MockUserServer)(nil).mustEmbedUnimplementedUserServer))
}
// MockUnsafeUserServer is a mock of UnsafeUserServer interface.
type MockUnsafeUserServer struct {
ctrl *gomock.Controller
recorder *MockUnsafeUserServerMockRecorder
}
// MockUnsafeUserServerMockRecorder is the mock recorder for MockUnsafeUserServer.
type MockUnsafeUserServerMockRecorder struct {
mock *MockUnsafeUserServer
}
// NewMockUnsafeUserServer creates a new mock instance.
func NewMockUnsafeUserServer(ctrl *gomock.Controller) *MockUnsafeUserServer {
mock := &MockUnsafeUserServer{ctrl: ctrl}
mock.recorder = &MockUnsafeUserServerMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockUnsafeUserServer) EXPECT() *MockUnsafeUserServerMockRecorder {
return m.recorder
}
// mustEmbedUnimplementedUserServer mocks base method.
func (m *MockUnsafeUserServer) mustEmbedUnimplementedUserServer() {
m.ctrl.T.Helper()
m.ctrl.Call(m, "mustEmbedUnimplementedUserServer")
}
// mustEmbedUnimplementedUserServer indicates an expected call of mustEmbedUnimplementedUserServer.
func (mr *MockUnsafeUserServerMockRecorder) mustEmbedUnimplementedUserServer() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "mustEmbedUnimplementedUserServer", reflect.TypeOf((*MockUnsafeUserServer)(nil).mustEmbedUnimplementedUserServer))
}

View File

@@ -0,0 +1,342 @@
// 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 (
_ "git.hlsq.asia/mmorpg/service-common/proto/rs/rs_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}
}
type KickUserReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
USN int64 `protobuf:"varint,1,opt,name=USN,proto3" json:"USN,omitempty"`
}
func (x *KickUserReq) Reset() {
*x = KickUserReq{}
if protoimpl.UnsafeEnabled {
mi := &file_service_gateway_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *KickUserReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*KickUserReq) ProtoMessage() {}
func (x *KickUserReq) ProtoReflect() protoreflect.Message {
mi := &file_service_gateway_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 KickUserReq.ProtoReflect.Descriptor instead.
func (*KickUserReq) Descriptor() ([]byte, []int) {
return file_service_gateway_proto_rawDescGZIP(), []int{2}
}
func (x *KickUserReq) GetUSN() int64 {
if x != nil {
return x.USN
}
return 0
}
type KickUserResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *KickUserResp) Reset() {
*x = KickUserResp{}
if protoimpl.UnsafeEnabled {
mi := &file_service_gateway_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *KickUserResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*KickUserResp) ProtoMessage() {}
func (x *KickUserResp) ProtoReflect() protoreflect.Message {
mi := &file_service_gateway_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 KickUserResp.ProtoReflect.Descriptor instead.
func (*KickUserResp) Descriptor() ([]byte, []int) {
return file_service_gateway_proto_rawDescGZIP(), []int{3}
}
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, 0x72, 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, 0x22, 0x1f, 0x0a, 0x0b, 0x4b, 0x69, 0x63, 0x6b, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71,
0x12, 0x10, 0x0a, 0x03, 0x55, 0x53, 0x4e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x55,
0x53, 0x4e, 0x22, 0x0e, 0x0a, 0x0c, 0x4b, 0x69, 0x63, 0x6b, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65,
0x73, 0x70, 0x32, 0x61, 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, 0x12, 0x29, 0x0a, 0x08, 0x4b, 0x69,
0x63, 0x6b, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0c, 0x2e, 0x4b, 0x69, 0x63, 0x6b, 0x55, 0x73, 0x65,
0x72, 0x52, 0x65, 0x71, 0x1a, 0x0d, 0x2e, 0x4b, 0x69, 0x63, 0x6b, 0x55, 0x73, 0x65, 0x72, 0x52,
0x65, 0x73, 0x70, 0x22, 0x00, 0x42, 0x36, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x2e, 0x68, 0x6c, 0x73,
0x71, 0x2e, 0x61, 0x73, 0x69, 0x61, 0x2f, 0x6d, 0x6d, 0x6f, 0x72, 0x70, 0x67, 0x2f, 0x73, 0x65,
0x72, 0x76, 0x69, 0x63, 0x65, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x2f, 0x72, 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, 4)
var file_service_gateway_proto_goTypes = []interface{}{
(*ToClientReq)(nil), // 0: ToClientReq
(*ToClientResp)(nil), // 1: ToClientResp
(*KickUserReq)(nil), // 2: KickUserReq
(*KickUserResp)(nil), // 3: KickUserResp
}
var file_service_gateway_proto_depIdxs = []int32{
0, // 0: Gateway.ToClient:input_type -> ToClientReq
2, // 1: Gateway.KickUser:input_type -> KickUserReq
1, // 2: Gateway.ToClient:output_type -> ToClientResp
3, // 3: Gateway.KickUser:output_type -> KickUserResp
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_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
}
}
file_service_gateway_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*KickUserReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_service_gateway_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*KickUserResp); 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: 4,
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

@@ -0,0 +1,178 @@
// 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)
KickUser(ctx context.Context, in *KickUserReq, opts ...grpc.CallOption) (*KickUserResp, 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
}
func (c *gatewayClient) KickUser(ctx context.Context, in *KickUserReq, opts ...grpc.CallOption) (*KickUserResp, error) {
out := new(KickUserResp)
err := c.cc.Invoke(ctx, "/Gateway/KickUser", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// GatewayServer is the server API for Gateway service.
// All implementations must embed UnimplementedGatewayServer
// for forward compatibility
type GatewayServer interface {
// 发送消息到客户端
ToClient(Gateway_ToClientServer) error
KickUser(context.Context, *KickUserReq) (*KickUserResp, 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) KickUser(context.Context, *KickUserReq) (*KickUserResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method KickUser 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
}
func _Gateway_KickUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(KickUserReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GatewayServer).KickUser(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Gateway/KickUser",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GatewayServer).KickUser(ctx, req.(*KickUserReq))
}
return interceptor(ctx, in, info, handler)
}
// 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{
{
MethodName: "KickUser",
Handler: _Gateway_KickUser_Handler,
},
},
Streams: []grpc.StreamDesc{
{
StreamName: "ToClient",
Handler: _Gateway_ToClient_Handler,
ClientStreams: true,
},
},
Metadata: "service_gateway.proto",
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,847 @@
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: service_qgdzs.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_Qgdzs_GenerateQuestion_0(ctx context.Context, marshaler runtime.Marshaler, client QgdzsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GenerateQuestionReq
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.GenerateQuestion(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Qgdzs_GenerateQuestion_0(ctx context.Context, marshaler runtime.Marshaler, server QgdzsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GenerateQuestionReq
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.GenerateQuestion(ctx, &protoReq)
return msg, metadata, err
}
func request_Qgdzs_RandomGetQuestion_0(ctx context.Context, marshaler runtime.Marshaler, client QgdzsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq RandomGetQuestionReq
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.RandomGetQuestion(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Qgdzs_RandomGetQuestion_0(ctx context.Context, marshaler runtime.Marshaler, server QgdzsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq RandomGetQuestionReq
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.RandomGetQuestion(ctx, &protoReq)
return msg, metadata, err
}
func request_Qgdzs_RandomAnswerQuestion_0(ctx context.Context, marshaler runtime.Marshaler, client QgdzsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq RandomAnswerQuestionReq
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.RandomAnswerQuestion(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Qgdzs_RandomAnswerQuestion_0(ctx context.Context, marshaler runtime.Marshaler, server QgdzsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq RandomAnswerQuestionReq
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.RandomAnswerQuestion(ctx, &protoReq)
return msg, metadata, err
}
func request_Qgdzs_GetAllCategory_0(ctx context.Context, marshaler runtime.Marshaler, client QgdzsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GetAllCategoryReq
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.GetAllCategory(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Qgdzs_GetAllCategory_0(ctx context.Context, marshaler runtime.Marshaler, server QgdzsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GetAllCategoryReq
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.GetAllCategory(ctx, &protoReq)
return msg, metadata, err
}
func request_Qgdzs_CategoryGetQuestion_0(ctx context.Context, marshaler runtime.Marshaler, client QgdzsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq CategoryGetQuestionReq
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.CategoryGetQuestion(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Qgdzs_CategoryGetQuestion_0(ctx context.Context, marshaler runtime.Marshaler, server QgdzsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq CategoryGetQuestionReq
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.CategoryGetQuestion(ctx, &protoReq)
return msg, metadata, err
}
func request_Qgdzs_CategoryAnswerQuestion_0(ctx context.Context, marshaler runtime.Marshaler, client QgdzsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq CategoryAnswerQuestionReq
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.CategoryAnswerQuestion(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Qgdzs_CategoryAnswerQuestion_0(ctx context.Context, marshaler runtime.Marshaler, server QgdzsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq CategoryAnswerQuestionReq
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.CategoryAnswerQuestion(ctx, &protoReq)
return msg, metadata, err
}
func request_Qgdzs_QuicklyGetQuestion_0(ctx context.Context, marshaler runtime.Marshaler, client QgdzsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq QuicklyGetQuestionReq
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.QuicklyGetQuestion(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Qgdzs_QuicklyGetQuestion_0(ctx context.Context, marshaler runtime.Marshaler, server QgdzsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq QuicklyGetQuestionReq
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.QuicklyGetQuestion(ctx, &protoReq)
return msg, metadata, err
}
func request_Qgdzs_QuicklyAnswerQuestion_0(ctx context.Context, marshaler runtime.Marshaler, client QgdzsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq QuicklyAnswerQuestionReq
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.QuicklyAnswerQuestion(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Qgdzs_QuicklyAnswerQuestion_0(ctx context.Context, marshaler runtime.Marshaler, server QgdzsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq QuicklyAnswerQuestionReq
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.QuicklyAnswerQuestion(ctx, &protoReq)
return msg, metadata, err
}
func request_Qgdzs_GetRecord_0(ctx context.Context, marshaler runtime.Marshaler, client QgdzsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GetRecordReq
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.GetRecord(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Qgdzs_GetRecord_0(ctx context.Context, marshaler runtime.Marshaler, server QgdzsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GetRecordReq
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.GetRecord(ctx, &protoReq)
return msg, metadata, err
}
func request_Qgdzs_GetQuestionInfo_0(ctx context.Context, marshaler runtime.Marshaler, client QgdzsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GetQuestionInfoReq
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.GetQuestionInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Qgdzs_GetQuestionInfo_0(ctx context.Context, marshaler runtime.Marshaler, server QgdzsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GetQuestionInfoReq
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.GetQuestionInfo(ctx, &protoReq)
return msg, metadata, err
}
func request_Qgdzs_GetPointRecord_0(ctx context.Context, marshaler runtime.Marshaler, client QgdzsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GetPointRecordReq
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.GetPointRecord(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Qgdzs_GetPointRecord_0(ctx context.Context, marshaler runtime.Marshaler, server QgdzsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GetPointRecordReq
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.GetPointRecord(ctx, &protoReq)
return msg, metadata, err
}
func request_Qgdzs_GetPoint_0(ctx context.Context, marshaler runtime.Marshaler, client QgdzsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GetPointReq
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.GetPoint(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Qgdzs_GetPoint_0(ctx context.Context, marshaler runtime.Marshaler, server QgdzsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq GetPointReq
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.GetPoint(ctx, &protoReq)
return msg, metadata, err
}
// RegisterQgdzsHandlerServer registers the http handlers for service Qgdzs to "mux".
// UnaryRPC :call QgdzsServer 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 RegisterQgdzsHandlerFromEndpoint 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 RegisterQgdzsHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QgdzsServer) error {
mux.Handle(http.MethodPost, pattern_Qgdzs_GenerateQuestion_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, "/.Qgdzs/GenerateQuestion", runtime.WithHTTPPathPattern("/qgdzs/auth/generate_question"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Qgdzs_GenerateQuestion_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_Qgdzs_GenerateQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_RandomGetQuestion_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, "/.Qgdzs/RandomGetQuestion", runtime.WithHTTPPathPattern("/qgdzs/open/random/question"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Qgdzs_RandomGetQuestion_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_Qgdzs_RandomGetQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_RandomAnswerQuestion_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, "/.Qgdzs/RandomAnswerQuestion", runtime.WithHTTPPathPattern("/qgdzs/open/random/answer"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Qgdzs_RandomAnswerQuestion_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_Qgdzs_RandomAnswerQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_GetAllCategory_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, "/.Qgdzs/GetAllCategory", runtime.WithHTTPPathPattern("/qgdzs/open/category/get_category"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Qgdzs_GetAllCategory_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_Qgdzs_GetAllCategory_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_CategoryGetQuestion_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, "/.Qgdzs/CategoryGetQuestion", runtime.WithHTTPPathPattern("/qgdzs/open/category/question"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Qgdzs_CategoryGetQuestion_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_Qgdzs_CategoryGetQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_CategoryAnswerQuestion_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, "/.Qgdzs/CategoryAnswerQuestion", runtime.WithHTTPPathPattern("/qgdzs/open/category/answer"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Qgdzs_CategoryAnswerQuestion_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_Qgdzs_CategoryAnswerQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_QuicklyGetQuestion_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, "/.Qgdzs/QuicklyGetQuestion", runtime.WithHTTPPathPattern("/qgdzs/open/quickly/question"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Qgdzs_QuicklyGetQuestion_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_Qgdzs_QuicklyGetQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_QuicklyAnswerQuestion_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, "/.Qgdzs/QuicklyAnswerQuestion", runtime.WithHTTPPathPattern("/qgdzs/open/quickly/answer"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Qgdzs_QuicklyAnswerQuestion_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_Qgdzs_QuicklyAnswerQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_GetRecord_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, "/.Qgdzs/GetRecord", runtime.WithHTTPPathPattern("/qgdzs/auth/get_record"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Qgdzs_GetRecord_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_Qgdzs_GetRecord_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_GetQuestionInfo_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, "/.Qgdzs/GetQuestionInfo", runtime.WithHTTPPathPattern("/qgdzs/open/get_question_info"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Qgdzs_GetQuestionInfo_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_Qgdzs_GetQuestionInfo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_GetPointRecord_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, "/.Qgdzs/GetPointRecord", runtime.WithHTTPPathPattern("/qgdzs/auth/point/record"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Qgdzs_GetPointRecord_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_Qgdzs_GetPointRecord_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_GetPoint_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, "/.Qgdzs/GetPoint", runtime.WithHTTPPathPattern("/qgdzs/auth/point/info"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Qgdzs_GetPoint_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_Qgdzs_GetPoint_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
// RegisterQgdzsHandlerFromEndpoint is same as RegisterQgdzsHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterQgdzsHandlerFromEndpoint(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 RegisterQgdzsHandler(ctx, mux, conn)
}
// RegisterQgdzsHandler registers the http handlers for service Qgdzs to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterQgdzsHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterQgdzsHandlerClient(ctx, mux, NewQgdzsClient(conn))
}
// RegisterQgdzsHandlerClient registers the http handlers for service Qgdzs
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QgdzsClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QgdzsClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "QgdzsClient" to call the correct interceptors. This client ignores the HTTP middlewares.
func RegisterQgdzsHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QgdzsClient) error {
mux.Handle(http.MethodPost, pattern_Qgdzs_GenerateQuestion_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, "/.Qgdzs/GenerateQuestion", runtime.WithHTTPPathPattern("/qgdzs/auth/generate_question"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Qgdzs_GenerateQuestion_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_GenerateQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_RandomGetQuestion_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, "/.Qgdzs/RandomGetQuestion", runtime.WithHTTPPathPattern("/qgdzs/open/random/question"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Qgdzs_RandomGetQuestion_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_RandomGetQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_RandomAnswerQuestion_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, "/.Qgdzs/RandomAnswerQuestion", runtime.WithHTTPPathPattern("/qgdzs/open/random/answer"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Qgdzs_RandomAnswerQuestion_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_RandomAnswerQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_GetAllCategory_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, "/.Qgdzs/GetAllCategory", runtime.WithHTTPPathPattern("/qgdzs/open/category/get_category"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Qgdzs_GetAllCategory_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_GetAllCategory_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_CategoryGetQuestion_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, "/.Qgdzs/CategoryGetQuestion", runtime.WithHTTPPathPattern("/qgdzs/open/category/question"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Qgdzs_CategoryGetQuestion_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_CategoryGetQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_CategoryAnswerQuestion_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, "/.Qgdzs/CategoryAnswerQuestion", runtime.WithHTTPPathPattern("/qgdzs/open/category/answer"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Qgdzs_CategoryAnswerQuestion_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_CategoryAnswerQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_QuicklyGetQuestion_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, "/.Qgdzs/QuicklyGetQuestion", runtime.WithHTTPPathPattern("/qgdzs/open/quickly/question"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Qgdzs_QuicklyGetQuestion_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_QuicklyGetQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_QuicklyAnswerQuestion_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, "/.Qgdzs/QuicklyAnswerQuestion", runtime.WithHTTPPathPattern("/qgdzs/open/quickly/answer"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Qgdzs_QuicklyAnswerQuestion_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_QuicklyAnswerQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_GetRecord_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, "/.Qgdzs/GetRecord", runtime.WithHTTPPathPattern("/qgdzs/auth/get_record"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Qgdzs_GetRecord_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_GetRecord_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_GetQuestionInfo_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, "/.Qgdzs/GetQuestionInfo", runtime.WithHTTPPathPattern("/qgdzs/open/get_question_info"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Qgdzs_GetQuestionInfo_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_GetQuestionInfo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_GetPointRecord_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, "/.Qgdzs/GetPointRecord", runtime.WithHTTPPathPattern("/qgdzs/auth/point/record"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Qgdzs_GetPointRecord_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_GetPointRecord_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_GetPoint_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, "/.Qgdzs/GetPoint", runtime.WithHTTPPathPattern("/qgdzs/auth/point/info"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Qgdzs_GetPoint_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Qgdzs_GetPoint_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
var (
pattern_Qgdzs_GenerateQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"qgdzs", "auth", "generate_question"}, ""))
pattern_Qgdzs_RandomGetQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"qgdzs", "open", "random", "question"}, ""))
pattern_Qgdzs_RandomAnswerQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"qgdzs", "open", "random", "answer"}, ""))
pattern_Qgdzs_GetAllCategory_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"qgdzs", "open", "category", "get_category"}, ""))
pattern_Qgdzs_CategoryGetQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"qgdzs", "open", "category", "question"}, ""))
pattern_Qgdzs_CategoryAnswerQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"qgdzs", "open", "category", "answer"}, ""))
pattern_Qgdzs_QuicklyGetQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"qgdzs", "open", "quickly", "question"}, ""))
pattern_Qgdzs_QuicklyAnswerQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"qgdzs", "open", "quickly", "answer"}, ""))
pattern_Qgdzs_GetRecord_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"qgdzs", "auth", "get_record"}, ""))
pattern_Qgdzs_GetQuestionInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"qgdzs", "open", "get_question_info"}, ""))
pattern_Qgdzs_GetPointRecord_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"qgdzs", "auth", "point", "record"}, ""))
pattern_Qgdzs_GetPoint_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"qgdzs", "auth", "point", "info"}, ""))
)
var (
forward_Qgdzs_GenerateQuestion_0 = runtime.ForwardResponseMessage
forward_Qgdzs_RandomGetQuestion_0 = runtime.ForwardResponseMessage
forward_Qgdzs_RandomAnswerQuestion_0 = runtime.ForwardResponseMessage
forward_Qgdzs_GetAllCategory_0 = runtime.ForwardResponseMessage
forward_Qgdzs_CategoryGetQuestion_0 = runtime.ForwardResponseMessage
forward_Qgdzs_CategoryAnswerQuestion_0 = runtime.ForwardResponseMessage
forward_Qgdzs_QuicklyGetQuestion_0 = runtime.ForwardResponseMessage
forward_Qgdzs_QuicklyAnswerQuestion_0 = runtime.ForwardResponseMessage
forward_Qgdzs_GetRecord_0 = runtime.ForwardResponseMessage
forward_Qgdzs_GetQuestionInfo_0 = runtime.ForwardResponseMessage
forward_Qgdzs_GetPointRecord_0 = runtime.ForwardResponseMessage
forward_Qgdzs_GetPoint_0 = runtime.ForwardResponseMessage
)

View File

@@ -0,0 +1,535 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v4.25.1
// source: service_qgdzs.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
// QgdzsClient is the client API for Qgdzs 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 QgdzsClient interface {
// 生成题目
GenerateQuestion(ctx context.Context, in *GenerateQuestionReq, opts ...grpc.CallOption) (*GenerateQuestionResp, error)
// ---------- 随机答题 ----------
// 获取题目
RandomGetQuestion(ctx context.Context, in *RandomGetQuestionReq, opts ...grpc.CallOption) (*RandomGetQuestionResp, error)
// 回答题目
RandomAnswerQuestion(ctx context.Context, in *RandomAnswerQuestionReq, opts ...grpc.CallOption) (*RandomAnswerQuestionResp, error)
// ---------- 类目答题 ----------
// 获取所有类目
GetAllCategory(ctx context.Context, in *GetAllCategoryReq, opts ...grpc.CallOption) (*GetAllCategoryResp, error)
// 获取题目
CategoryGetQuestion(ctx context.Context, in *CategoryGetQuestionReq, opts ...grpc.CallOption) (*CategoryGetQuestionResp, error)
// 回答题目
CategoryAnswerQuestion(ctx context.Context, in *CategoryAnswerQuestionReq, opts ...grpc.CallOption) (*CategoryAnswerQuestionResp, error)
// ---------- 快速答题 ----------
// 获取题目
QuicklyGetQuestion(ctx context.Context, in *QuicklyGetQuestionReq, opts ...grpc.CallOption) (*QuicklyGetQuestionResp, error)
// 回答题目
QuicklyAnswerQuestion(ctx context.Context, in *QuicklyAnswerQuestionReq, opts ...grpc.CallOption) (*QuicklyAnswerQuestionResp, error)
// ---------- 答题记录 ----------
// 获取答题记录
GetRecord(ctx context.Context, in *GetRecordReq, opts ...grpc.CallOption) (*GetRecordResp, error)
// 获取具体的题目
GetQuestionInfo(ctx context.Context, in *GetQuestionInfoReq, opts ...grpc.CallOption) (*GetQuestionInfoResp, error)
// ---------- 学识分 ----------
// 获取学识分获取记录
GetPointRecord(ctx context.Context, in *GetPointRecordReq, opts ...grpc.CallOption) (*GetPointRecordResp, error)
// 获取学识分
GetPoint(ctx context.Context, in *GetPointReq, opts ...grpc.CallOption) (*GetPointResp, error)
}
type qgdzsClient struct {
cc grpc.ClientConnInterface
}
func NewQgdzsClient(cc grpc.ClientConnInterface) QgdzsClient {
return &qgdzsClient{cc}
}
func (c *qgdzsClient) GenerateQuestion(ctx context.Context, in *GenerateQuestionReq, opts ...grpc.CallOption) (*GenerateQuestionResp, error) {
out := new(GenerateQuestionResp)
err := c.cc.Invoke(ctx, "/Qgdzs/GenerateQuestion", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *qgdzsClient) RandomGetQuestion(ctx context.Context, in *RandomGetQuestionReq, opts ...grpc.CallOption) (*RandomGetQuestionResp, error) {
out := new(RandomGetQuestionResp)
err := c.cc.Invoke(ctx, "/Qgdzs/RandomGetQuestion", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *qgdzsClient) RandomAnswerQuestion(ctx context.Context, in *RandomAnswerQuestionReq, opts ...grpc.CallOption) (*RandomAnswerQuestionResp, error) {
out := new(RandomAnswerQuestionResp)
err := c.cc.Invoke(ctx, "/Qgdzs/RandomAnswerQuestion", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *qgdzsClient) GetAllCategory(ctx context.Context, in *GetAllCategoryReq, opts ...grpc.CallOption) (*GetAllCategoryResp, error) {
out := new(GetAllCategoryResp)
err := c.cc.Invoke(ctx, "/Qgdzs/GetAllCategory", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *qgdzsClient) CategoryGetQuestion(ctx context.Context, in *CategoryGetQuestionReq, opts ...grpc.CallOption) (*CategoryGetQuestionResp, error) {
out := new(CategoryGetQuestionResp)
err := c.cc.Invoke(ctx, "/Qgdzs/CategoryGetQuestion", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *qgdzsClient) CategoryAnswerQuestion(ctx context.Context, in *CategoryAnswerQuestionReq, opts ...grpc.CallOption) (*CategoryAnswerQuestionResp, error) {
out := new(CategoryAnswerQuestionResp)
err := c.cc.Invoke(ctx, "/Qgdzs/CategoryAnswerQuestion", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *qgdzsClient) QuicklyGetQuestion(ctx context.Context, in *QuicklyGetQuestionReq, opts ...grpc.CallOption) (*QuicklyGetQuestionResp, error) {
out := new(QuicklyGetQuestionResp)
err := c.cc.Invoke(ctx, "/Qgdzs/QuicklyGetQuestion", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *qgdzsClient) QuicklyAnswerQuestion(ctx context.Context, in *QuicklyAnswerQuestionReq, opts ...grpc.CallOption) (*QuicklyAnswerQuestionResp, error) {
out := new(QuicklyAnswerQuestionResp)
err := c.cc.Invoke(ctx, "/Qgdzs/QuicklyAnswerQuestion", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *qgdzsClient) GetRecord(ctx context.Context, in *GetRecordReq, opts ...grpc.CallOption) (*GetRecordResp, error) {
out := new(GetRecordResp)
err := c.cc.Invoke(ctx, "/Qgdzs/GetRecord", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *qgdzsClient) GetQuestionInfo(ctx context.Context, in *GetQuestionInfoReq, opts ...grpc.CallOption) (*GetQuestionInfoResp, error) {
out := new(GetQuestionInfoResp)
err := c.cc.Invoke(ctx, "/Qgdzs/GetQuestionInfo", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *qgdzsClient) GetPointRecord(ctx context.Context, in *GetPointRecordReq, opts ...grpc.CallOption) (*GetPointRecordResp, error) {
out := new(GetPointRecordResp)
err := c.cc.Invoke(ctx, "/Qgdzs/GetPointRecord", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *qgdzsClient) GetPoint(ctx context.Context, in *GetPointReq, opts ...grpc.CallOption) (*GetPointResp, error) {
out := new(GetPointResp)
err := c.cc.Invoke(ctx, "/Qgdzs/GetPoint", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// QgdzsServer is the server API for Qgdzs service.
// All implementations must embed UnimplementedQgdzsServer
// for forward compatibility
type QgdzsServer interface {
// 生成题目
GenerateQuestion(context.Context, *GenerateQuestionReq) (*GenerateQuestionResp, error)
// ---------- 随机答题 ----------
// 获取题目
RandomGetQuestion(context.Context, *RandomGetQuestionReq) (*RandomGetQuestionResp, error)
// 回答题目
RandomAnswerQuestion(context.Context, *RandomAnswerQuestionReq) (*RandomAnswerQuestionResp, error)
// ---------- 类目答题 ----------
// 获取所有类目
GetAllCategory(context.Context, *GetAllCategoryReq) (*GetAllCategoryResp, error)
// 获取题目
CategoryGetQuestion(context.Context, *CategoryGetQuestionReq) (*CategoryGetQuestionResp, error)
// 回答题目
CategoryAnswerQuestion(context.Context, *CategoryAnswerQuestionReq) (*CategoryAnswerQuestionResp, error)
// ---------- 快速答题 ----------
// 获取题目
QuicklyGetQuestion(context.Context, *QuicklyGetQuestionReq) (*QuicklyGetQuestionResp, error)
// 回答题目
QuicklyAnswerQuestion(context.Context, *QuicklyAnswerQuestionReq) (*QuicklyAnswerQuestionResp, error)
// ---------- 答题记录 ----------
// 获取答题记录
GetRecord(context.Context, *GetRecordReq) (*GetRecordResp, error)
// 获取具体的题目
GetQuestionInfo(context.Context, *GetQuestionInfoReq) (*GetQuestionInfoResp, error)
// ---------- 学识分 ----------
// 获取学识分获取记录
GetPointRecord(context.Context, *GetPointRecordReq) (*GetPointRecordResp, error)
// 获取学识分
GetPoint(context.Context, *GetPointReq) (*GetPointResp, error)
mustEmbedUnimplementedQgdzsServer()
}
// UnimplementedQgdzsServer must be embedded to have forward compatible implementations.
type UnimplementedQgdzsServer struct {
}
func (UnimplementedQgdzsServer) GenerateQuestion(context.Context, *GenerateQuestionReq) (*GenerateQuestionResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GenerateQuestion not implemented")
}
func (UnimplementedQgdzsServer) RandomGetQuestion(context.Context, *RandomGetQuestionReq) (*RandomGetQuestionResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method RandomGetQuestion not implemented")
}
func (UnimplementedQgdzsServer) RandomAnswerQuestion(context.Context, *RandomAnswerQuestionReq) (*RandomAnswerQuestionResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method RandomAnswerQuestion not implemented")
}
func (UnimplementedQgdzsServer) GetAllCategory(context.Context, *GetAllCategoryReq) (*GetAllCategoryResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetAllCategory not implemented")
}
func (UnimplementedQgdzsServer) CategoryGetQuestion(context.Context, *CategoryGetQuestionReq) (*CategoryGetQuestionResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method CategoryGetQuestion not implemented")
}
func (UnimplementedQgdzsServer) CategoryAnswerQuestion(context.Context, *CategoryAnswerQuestionReq) (*CategoryAnswerQuestionResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method CategoryAnswerQuestion not implemented")
}
func (UnimplementedQgdzsServer) QuicklyGetQuestion(context.Context, *QuicklyGetQuestionReq) (*QuicklyGetQuestionResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method QuicklyGetQuestion not implemented")
}
func (UnimplementedQgdzsServer) QuicklyAnswerQuestion(context.Context, *QuicklyAnswerQuestionReq) (*QuicklyAnswerQuestionResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method QuicklyAnswerQuestion not implemented")
}
func (UnimplementedQgdzsServer) GetRecord(context.Context, *GetRecordReq) (*GetRecordResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetRecord not implemented")
}
func (UnimplementedQgdzsServer) GetQuestionInfo(context.Context, *GetQuestionInfoReq) (*GetQuestionInfoResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetQuestionInfo not implemented")
}
func (UnimplementedQgdzsServer) GetPointRecord(context.Context, *GetPointRecordReq) (*GetPointRecordResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetPointRecord not implemented")
}
func (UnimplementedQgdzsServer) GetPoint(context.Context, *GetPointReq) (*GetPointResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetPoint not implemented")
}
func (UnimplementedQgdzsServer) mustEmbedUnimplementedQgdzsServer() {}
// UnsafeQgdzsServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to QgdzsServer will
// result in compilation errors.
type UnsafeQgdzsServer interface {
mustEmbedUnimplementedQgdzsServer()
}
func RegisterQgdzsServer(s grpc.ServiceRegistrar, srv QgdzsServer) {
s.RegisterService(&Qgdzs_ServiceDesc, srv)
}
func _Qgdzs_GenerateQuestion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GenerateQuestionReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QgdzsServer).GenerateQuestion(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Qgdzs/GenerateQuestion",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QgdzsServer).GenerateQuestion(ctx, req.(*GenerateQuestionReq))
}
return interceptor(ctx, in, info, handler)
}
func _Qgdzs_RandomGetQuestion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RandomGetQuestionReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QgdzsServer).RandomGetQuestion(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Qgdzs/RandomGetQuestion",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QgdzsServer).RandomGetQuestion(ctx, req.(*RandomGetQuestionReq))
}
return interceptor(ctx, in, info, handler)
}
func _Qgdzs_RandomAnswerQuestion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RandomAnswerQuestionReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QgdzsServer).RandomAnswerQuestion(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Qgdzs/RandomAnswerQuestion",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QgdzsServer).RandomAnswerQuestion(ctx, req.(*RandomAnswerQuestionReq))
}
return interceptor(ctx, in, info, handler)
}
func _Qgdzs_GetAllCategory_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetAllCategoryReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QgdzsServer).GetAllCategory(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Qgdzs/GetAllCategory",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QgdzsServer).GetAllCategory(ctx, req.(*GetAllCategoryReq))
}
return interceptor(ctx, in, info, handler)
}
func _Qgdzs_CategoryGetQuestion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CategoryGetQuestionReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QgdzsServer).CategoryGetQuestion(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Qgdzs/CategoryGetQuestion",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QgdzsServer).CategoryGetQuestion(ctx, req.(*CategoryGetQuestionReq))
}
return interceptor(ctx, in, info, handler)
}
func _Qgdzs_CategoryAnswerQuestion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CategoryAnswerQuestionReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QgdzsServer).CategoryAnswerQuestion(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Qgdzs/CategoryAnswerQuestion",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QgdzsServer).CategoryAnswerQuestion(ctx, req.(*CategoryAnswerQuestionReq))
}
return interceptor(ctx, in, info, handler)
}
func _Qgdzs_QuicklyGetQuestion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(QuicklyGetQuestionReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QgdzsServer).QuicklyGetQuestion(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Qgdzs/QuicklyGetQuestion",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QgdzsServer).QuicklyGetQuestion(ctx, req.(*QuicklyGetQuestionReq))
}
return interceptor(ctx, in, info, handler)
}
func _Qgdzs_QuicklyAnswerQuestion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(QuicklyAnswerQuestionReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QgdzsServer).QuicklyAnswerQuestion(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Qgdzs/QuicklyAnswerQuestion",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QgdzsServer).QuicklyAnswerQuestion(ctx, req.(*QuicklyAnswerQuestionReq))
}
return interceptor(ctx, in, info, handler)
}
func _Qgdzs_GetRecord_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetRecordReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QgdzsServer).GetRecord(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Qgdzs/GetRecord",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QgdzsServer).GetRecord(ctx, req.(*GetRecordReq))
}
return interceptor(ctx, in, info, handler)
}
func _Qgdzs_GetQuestionInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetQuestionInfoReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QgdzsServer).GetQuestionInfo(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Qgdzs/GetQuestionInfo",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QgdzsServer).GetQuestionInfo(ctx, req.(*GetQuestionInfoReq))
}
return interceptor(ctx, in, info, handler)
}
func _Qgdzs_GetPointRecord_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetPointRecordReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QgdzsServer).GetPointRecord(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Qgdzs/GetPointRecord",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QgdzsServer).GetPointRecord(ctx, req.(*GetPointRecordReq))
}
return interceptor(ctx, in, info, handler)
}
func _Qgdzs_GetPoint_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetPointReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QgdzsServer).GetPoint(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Qgdzs/GetPoint",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QgdzsServer).GetPoint(ctx, req.(*GetPointReq))
}
return interceptor(ctx, in, info, handler)
}
// Qgdzs_ServiceDesc is the grpc.ServiceDesc for Qgdzs service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Qgdzs_ServiceDesc = grpc.ServiceDesc{
ServiceName: "Qgdzs",
HandlerType: (*QgdzsServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "GenerateQuestion",
Handler: _Qgdzs_GenerateQuestion_Handler,
},
{
MethodName: "RandomGetQuestion",
Handler: _Qgdzs_RandomGetQuestion_Handler,
},
{
MethodName: "RandomAnswerQuestion",
Handler: _Qgdzs_RandomAnswerQuestion_Handler,
},
{
MethodName: "GetAllCategory",
Handler: _Qgdzs_GetAllCategory_Handler,
},
{
MethodName: "CategoryGetQuestion",
Handler: _Qgdzs_CategoryGetQuestion_Handler,
},
{
MethodName: "CategoryAnswerQuestion",
Handler: _Qgdzs_CategoryAnswerQuestion_Handler,
},
{
MethodName: "QuicklyGetQuestion",
Handler: _Qgdzs_QuicklyGetQuestion_Handler,
},
{
MethodName: "QuicklyAnswerQuestion",
Handler: _Qgdzs_QuicklyAnswerQuestion_Handler,
},
{
MethodName: "GetRecord",
Handler: _Qgdzs_GetRecord_Handler,
},
{
MethodName: "GetQuestionInfo",
Handler: _Qgdzs_GetQuestionInfo_Handler,
},
{
MethodName: "GetPointRecord",
Handler: _Qgdzs_GetPointRecord_Handler,
},
{
MethodName: "GetPoint",
Handler: _Qgdzs_GetPoint_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "service_qgdzs.proto",
}

View File

@@ -0,0 +1,555 @@
// 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 (
_ "git.hlsq.asia/mmorpg/service-common/proto/rs/rs_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
UniqueNo int64 `protobuf:"varint,2,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) 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, 0x72, 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, 0x38, 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,
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, 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, 0x36, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x2e, 0x68, 0x6c, 0x73, 0x71, 0x2e, 0x61, 0x73, 0x69,
0x61, 0x2f, 0x6d, 0x6d, 0x6f, 0x72, 0x70, 0x67, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 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

@@ -0,0 +1,212 @@
// 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

@@ -0,0 +1,518 @@
// 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 (
_ "git.hlsq.asia/mmorpg/service-common/proto/rs/rs_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)
)
// ---------- PhoneLogin ----------
type PhoneLoginReq 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 *PhoneLoginReq) Reset() {
*x = PhoneLoginReq{}
if protoimpl.UnsafeEnabled {
mi := &file_service_user_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PhoneLoginReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PhoneLoginReq) ProtoMessage() {}
func (x *PhoneLoginReq) 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 PhoneLoginReq.ProtoReflect.Descriptor instead.
func (*PhoneLoginReq) Descriptor() ([]byte, []int) {
return file_service_user_proto_rawDescGZIP(), []int{0}
}
func (x *PhoneLoginReq) GetPhone() string {
if x != nil {
return x.Phone
}
return ""
}
func (x *PhoneLoginReq) GetCode() string {
if x != nil {
return x.Code
}
return ""
}
type PhoneLoginResp 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 *PhoneLoginResp) Reset() {
*x = PhoneLoginResp{}
if protoimpl.UnsafeEnabled {
mi := &file_service_user_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PhoneLoginResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PhoneLoginResp) ProtoMessage() {}
func (x *PhoneLoginResp) 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 PhoneLoginResp.ProtoReflect.Descriptor instead.
func (*PhoneLoginResp) Descriptor() ([]byte, []int) {
return file_service_user_proto_rawDescGZIP(), []int{1}
}
func (x *PhoneLoginResp) GetUSN() int64 {
if x != nil {
return x.USN
}
return 0
}
func (x *PhoneLoginResp) GetName() string {
if x != nil {
return x.Name
}
return ""
}
// ---------- WxMiniLogin ----------
type WxMiniLoginReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Code string `protobuf:"bytes,1,opt,name=Code,json=code,proto3" json:"Code,omitempty"` // 微信小程序登录凭证
}
func (x *WxMiniLoginReq) Reset() {
*x = WxMiniLoginReq{}
if protoimpl.UnsafeEnabled {
mi := &file_service_user_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *WxMiniLoginReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*WxMiniLoginReq) ProtoMessage() {}
func (x *WxMiniLoginReq) 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 WxMiniLoginReq.ProtoReflect.Descriptor instead.
func (*WxMiniLoginReq) Descriptor() ([]byte, []int) {
return file_service_user_proto_rawDescGZIP(), []int{2}
}
func (x *WxMiniLoginReq) GetCode() string {
if x != nil {
return x.Code
}
return ""
}
type WxMiniLoginResp 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 *WxMiniLoginResp) Reset() {
*x = WxMiniLoginResp{}
if protoimpl.UnsafeEnabled {
mi := &file_service_user_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *WxMiniLoginResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*WxMiniLoginResp) ProtoMessage() {}
func (x *WxMiniLoginResp) 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 WxMiniLoginResp.ProtoReflect.Descriptor instead.
func (*WxMiniLoginResp) Descriptor() ([]byte, []int) {
return file_service_user_proto_rawDescGZIP(), []int{3}
}
func (x *WxMiniLoginResp) GetUSN() int64 {
if x != nil {
return x.USN
}
return 0
}
func (x *WxMiniLoginResp) GetName() string {
if x != nil {
return x.Name
}
return ""
}
// ---------- GetUserInfo ----------
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[4]
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[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 GetUserInfoReq.ProtoReflect.Descriptor instead.
func (*GetUserInfoReq) Descriptor() ([]byte, []int) {
return file_service_user_proto_rawDescGZIP(), []int{4}
}
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[5]
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[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 GetUserInfoResp.ProtoReflect.Descriptor instead.
func (*GetUserInfoResp) Descriptor() ([]byte, []int) {
return file_service_user_proto_rawDescGZIP(), []int{5}
}
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, 0x72, 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, 0x39, 0x0a, 0x0d, 0x50, 0x68, 0x6f, 0x6e, 0x65, 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, 0x36,
0x0a, 0x0e, 0x50, 0x68, 0x6f, 0x6e, 0x65, 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, 0x24, 0x0a, 0x0e, 0x57, 0x78, 0x4d, 0x69, 0x6e, 0x69,
0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x22, 0x37, 0x0a, 0x0f,
0x57, 0x78, 0x4d, 0x69, 0x6e, 0x69, 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, 0xb9, 0x01, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x2f, 0x0a, 0x0a, 0x50,
0x68, 0x6f, 0x6e, 0x65, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x0e, 0x2e, 0x50, 0x68, 0x6f, 0x6e,
0x65, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x50, 0x68, 0x6f, 0x6e,
0x65, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x12, 0x32, 0x0a, 0x0b,
0x57, 0x78, 0x4d, 0x69, 0x6e, 0x69, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x0f, 0x2e, 0x57, 0x78,
0x4d, 0x69, 0x6e, 0x69, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x10, 0x2e, 0x57,
0x78, 0x4d, 0x69, 0x6e, 0x69, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00,
0x12, 0x4c, 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, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x3a, 0x01, 0x2a, 0x22, 0x0f, 0x2f,
0x75, 0x73, 0x65, 0x72, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2f, 0x69, 0x6e, 0x66, 0x6f, 0x42, 0x36,
0x5a, 0x34, 0x67, 0x69, 0x74, 0x2e, 0x68, 0x6c, 0x73, 0x71, 0x2e, 0x61, 0x73, 0x69, 0x61, 0x2f,
0x6d, 0x6d, 0x6f, 0x72, 0x70, 0x67, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2d, 0x63,
0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 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, 6)
var file_service_user_proto_goTypes = []interface{}{
(*PhoneLoginReq)(nil), // 0: PhoneLoginReq
(*PhoneLoginResp)(nil), // 1: PhoneLoginResp
(*WxMiniLoginReq)(nil), // 2: WxMiniLoginReq
(*WxMiniLoginResp)(nil), // 3: WxMiniLoginResp
(*GetUserInfoReq)(nil), // 4: GetUserInfoReq
(*GetUserInfoResp)(nil), // 5: GetUserInfoResp
}
var file_service_user_proto_depIdxs = []int32{
0, // 0: User.PhoneLogin:input_type -> PhoneLoginReq
2, // 1: User.WxMiniLogin:input_type -> WxMiniLoginReq
4, // 2: User.GetUserInfo:input_type -> GetUserInfoReq
1, // 3: User.PhoneLogin:output_type -> PhoneLoginResp
3, // 4: User.WxMiniLogin:output_type -> WxMiniLoginResp
5, // 5: User.GetUserInfo:output_type -> GetUserInfoResp
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_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.(*PhoneLoginReq); 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.(*PhoneLoginResp); 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.(*WxMiniLoginReq); 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.(*WxMiniLoginResp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_service_user_proto_msgTypes[4].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[5].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: 6,
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

@@ -0,0 +1,154 @@
// 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/auth/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/auth/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, 2, 2}, []string{"user", "auth", "info"}, ""))
)
var (
forward_User_GetUserInfo_0 = runtime.ForwardResponseMessage
)

View File

@@ -0,0 +1,179 @@
// 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 {
PhoneLogin(ctx context.Context, in *PhoneLoginReq, opts ...grpc.CallOption) (*PhoneLoginResp, error)
WxMiniLogin(ctx context.Context, in *WxMiniLoginReq, opts ...grpc.CallOption) (*WxMiniLoginResp, 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) PhoneLogin(ctx context.Context, in *PhoneLoginReq, opts ...grpc.CallOption) (*PhoneLoginResp, error) {
out := new(PhoneLoginResp)
err := c.cc.Invoke(ctx, "/User/PhoneLogin", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *userClient) WxMiniLogin(ctx context.Context, in *WxMiniLoginReq, opts ...grpc.CallOption) (*WxMiniLoginResp, error) {
out := new(WxMiniLoginResp)
err := c.cc.Invoke(ctx, "/User/WxMiniLogin", 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 {
PhoneLogin(context.Context, *PhoneLoginReq) (*PhoneLoginResp, error)
WxMiniLogin(context.Context, *WxMiniLoginReq) (*WxMiniLoginResp, error)
// 获取用户信息
GetUserInfo(context.Context, *GetUserInfoReq) (*GetUserInfoResp, error)
mustEmbedUnimplementedUserServer()
}
// UnimplementedUserServer must be embedded to have forward compatible implementations.
type UnimplementedUserServer struct {
}
func (UnimplementedUserServer) PhoneLogin(context.Context, *PhoneLoginReq) (*PhoneLoginResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method PhoneLogin not implemented")
}
func (UnimplementedUserServer) WxMiniLogin(context.Context, *WxMiniLoginReq) (*WxMiniLoginResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method WxMiniLogin 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_PhoneLogin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(PhoneLoginReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserServer).PhoneLogin(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/User/PhoneLogin",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServer).PhoneLogin(ctx, req.(*PhoneLoginReq))
}
return interceptor(ctx, in, info, handler)
}
func _User_WxMiniLogin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(WxMiniLoginReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserServer).WxMiniLogin(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/User/WxMiniLogin",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServer).WxMiniLogin(ctx, req.(*WxMiniLoginReq))
}
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: "PhoneLogin",
Handler: _User_PhoneLogin_Handler,
},
{
MethodName: "WxMiniLogin",
Handler: _User_WxMiniLogin_Handler,
},
{
MethodName: "GetUserInfo",
Handler: _User_GetUserInfo_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "service_user.proto",
}

View File

@@ -0,0 +1,153 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.32.0
// protoc v4.25.1
// source: rs_common.proto
package rs_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_rs_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_rs_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_rs_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_rs_common_proto protoreflect.FileDescriptor
var file_rs_common_proto_rawDesc = []byte{
0x0a, 0x0f, 0x72, 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, 0x38, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x2e, 0x68, 0x6c, 0x73, 0x71,
0x2e, 0x61, 0x73, 0x69, 0x61, 0x2f, 0x6d, 0x6d, 0x6f, 0x72, 0x70, 0x67, 0x2f, 0x73, 0x65, 0x72,
0x76, 0x69, 0x63, 0x65, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x2f, 0x72, 0x73, 0x2f, 0x72, 0x73, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_rs_common_proto_rawDescOnce sync.Once
file_rs_common_proto_rawDescData = file_rs_common_proto_rawDesc
)
func file_rs_common_proto_rawDescGZIP() []byte {
file_rs_common_proto_rawDescOnce.Do(func() {
file_rs_common_proto_rawDescData = protoimpl.X.CompressGZIP(file_rs_common_proto_rawDescData)
})
return file_rs_common_proto_rawDescData
}
var file_rs_common_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_rs_common_proto_goTypes = []interface{}{
(*ErrorInfo)(nil), // 0: ErrorInfo
}
var file_rs_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_rs_common_proto_init() }
func file_rs_common_proto_init() {
if File_rs_common_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_rs_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_rs_common_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_rs_common_proto_goTypes,
DependencyIndexes: file_rs_common_proto_depIdxs,
MessageInfos: file_rs_common_proto_msgTypes,
}.Build()
File_rs_common_proto = out.File
file_rs_common_proto_rawDesc = nil
file_rs_common_proto_goTypes = nil
file_rs_common_proto_depIdxs = nil
}

View File

@@ -0,0 +1,64 @@
// 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"
)
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_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, 0x42, 0x38, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x2e, 0x68, 0x6c, 0x73, 0x71, 0x2e, 0x61, 0x73,
0x69, 0x61, 0x2f, 0x6d, 0x6d, 0x6f, 0x72, 0x70, 0x67, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63,
0x65, 0x2d, 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_goTypes = []interface{}{}
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
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_ss_common_proto_rawDesc,
NumEnums: 0,
NumMessages: 0,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_ss_common_proto_goTypes,
DependencyIndexes: file_ss_common_proto_depIdxs,
}.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
}

527
proto/ss/ss_pb/action.pb.go Normal file
View File

@@ -0,0 +1,527 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.32.0
// protoc v4.25.1
// source: action.proto
package ss_pb
import (
_ "git.hlsq.asia/mmorpg/service-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)
)
// MESSAGE_ID_ACTION
type ActionID int32
const (
ActionID_ACTION_ID_INVALID ActionID = 0
ActionID_ACTION_ID_MOVE ActionID = 1 // 移动
ActionID_ACTION_ID_ATTACK ActionID = 2 // 攻击
)
// Enum value maps for ActionID.
var (
ActionID_name = map[int32]string{
0: "ACTION_ID_INVALID",
1: "ACTION_ID_MOVE",
2: "ACTION_ID_ATTACK",
}
ActionID_value = map[string]int32{
"ACTION_ID_INVALID": 0,
"ACTION_ID_MOVE": 1,
"ACTION_ID_ATTACK": 2,
}
)
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_INVALID
}
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, 0x73, 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, 0x4b, 0x0a, 0x08, 0x41,
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x44, 0x12, 0x15, 0x0a, 0x11, 0x41, 0x43, 0x54, 0x49, 0x4f,
0x4e, 0x5f, 0x49, 0x44, 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x10, 0x00, 0x12, 0x12,
0x0a, 0x0e, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x49, 0x44, 0x5f, 0x4d, 0x4f, 0x56, 0x45,
0x10, 0x01, 0x12, 0x14, 0x0a, 0x10, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x49, 0x44, 0x5f,
0x41, 0x54, 0x54, 0x41, 0x43, 0x4b, 0x10, 0x02, 0x42, 0x34, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x2e,
0x68, 0x6c, 0x73, 0x71, 0x2e, 0x61, 0x73, 0x69, 0x61, 0x2f, 0x6d, 0x6d, 0x6f, 0x72, 0x70, 0x67,
0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x73, 0x2f, 0x73, 0x73, 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
}

233
proto/ss/ss_pb/define.pb.go Normal file
View File

@@ -0,0 +1,233 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.32.0
// protoc v4.25.1
// source: define.proto
package ss_pb
import (
_ "git.hlsq.asia/mmorpg/service-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 MessageID int32
const (
MessageID_MESSAGE_ID_INVALID MessageID = 0
MessageID_MESSAGE_ID_KICK_OUT MessageID = 1 // 服务器踢人
MessageID_MESSAGE_ID_QUEUE_UP MessageID = 2 // 排队中
MessageID_MESSAGE_ID_LOGIN_SUCCESS MessageID = 3 // 登录成功
MessageID_MESSAGE_ID_ENTER_INSTANCE MessageID = 101 // 进入副本
MessageID_MESSAGE_ID_ACTION MessageID = 102 // 指令
MessageID_MESSAGE_ID_POSITION MessageID = 103 // 位置更新
)
// Enum value maps for MessageID.
var (
MessageID_name = map[int32]string{
0: "MESSAGE_ID_INVALID",
1: "MESSAGE_ID_KICK_OUT",
2: "MESSAGE_ID_QUEUE_UP",
3: "MESSAGE_ID_LOGIN_SUCCESS",
101: "MESSAGE_ID_ENTER_INSTANCE",
102: "MESSAGE_ID_ACTION",
103: "MESSAGE_ID_POSITION",
}
MessageID_value = map[string]int32{
"MESSAGE_ID_INVALID": 0,
"MESSAGE_ID_KICK_OUT": 1,
"MESSAGE_ID_QUEUE_UP": 2,
"MESSAGE_ID_LOGIN_SUCCESS": 3,
"MESSAGE_ID_ENTER_INSTANCE": 101,
"MESSAGE_ID_ACTION": 102,
"MESSAGE_ID_POSITION": 103,
}
)
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, 0x73, 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, 0xc2, 0x01, 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, 0x17, 0x0a, 0x13, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47,
0x45, 0x5f, 0x49, 0x44, 0x5f, 0x4b, 0x49, 0x43, 0x4b, 0x5f, 0x4f, 0x55, 0x54, 0x10, 0x01, 0x12,
0x17, 0x0a, 0x13, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45, 0x5f, 0x49, 0x44, 0x5f, 0x51, 0x55,
0x45, 0x55, 0x45, 0x5f, 0x55, 0x50, 0x10, 0x02, 0x12, 0x1c, 0x0a, 0x18, 0x4d, 0x45, 0x53, 0x53,
0x41, 0x47, 0x45, 0x5f, 0x49, 0x44, 0x5f, 0x4c, 0x4f, 0x47, 0x49, 0x4e, 0x5f, 0x53, 0x55, 0x43,
0x43, 0x45, 0x53, 0x53, 0x10, 0x03, 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, 0x65, 0x12, 0x15, 0x0a, 0x11, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45,
0x5f, 0x49, 0x44, 0x5f, 0x41, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0x66, 0x12, 0x17, 0x0a, 0x13,
0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45, 0x5f, 0x49, 0x44, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54,
0x49, 0x4f, 0x4e, 0x10, 0x67, 0x42, 0x34, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x2e, 0x68, 0x6c, 0x73,
0x71, 0x2e, 0x61, 0x73, 0x69, 0x61, 0x2f, 0x6d, 0x6d, 0x6f, 0x72, 0x70, 0x67, 0x2f, 0x73, 0x65,
0x72, 0x76, 0x69, 0x63, 0x65, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x2f, 0x73, 0x73, 0x2f, 0x73, 0x73, 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

@@ -0,0 +1,350 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.32.0
// protoc v4.25.1
// source: service.proto
package ss_pb
import (
_ "git.hlsq.asia/mmorpg/service-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)
)
// MESSAGE_ID_KICK_OUT
type KickOutID int32
const (
KickOutID_KICK_OUT_ID_INVALID KickOutID = 0
KickOutID_KICK_OUT_ID_DUPLICATE_LOGIN KickOutID = 1 // 重复登录
KickOutID_KICK_OUT_ID_SERVER_BUSY KickOutID = 2 // 服务器繁忙
KickOutID_KICK_OUT_ID_SERVER_CLOSE KickOutID = 3 // 服务器关闭
KickOutID_KICK_OUT_ID_QUEUE_UP_FULL KickOutID = 4 // 排队上限
KickOutID_KICK_OUT_ID_TOKEN_INVALID KickOutID = 5 // Token无效
)
// Enum value maps for KickOutID.
var (
KickOutID_name = map[int32]string{
0: "KICK_OUT_ID_INVALID",
1: "KICK_OUT_ID_DUPLICATE_LOGIN",
2: "KICK_OUT_ID_SERVER_BUSY",
3: "KICK_OUT_ID_SERVER_CLOSE",
4: "KICK_OUT_ID_QUEUE_UP_FULL",
5: "KICK_OUT_ID_TOKEN_INVALID",
}
KickOutID_value = map[string]int32{
"KICK_OUT_ID_INVALID": 0,
"KICK_OUT_ID_DUPLICATE_LOGIN": 1,
"KICK_OUT_ID_SERVER_BUSY": 2,
"KICK_OUT_ID_SERVER_CLOSE": 3,
"KICK_OUT_ID_QUEUE_UP_FULL": 4,
"KICK_OUT_ID_TOKEN_INVALID": 5,
}
)
func (x KickOutID) Enum() *KickOutID {
p := new(KickOutID)
*p = x
return p
}
func (x KickOutID) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (KickOutID) Descriptor() protoreflect.EnumDescriptor {
return file_service_proto_enumTypes[0].Descriptor()
}
func (KickOutID) Type() protoreflect.EnumType {
return &file_service_proto_enumTypes[0]
}
func (x KickOutID) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use KickOutID.Descriptor instead.
func (KickOutID) EnumDescriptor() ([]byte, []int) {
return file_service_proto_rawDescGZIP(), []int{0}
}
type S2C_KickOut struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ID KickOutID `protobuf:"varint,1,opt,name=ID,proto3,enum=KickOutID" json:"ID,omitempty"`
}
func (x *S2C_KickOut) Reset() {
*x = S2C_KickOut{}
if protoimpl.UnsafeEnabled {
mi := &file_service_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *S2C_KickOut) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*S2C_KickOut) ProtoMessage() {}
func (x *S2C_KickOut) ProtoReflect() protoreflect.Message {
mi := &file_service_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 S2C_KickOut.ProtoReflect.Descriptor instead.
func (*S2C_KickOut) Descriptor() ([]byte, []int) {
return file_service_proto_rawDescGZIP(), []int{0}
}
func (x *S2C_KickOut) GetID() KickOutID {
if x != nil {
return x.ID
}
return KickOutID_KICK_OUT_ID_INVALID
}
// MESSAGE_ID_QUEUE_UP
type S2C_QueueUp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
QueueUpCount int32 `protobuf:"varint,1,opt,name=QueueUpCount,proto3" json:"QueueUpCount,omitempty"` // 排队人数
}
func (x *S2C_QueueUp) Reset() {
*x = S2C_QueueUp{}
if protoimpl.UnsafeEnabled {
mi := &file_service_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *S2C_QueueUp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*S2C_QueueUp) ProtoMessage() {}
func (x *S2C_QueueUp) ProtoReflect() protoreflect.Message {
mi := &file_service_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_QueueUp.ProtoReflect.Descriptor instead.
func (*S2C_QueueUp) Descriptor() ([]byte, []int) {
return file_service_proto_rawDescGZIP(), []int{1}
}
func (x *S2C_QueueUp) GetQueueUpCount() int32 {
if x != nil {
return x.QueueUpCount
}
return 0
}
// MESSAGE_ID_LOGIN_SUCCESS
type S2C_LoginSuccess struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
InstanceID int32 `protobuf:"varint,1,opt,name=InstanceID,proto3" json:"InstanceID,omitempty"` // 副本ID
}
func (x *S2C_LoginSuccess) Reset() {
*x = S2C_LoginSuccess{}
if protoimpl.UnsafeEnabled {
mi := &file_service_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *S2C_LoginSuccess) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*S2C_LoginSuccess) ProtoMessage() {}
func (x *S2C_LoginSuccess) ProtoReflect() protoreflect.Message {
mi := &file_service_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 S2C_LoginSuccess.ProtoReflect.Descriptor instead.
func (*S2C_LoginSuccess) Descriptor() ([]byte, []int) {
return file_service_proto_rawDescGZIP(), []int{2}
}
func (x *S2C_LoginSuccess) GetInstanceID() int32 {
if x != nil {
return x.InstanceID
}
return 0
}
var File_service_proto protoreflect.FileDescriptor
var file_service_proto_rawDesc = []byte{
0x0a, 0x0d, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 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, 0x29, 0x0a, 0x0b, 0x53, 0x32, 0x43, 0x5f, 0x4b, 0x69, 0x63, 0x6b, 0x4f, 0x75, 0x74, 0x12,
0x1a, 0x0a, 0x02, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x4b, 0x69,
0x63, 0x6b, 0x4f, 0x75, 0x74, 0x49, 0x44, 0x52, 0x02, 0x49, 0x44, 0x22, 0x31, 0x0a, 0x0b, 0x53,
0x32, 0x43, 0x5f, 0x51, 0x75, 0x65, 0x75, 0x65, 0x55, 0x70, 0x12, 0x22, 0x0a, 0x0c, 0x51, 0x75,
0x65, 0x75, 0x65, 0x55, 0x70, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05,
0x52, 0x0c, 0x51, 0x75, 0x65, 0x75, 0x65, 0x55, 0x70, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x32,
0x0a, 0x10, 0x53, 0x32, 0x43, 0x5f, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x53, 0x75, 0x63, 0x63, 0x65,
0x73, 0x73, 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, 0x2a, 0xbe, 0x01, 0x0a, 0x09, 0x4b, 0x69, 0x63, 0x6b, 0x4f, 0x75, 0x74, 0x49, 0x44,
0x12, 0x17, 0x0a, 0x13, 0x4b, 0x49, 0x43, 0x4b, 0x5f, 0x4f, 0x55, 0x54, 0x5f, 0x49, 0x44, 0x5f,
0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x10, 0x00, 0x12, 0x1f, 0x0a, 0x1b, 0x4b, 0x49, 0x43,
0x4b, 0x5f, 0x4f, 0x55, 0x54, 0x5f, 0x49, 0x44, 0x5f, 0x44, 0x55, 0x50, 0x4c, 0x49, 0x43, 0x41,
0x54, 0x45, 0x5f, 0x4c, 0x4f, 0x47, 0x49, 0x4e, 0x10, 0x01, 0x12, 0x1b, 0x0a, 0x17, 0x4b, 0x49,
0x43, 0x4b, 0x5f, 0x4f, 0x55, 0x54, 0x5f, 0x49, 0x44, 0x5f, 0x53, 0x45, 0x52, 0x56, 0x45, 0x52,
0x5f, 0x42, 0x55, 0x53, 0x59, 0x10, 0x02, 0x12, 0x1c, 0x0a, 0x18, 0x4b, 0x49, 0x43, 0x4b, 0x5f,
0x4f, 0x55, 0x54, 0x5f, 0x49, 0x44, 0x5f, 0x53, 0x45, 0x52, 0x56, 0x45, 0x52, 0x5f, 0x43, 0x4c,
0x4f, 0x53, 0x45, 0x10, 0x03, 0x12, 0x1d, 0x0a, 0x19, 0x4b, 0x49, 0x43, 0x4b, 0x5f, 0x4f, 0x55,
0x54, 0x5f, 0x49, 0x44, 0x5f, 0x51, 0x55, 0x45, 0x55, 0x45, 0x5f, 0x55, 0x50, 0x5f, 0x46, 0x55,
0x4c, 0x4c, 0x10, 0x04, 0x12, 0x1d, 0x0a, 0x19, 0x4b, 0x49, 0x43, 0x4b, 0x5f, 0x4f, 0x55, 0x54,
0x5f, 0x49, 0x44, 0x5f, 0x54, 0x4f, 0x4b, 0x45, 0x4e, 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49,
0x44, 0x10, 0x05, 0x42, 0x34, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x2e, 0x68, 0x6c, 0x73, 0x71, 0x2e,
0x61, 0x73, 0x69, 0x61, 0x2f, 0x6d, 0x6d, 0x6f, 0x72, 0x70, 0x67, 0x2f, 0x73, 0x65, 0x72, 0x76,
0x69, 0x63, 0x65, 0x2d, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x2f, 0x73, 0x73, 0x2f, 0x73, 0x73, 0x5f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x33,
}
var (
file_service_proto_rawDescOnce sync.Once
file_service_proto_rawDescData = file_service_proto_rawDesc
)
func file_service_proto_rawDescGZIP() []byte {
file_service_proto_rawDescOnce.Do(func() {
file_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_service_proto_rawDescData)
})
return file_service_proto_rawDescData
}
var file_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_service_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_service_proto_goTypes = []interface{}{
(KickOutID)(0), // 0: KickOutID
(*S2C_KickOut)(nil), // 1: S2C_KickOut
(*S2C_QueueUp)(nil), // 2: S2C_QueueUp
(*S2C_LoginSuccess)(nil), // 3: S2C_LoginSuccess
}
var file_service_proto_depIdxs = []int32{
0, // 0: S2C_KickOut.ID:type_name -> KickOutID
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_service_proto_init() }
func file_service_proto_init() {
if File_service_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*S2C_KickOut); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*S2C_QueueUp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*S2C_LoginSuccess); 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_proto_rawDesc,
NumEnums: 1,
NumMessages: 3,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_service_proto_goTypes,
DependencyIndexes: file_service_proto_depIdxs,
EnumInfos: file_service_proto_enumTypes,
MessageInfos: file_service_proto_msgTypes,
}.Build()
File_service_proto = out.File
file_service_proto_rawDesc = nil
file_service_proto_goTypes = nil
file_service_proto_depIdxs = nil
}

63
utils/error.go Normal file
View File

@@ -0,0 +1,63 @@
package utils
import (
"errors"
"fmt"
"runtime"
"strconv"
"strings"
)
type WrapErrors struct {
message string
trace []string
}
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{}
}
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{}
}
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)
}

39
utils/jwt.go Normal file
View File

@@ -0,0 +1,39 @@
package utils
import (
"errors"
"github.com/golang-jwt/jwt/v5"
"time"
)
type Claims struct {
USN int64 `json:"usn"`
jwt.RegisteredClaims
}
func GenToken(usn int64, secret string, expires time.Duration) (string, error) {
token := jwt.NewWithClaims(jwt.SigningMethodHS256, Claims{
USN: usn,
RegisteredClaims: jwt.RegisteredClaims{
ExpiresAt: jwt.NewNumericDate(time.Now().Add(expires)),
},
})
return token.SignedString([]byte(secret))
}
func ParseToken(tokenString string, secret string) (*Claims, error) {
if tokenString == "" {
return nil, errors.New("invalid token")
}
claims := &Claims{}
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
}

28
utils/number.go Normal file
View File

@@ -0,0 +1,28 @@
package utils
import (
"math/rand"
"strconv"
)
// RandInt 生成 [min, max] 范围内的随机整数
func RandInt(min, max int) int {
if min > max {
min, max = max, min
}
return rand.Intn(max-min+1) + min
}
// StringToInt64 converts a string to int64, returns 0 if failed
func StringToInt64(s string) int64 {
i, err := strconv.ParseInt(s, 10, 64)
if err != nil {
return 0
}
return i
}
// Int64ToString converts int64 to string
func Int64ToString(i int64) string {
return strconv.FormatInt(i, 10)
}

29
utils/session.go Normal file
View File

@@ -0,0 +1,29 @@
package utils
import (
"context"
"google.golang.org/grpc/metadata"
)
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 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
}

24
utils/snowflake.go Normal file
View File

@@ -0,0 +1,24 @@
package utils
import (
"github.com/bwmarrin/snowflake"
"log"
)
var instance *snowflake.Node
func InitSnowflake(node int64) *snowflake.Node {
n, err := snowflake.NewNode(node)
if err != nil {
log.Fatalf("create snowflake's node failed: %v", err)
}
instance = n
return instance
}
func SnowflakeInstance() *snowflake.Node {
if instance == nil {
log.Fatal("snowflake's not init")
}
return instance
}

34
utils/test.go Normal file
View File

@@ -0,0 +1,34 @@
package utils
import (
"bytes"
"encoding/json"
"git.hlsq.asia/mmorpg/service-common/net/http/http_resp"
"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 *http_resp.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"])
}

41
utils/workerpool.go Normal file
View File

@@ -0,0 +1,41 @@
package utils
import (
"sync"
)
// DefaultMaxWorkers 默认并发数
const DefaultMaxWorkers = 32
// WorkerPool 并发执行一批任务。
func WorkerPool(tasks []interface{}, taskFunc func(interface{}), maxWorkers ...int) {
if len(tasks) == 0 {
return
}
workers := DefaultMaxWorkers
if len(maxWorkers) > 0 && maxWorkers[0] > 0 {
workers = maxWorkers[0]
}
if workers > len(tasks) {
workers = len(tasks)
}
jobs := make(chan interface{}, len(tasks))
var wg sync.WaitGroup
for i := 0; i < workers; i++ {
wg.Add(1)
go func() {
defer wg.Done()
for task := range jobs {
taskFunc(task)
}
}()
}
for _, task := range tasks {
jobs <- task
}
close(jobs)
wg.Wait()
}