feat 初始化
This commit is contained in:
25
PORTS.md
Normal file
25
PORTS.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# Ports
|
||||
|
||||
端口分配记录
|
||||
|
||||
---
|
||||
gateway 18500-18599
|
||||
---
|
||||
third-party 18600-18699
|
||||
---
|
||||
scene 18700-18799
|
||||
---
|
||||
user 18800-18899
|
||||
---
|
||||
post 18900-18999
|
||||
---
|
||||
announcement 19000-19099
|
||||
---
|
||||
court 19100-19199
|
||||
---
|
||||
admin 19200-19299
|
||||
---
|
||||
court-physical 19300-19399
|
||||
---
|
||||
court-timer 19400-19499
|
||||
---
|
||||
@@ -178,7 +178,7 @@ user-service/
|
||||
|
||||
common
|
||||
1. 在 `discover\common\define.go` 定义服务发现
|
||||
2. 在 `net\grpc\service` 实现客户端发现
|
||||
2. 在 `net\grpc\grpcclient` 实现客户端发现
|
||||
|
||||
public
|
||||
1. 在 `Proto\RpcServer\sources` 定义gRPC服务
|
||||
@@ -188,7 +188,6 @@ db
|
||||
|
||||
quickly
|
||||
1. `MySQL Model` 增加数据库配置
|
||||
2. `更新Common` 增加项目配置
|
||||
|
||||
gateway
|
||||
1. 在 `internal\net\http_gateway\router.go` 定义路由
|
||||
1. 在 `internal\net\httpgateway\router.go` 定义路由
|
||||
@@ -18,7 +18,8 @@ type MetricConfig struct {
|
||||
Port int32 `yaml:"port"`
|
||||
} `yaml:"prometheus"`
|
||||
Jaeger *struct {
|
||||
Endpoint string `yaml:"endpoint"`
|
||||
Endpoint string `yaml:"endpoint"`
|
||||
SamplingRate float64 `yaml:"samplingRate"`
|
||||
} `yaml:"jaeger"`
|
||||
}
|
||||
|
||||
@@ -76,3 +77,14 @@ type AddressConfig struct {
|
||||
Address string `yaml:"address"`
|
||||
Port int32 `yaml:"port"`
|
||||
}
|
||||
|
||||
type CosConfig struct {
|
||||
SecretID string `yaml:"secretID"`
|
||||
SecretKey string `yaml:"secretKey"`
|
||||
BucketURL string `yaml:"bucketURL"`
|
||||
}
|
||||
|
||||
type SensitiveWordConfig struct {
|
||||
SourceType string `yaml:"sourceType"`
|
||||
Source string `yaml:"sourceURL"`
|
||||
}
|
||||
|
||||
@@ -4,13 +4,30 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/spf13/viper"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
const (
|
||||
envConfigPrefix = "XH_G"
|
||||
)
|
||||
|
||||
var (
|
||||
currentEnv EnvType // 当前环境变量
|
||||
currentEnvOnce sync.Once
|
||||
currentCommit string // 当前提交的CommitID
|
||||
currentCommitOnce sync.Once
|
||||
)
|
||||
|
||||
type EnvType string
|
||||
|
||||
const (
|
||||
EnvDev EnvType = "dev"
|
||||
EnvTest EnvType = "test"
|
||||
EnvProd EnvType = "prod"
|
||||
)
|
||||
|
||||
// LoadConfig 加载并返回应用配置
|
||||
func LoadConfig[T any](configDir string, configPtr *T) (*T, error) {
|
||||
v := viper.New()
|
||||
@@ -40,3 +57,27 @@ func LoadConfig[T any](configDir string, configPtr *T) (*T, error) {
|
||||
fmt.Printf("Configuration loading completed: %v\n", string(marshal))
|
||||
return configPtr, nil
|
||||
}
|
||||
|
||||
// Env 获取环境
|
||||
func Env() EnvType {
|
||||
currentEnvOnce.Do(func() {
|
||||
if v, ok := os.LookupEnv(envConfigPrefix + "_ENV"); ok {
|
||||
currentEnv = EnvType(v)
|
||||
} else {
|
||||
currentEnv = EnvDev
|
||||
}
|
||||
})
|
||||
return currentEnv
|
||||
}
|
||||
|
||||
// Commit 获取提交ID
|
||||
func Commit() string {
|
||||
currentCommitOnce.Do(func() {
|
||||
if v, ok := os.LookupEnv(envConfigPrefix + "_COMMIT"); ok {
|
||||
currentCommit = v
|
||||
} else {
|
||||
currentCommit = "unknown"
|
||||
}
|
||||
})
|
||||
return currentCommit
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ func getConsumer(cfg *config.KafkaConfig, appName string) (sarama.ConsumerGroup,
|
||||
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.AutoCommit.Enable = true
|
||||
conf.Consumer.Offsets.Initial = sarama.OffsetOldest
|
||||
return sarama.NewConsumerGroup(cfg.Brokers, appName, conf)
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ import (
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
otelcodes "go.opentelemetry.io/otel/codes"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
"reflect"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -31,10 +33,13 @@ type Consumer struct {
|
||||
func (c *Consumer) Consume(t []Topic) {
|
||||
for {
|
||||
topicArr := make([]string, 0)
|
||||
handlerMap := make(map[string]Topic)
|
||||
handlerMap := make(map[string]*sync.Pool)
|
||||
for _, v := range t {
|
||||
topicArr = append(topicArr, v.Name())
|
||||
handlerMap[v.Name()] = v
|
||||
typ := reflect.ValueOf(v).Elem().Type()
|
||||
handlerMap[v.Name()] = &sync.Pool{New: func() interface{} {
|
||||
return reflect.New(typ).Interface()
|
||||
}}
|
||||
}
|
||||
err := client.consumer.Consume(c.ctx, topicArr, &handler{
|
||||
handler: handlerMap,
|
||||
@@ -48,13 +53,13 @@ func (c *Consumer) Consume(t []Topic) {
|
||||
|
||||
func (c *Consumer) Stop() error {
|
||||
c.cancel()
|
||||
return nil
|
||||
return client.consumer.Close()
|
||||
}
|
||||
|
||||
type Handler func(context.Context, []byte) error
|
||||
|
||||
type handler struct {
|
||||
handler map[string]Topic
|
||||
handler map[string]*sync.Pool
|
||||
}
|
||||
|
||||
func (h *handler) Setup(_ sarama.ConsumerGroupSession) error {
|
||||
@@ -67,39 +72,72 @@ func (h *handler) Cleanup(sess sarama.ConsumerGroupSession) error {
|
||||
}
|
||||
|
||||
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")
|
||||
for {
|
||||
select {
|
||||
case message, ok := <-claim.Messages():
|
||||
if ok {
|
||||
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"))
|
||||
}
|
||||
pool := h.handler[message.Topic]
|
||||
if pool == nil {
|
||||
span.SetStatus(otelcodes.Error, "handler not found")
|
||||
span.End()
|
||||
return utils.ErrorsWrap(errors.New("handler not found"))
|
||||
}
|
||||
span.SetAttributes(attribute.String("kafka.topic", message.Topic))
|
||||
span.SetAttributes(attribute.String("kafka.message", string(message.Value)))
|
||||
|
||||
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")
|
||||
}
|
||||
newCb := pool.Get().(Topic)
|
||||
if err := json.Unmarshal(message.Value, newCb); err != nil {
|
||||
releaseTopicObject(pool, newCb)
|
||||
span.SetStatus(otelcodes.Error, "handler json.Unmarshal error")
|
||||
span.End()
|
||||
return utils.ErrorsWrap(err, "handler json.Unmarshal error")
|
||||
}
|
||||
|
||||
if err := 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())),
|
||||
))
|
||||
if err := func() (err error) {
|
||||
defer func() {
|
||||
if e := recover(); e != nil {
|
||||
span.SetStatus(otelcodes.Error, fmt.Sprintf("%v", e))
|
||||
span.End()
|
||||
err = fmt.Errorf("kafka handler panic: %v", e)
|
||||
}
|
||||
}()
|
||||
if err = newCb.OnMessage(ctx); err != nil {
|
||||
if stack, ok := err.(interface{ StackTrace() string }); ok {
|
||||
span.AddEvent("Stack Trace", trace.WithAttributes(
|
||||
attribute.String("stack.trace", fmt.Sprintf("%v", stack.StackTrace())),
|
||||
))
|
||||
}
|
||||
span.SetStatus(otelcodes.Error, err.Error())
|
||||
span.End()
|
||||
log.Errorf("kafka handler error: %v", err)
|
||||
err = utils.ErrorsWrap(err, "kafka handler error")
|
||||
}
|
||||
return
|
||||
}(); err != nil {
|
||||
releaseTopicObject(pool, newCb)
|
||||
return err
|
||||
}
|
||||
|
||||
sess.MarkMessage(message, "")
|
||||
releaseTopicObject(pool, newCb)
|
||||
span.End()
|
||||
}
|
||||
span.SetStatus(otelcodes.Error, err.Error())
|
||||
span.End()
|
||||
return utils.ErrorsWrap(err, "kafka handler error")
|
||||
case <-sess.Context().Done():
|
||||
log.Warnf("kafka session done, reason: %v", sess.Context().Err())
|
||||
sess.Commit()
|
||||
return sess.Context().Err()
|
||||
}
|
||||
|
||||
sess.MarkMessage(message, "")
|
||||
span.End()
|
||||
}
|
||||
sess.Commit()
|
||||
return nil
|
||||
}
|
||||
|
||||
// 回收Topic对象
|
||||
func releaseTopicObject(pool *sync.Pool, obj Topic) {
|
||||
v := reflect.ValueOf(obj).Elem()
|
||||
v.Set(reflect.Zero(v.Type()))
|
||||
pool.Put(obj)
|
||||
}
|
||||
|
||||
func consumerError() {
|
||||
|
||||
@@ -3,26 +3,39 @@ package kafka
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/IBM/sarama"
|
||||
"go.opentelemetry.io/otel"
|
||||
otelcodes "go.opentelemetry.io/otel/codes"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func NewProducer() *Producer {
|
||||
return &Producer{}
|
||||
var ProduceTimeoutError = errors.New("kafka producer timeout")
|
||||
|
||||
func NewProducer(key int64) *Producer {
|
||||
return &Producer{
|
||||
key: key,
|
||||
}
|
||||
}
|
||||
|
||||
type Producer struct {
|
||||
key int64
|
||||
}
|
||||
|
||||
func (c *Producer) Produce(ctx context.Context, data Topic) {
|
||||
func (c *Producer) Produce(ctx context.Context, data Topic) error {
|
||||
marshal, _ := json.Marshal(data)
|
||||
msg := &sarama.ProducerMessage{
|
||||
Topic: data.Name(),
|
||||
Key: sarama.StringEncoder(strconv.FormatInt(c.key, 10)),
|
||||
Value: sarama.ByteEncoder(marshal),
|
||||
Headers: NewCarrier().Inject(ctx),
|
||||
}
|
||||
client.producer.Input() <- msg
|
||||
select {
|
||||
case client.producer.Input() <- msg:
|
||||
return nil
|
||||
case <-ctx.Done():
|
||||
return ProduceTimeoutError
|
||||
}
|
||||
}
|
||||
|
||||
func producerError() {
|
||||
|
||||
@@ -6,43 +6,3 @@ type Topic interface {
|
||||
Name() string
|
||||
OnMessage(context.Context) error
|
||||
}
|
||||
|
||||
type TopicQuestionAnswer struct {
|
||||
MessageSn int64 `json:"messageSn"`
|
||||
USN int64 `json:"usn"`
|
||||
QuestionSn int64 `json:"questionSn"`
|
||||
QuestionAnswer string `json:"questionAnswer"`
|
||||
Answer string `json:"answer"`
|
||||
}
|
||||
|
||||
func (t *TopicQuestionAnswer) Name() string {
|
||||
return "qgdzs.question.answer"
|
||||
}
|
||||
|
||||
func (t *TopicQuestionAnswer) OnMessage(_ context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type TopicAddPoint struct {
|
||||
MessageSn int64 `json:"messageSn"`
|
||||
Source AddPointSource `json:"source"`
|
||||
USN int64 `json:"usn"`
|
||||
Point int64 `json:"point"`
|
||||
}
|
||||
|
||||
type AddPointSource int32
|
||||
|
||||
const (
|
||||
AddPointSourceUnKnown AddPointSource = 0
|
||||
AddPointSourceRandom AddPointSource = 1
|
||||
AddPointSourceCategory AddPointSource = 2
|
||||
AddPointSourceQuickly AddPointSource = 3
|
||||
)
|
||||
|
||||
func (t *TopicAddPoint) Name() string {
|
||||
return "qgdzs.user.point"
|
||||
}
|
||||
|
||||
func (t *TopicAddPoint) OnMessage(_ context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -4,8 +4,17 @@ import (
|
||||
"context"
|
||||
"git.hlsq.asia/alex/service-common/config"
|
||||
"git.hlsq.asia/alex/service-common/log"
|
||||
"go.mongodb.org/mongo-driver/event"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"go.mongodb.org/mongo-driver/mongo/readpref"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Colors
|
||||
const (
|
||||
Reset = "\033[0m"
|
||||
BrightGreen = "\033[92m"
|
||||
)
|
||||
|
||||
type DBName string
|
||||
@@ -25,12 +34,27 @@ func Init(cfg map[string]*config.MongoConfig) error {
|
||||
|
||||
func initOneClient(cfg *config.MongoConfig) (*mongo.Client, error) {
|
||||
opts := options.Client().
|
||||
ApplyURI(cfg.URI)
|
||||
ApplyURI(cfg.URI).
|
||||
SetMonitor(&event.CommandMonitor{
|
||||
Started: func(ctx context.Context, startedEvent *event.CommandStartedEvent) {
|
||||
log.Infof(BrightGreen+"[MongoDB] Started, Command: %v"+Reset, startedEvent.Command.String())
|
||||
},
|
||||
Failed: func(ctx context.Context, failedEvent *event.CommandFailedEvent) {
|
||||
log.Errorf(BrightGreen+"[MongoDB] [%v] Failed, Failure: %v"+Reset, failedEvent.Duration, failedEvent.Failure)
|
||||
},
|
||||
})
|
||||
|
||||
client, err := mongo.Connect(context.Background(), opts)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
client, err := mongo.Connect(ctx, opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err = client.Ping(ctx, readpref.Primary()); err != nil {
|
||||
_ = client.Disconnect(context.Background())
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return client, nil
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ func initOneDB(cfg *config.MySQLConfig) (*gorm.DB, error) {
|
||||
mysql.Open(cfg.Dsn),
|
||||
&gorm.Config{
|
||||
TranslateError: true,
|
||||
Logger: logger.Default.LogMode(parseLogLevel(cfg.LogLevel)),
|
||||
Logger: NewGormLogger(parseLogLevel(cfg.LogLevel)),
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
84
db/mysql/log.go
Normal file
84
db/mysql/log.go
Normal file
@@ -0,0 +1,84 @@
|
||||
package mysql
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.hlsq.asia/alex/service-common/log"
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.uber.org/zap"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/logger"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Colors
|
||||
const (
|
||||
Reset = "\033[0m"
|
||||
Blue = "\033[34m"
|
||||
)
|
||||
|
||||
type GormLogger struct {
|
||||
logLevel logger.LogLevel
|
||||
logger *zap.SugaredLogger
|
||||
}
|
||||
|
||||
func NewGormLogger(level logger.LogLevel) *GormLogger {
|
||||
return &GormLogger{
|
||||
logLevel: level,
|
||||
logger: log.GetLogger().
|
||||
WithOptions(zap.AddCallerSkip(5)).
|
||||
Named("GORM"),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GormLogger) LogMode(level logger.LogLevel) logger.Interface {
|
||||
newLogger := *l
|
||||
newLogger.logLevel = level
|
||||
return &newLogger
|
||||
}
|
||||
|
||||
func (l *GormLogger) Info(ctx context.Context, msg string, data ...interface{}) {
|
||||
if l.logLevel >= logger.Info {
|
||||
l.logger.Infof(Blue+msg+Reset, data...)
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GormLogger) Warn(ctx context.Context, msg string, data ...interface{}) {
|
||||
if l.logLevel >= logger.Warn {
|
||||
l.logger.Warnf(Blue+msg+Reset, data...)
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GormLogger) Error(ctx context.Context, msg string, data ...interface{}) {
|
||||
if l.logLevel >= logger.Error {
|
||||
l.logger.Errorf(Blue+msg+Reset, data...)
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (sql string, rowsAffected int64), err error) {
|
||||
if l.logLevel <= logger.Silent {
|
||||
return
|
||||
}
|
||||
|
||||
elapsed := time.Since(begin)
|
||||
sql, rows := fc()
|
||||
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
l.logger.Errorf(Blue+"[SLOW SQL] [%v] [rows:%v] [error: %v] %v"+Reset, elapsed, rows, err.Error(), sql)
|
||||
l.SlowLog(ctx, elapsed, sql)
|
||||
} else if elapsed > 50*time.Millisecond {
|
||||
l.logger.Warnf(Blue+"[SLOW SQL] [%v] [rows:%v] %v"+Reset, elapsed, rows, sql)
|
||||
l.SlowLog(ctx, elapsed, sql)
|
||||
} else {
|
||||
l.logger.Infof(Blue+"[%v] [rows:%v] %v"+Reset, elapsed, rows, sql)
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GormLogger) SlowLog(ctx context.Context, elapsed time.Duration, sql string) {
|
||||
_, span := otel.Tracer("common.db.mysql").Start(ctx, "mysql.slow")
|
||||
defer span.End()
|
||||
span.SetAttributes(attribute.String("elapsed", fmt.Sprintf("%v", elapsed)))
|
||||
span.SetAttributes(attribute.String("sql", sql))
|
||||
}
|
||||
@@ -48,3 +48,11 @@ func (c *CacheClient) Get(ctx context.Context, key string, dst interface{}) bool
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *CacheClient) Exists(ctx context.Context, key ...string) bool {
|
||||
n, err := c.cli.Exists(ctx, key...).Result()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return n > 0
|
||||
}
|
||||
|
||||
@@ -5,13 +5,12 @@ import (
|
||||
"git.hlsq.asia/alex/service-common/config"
|
||||
"git.hlsq.asia/alex/service-common/log"
|
||||
"github.com/redis/go-redis/v9"
|
||||
"time"
|
||||
)
|
||||
|
||||
var instance *Client
|
||||
|
||||
type Client struct {
|
||||
cli *redis.Client
|
||||
*redis.Client
|
||||
}
|
||||
|
||||
func Init(cfg *config.RedisConfig) error {
|
||||
@@ -21,7 +20,7 @@ func Init(cfg *config.RedisConfig) error {
|
||||
DB: cfg.DB,
|
||||
})
|
||||
instance = &Client{
|
||||
cli: client,
|
||||
Client: client,
|
||||
}
|
||||
cacheInstance = &CacheClient{
|
||||
cli: client,
|
||||
@@ -35,8 +34,8 @@ func Init(cfg *config.RedisConfig) error {
|
||||
}
|
||||
|
||||
func Close() error {
|
||||
if instance != nil && instance.cli != nil {
|
||||
return instance.cli.Close()
|
||||
if instance != nil && instance.Client != nil {
|
||||
return instance.Client.Close()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -44,43 +43,3 @@ func Close() error {
|
||||
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...)
|
||||
}
|
||||
|
||||
@@ -10,23 +10,37 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
KeyDiscover = "xh-discover"
|
||||
KeyDiscover = "/discover"
|
||||
KeyDiscoverService = KeyDiscover + "/service"
|
||||
KeyDiscoverInstance = KeyDiscover + "/instance"
|
||||
)
|
||||
|
||||
var (
|
||||
KeyDiscoverServiceNameGateway = "gateway" // 网关服
|
||||
KeyDiscoverServiceNameScene = "scene" // 场景服
|
||||
KeyDiscoverServiceNameUser = "user" // 用户中心
|
||||
KeyDiscoverServiceNameQgdzs = "qgdzs" // 奇怪的知识-服务端
|
||||
KeyDiscoverServiceNameGateway = "01-gateway" // 网关服
|
||||
KeyDiscoverServiceNameScene = "02-scene" // 场景服
|
||||
KeyDiscoverServiceNameUser = "03-user" // 用户中心
|
||||
KeyDiscoverServiceNameThirdParty = "04-third-party" // 三方登录服
|
||||
KeyDiscoverServiceNamePost = "05-post" // 推送服
|
||||
KeyDiscoverServiceNameAnnouncement = "06-announcement" // 公告服
|
||||
KeyDiscoverServiceNameCourt = "07-court" // 球场服
|
||||
KeyDiscoverServiceNameAdmin = "08-admin" // 后台服
|
||||
KeyDiscoverServiceNameCourtPhysical = "09-court-physical" // 线下球场服
|
||||
KeyDiscoverServiceNameTimer = "10-timer" // 定时任务服(只起一个)
|
||||
KeyDiscoverServiceNameQgdzs = "11-qgdzs" // 奇怪的知识
|
||||
)
|
||||
|
||||
var (
|
||||
KeyDiscoverGateway = KeyDiscoverService + "/" + KeyDiscoverServiceNameGateway // 网关服
|
||||
KeyDiscoverScene = KeyDiscoverService + "/" + KeyDiscoverServiceNameScene // 场景服
|
||||
KeyDiscoverUser = KeyDiscoverService + "/" + KeyDiscoverServiceNameUser // 用户中心
|
||||
KeyDiscoverQgdzs = KeyDiscoverService + "/" + KeyDiscoverServiceNameQgdzs // 奇怪的知识-服务端
|
||||
KeyDiscoverGateway = KeyDiscoverService + "/" + KeyDiscoverServiceNameGateway // 网关服
|
||||
KeyDiscoverScene = KeyDiscoverService + "/" + KeyDiscoverServiceNameScene // 场景服
|
||||
KeyDiscoverUser = KeyDiscoverService + "/" + KeyDiscoverServiceNameUser // 用户中心
|
||||
KeyDiscoverThirdParty = KeyDiscoverService + "/" + KeyDiscoverServiceNameThirdParty // 三方登录服
|
||||
KeyDiscoverPost = KeyDiscoverService + "/" + KeyDiscoverServiceNamePost // 推送服
|
||||
KeyDiscoverAnnouncement = KeyDiscoverService + "/" + KeyDiscoverServiceNameAnnouncement // 公告服
|
||||
KeyDiscoverCourt = KeyDiscoverService + "/" + KeyDiscoverServiceNameCourt // 球场服
|
||||
KeyDiscoverAdmin = KeyDiscoverService + "/" + KeyDiscoverServiceNameAdmin // 后台服
|
||||
KeyDiscoverCourtPhysical = KeyDiscoverService + "/" + KeyDiscoverServiceNameCourtPhysical // 线下球场服
|
||||
KeyDiscoverTimer = KeyDiscoverService + "/" + KeyDiscoverServiceNameTimer // 定时任务服(只起一个)
|
||||
KeyDiscoverQgdzs = KeyDiscoverService + "/" + KeyDiscoverServiceNameQgdzs // 奇怪的知识
|
||||
)
|
||||
|
||||
// ServiceProvider 服务提供者
|
||||
|
||||
@@ -83,20 +83,20 @@ func Listen(ready *sync.WaitGroup) {
|
||||
// 服务发生变化
|
||||
func onServerChange(t mvccpb.Event_EventType, key, value string) {
|
||||
split := strings.Split(key, "/")
|
||||
if len(split) != 4 {
|
||||
if len(split) != 5 {
|
||||
return
|
||||
}
|
||||
switch t {
|
||||
case clientv3.EventTypePut:
|
||||
onCBByType(common.ListenerTypeNewServer, &common.ServiceProvider{
|
||||
Target: common.KeyDiscoverService + "/" + split[2],
|
||||
SID: utils.StringToInt64(split[3]),
|
||||
Target: common.KeyDiscoverService + "/" + split[3],
|
||||
SID: utils.StringToInt64(split[4]),
|
||||
Addr: value,
|
||||
})
|
||||
case clientv3.EventTypeDelete:
|
||||
onCBByType(common.ListenerTypeCloseServer, &common.ServiceProvider{
|
||||
Target: common.KeyDiscoverService + "/" + split[2],
|
||||
SID: utils.StringToInt64(split[3]),
|
||||
Target: common.KeyDiscoverService + "/" + split[3],
|
||||
SID: utils.StringToInt64(split[4]),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -104,21 +104,21 @@ func onServerChange(t mvccpb.Event_EventType, key, value string) {
|
||||
// 副本发生变化
|
||||
func onInstanceChange(t mvccpb.Event_EventType, key, value string, preKv *mvccpb.KeyValue) {
|
||||
split := strings.Split(key, "/")
|
||||
if len(split) != 4 {
|
||||
if len(split) != 5 {
|
||||
return
|
||||
}
|
||||
instanceID, _ := strconv.Atoi(split[2])
|
||||
instanceID, _ := strconv.Atoi(split[3])
|
||||
switch t {
|
||||
case clientv3.EventTypePut:
|
||||
onCBByType(common.ListenerTypeNewInstance, &common.InstanceProvider{
|
||||
InstanceID: instanceID,
|
||||
UniqueNo: utils.StringToInt64(split[3]),
|
||||
UniqueNo: utils.StringToInt64(split[4]),
|
||||
SID: utils.StringToInt64(value),
|
||||
})
|
||||
case clientv3.EventTypeDelete:
|
||||
onCBByType(common.ListenerTypeCloseInstance, &common.InstanceProvider{
|
||||
InstanceID: instanceID,
|
||||
UniqueNo: utils.StringToInt64(split[3]),
|
||||
UniqueNo: utils.StringToInt64(split[4]),
|
||||
SID: utils.StringToInt64(string(preKv.Value)),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -42,6 +42,15 @@ func FindServerAll(target string) map[int64]*grpc.ClientConn {
|
||||
return make(map[int64]*grpc.ClientConn)
|
||||
}
|
||||
|
||||
func FindServerAllSid(target string) []int64 {
|
||||
serverMU.RLock()
|
||||
defer serverMU.RUnlock()
|
||||
if v, ok := conn[target]; ok {
|
||||
return v.LoadAllSid()
|
||||
}
|
||||
return make([]int64, 0)
|
||||
}
|
||||
|
||||
// RegisterGrpcServer 注册服务提供者
|
||||
func RegisterGrpcServer(target string, sid int64, addr string, ttl int64) error {
|
||||
serverMU.Lock()
|
||||
|
||||
45
go.mod
45
go.mod
@@ -4,16 +4,16 @@ 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/shopspring/decimal v1.4.0
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
||||
github.com/sony/sonyflake/v2 v2.2.0
|
||||
github.com/spf13/viper v1.21.0
|
||||
github.com/stretchr/testify v1.11.1
|
||||
go.etcd.io/etcd/api/v3 v3.6.1
|
||||
@@ -25,22 +25,22 @@ require (
|
||||
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
|
||||
google.golang.org/protobuf v1.36.11
|
||||
gorm.io/driver/mysql v1.6.0
|
||||
gorm.io/gen v0.3.27
|
||||
gorm.io/gorm v1.31.1
|
||||
)
|
||||
|
||||
require (
|
||||
filippo.io/edwards25519 v1.1.0 // indirect
|
||||
github.com/BurntSushi/toml v1.2.0 // indirect
|
||||
github.com/BurntSushi/toml v1.6.0 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bytedance/gopkg v0.1.3 // indirect
|
||||
github.com/bytedance/sonic v1.14.2 // indirect
|
||||
github.com/bytedance/sonic/loader v0.4.0 // indirect
|
||||
github.com/bytedance/sonic v1.14.0 // indirect
|
||||
github.com/bytedance/sonic/loader v0.3.0 // indirect
|
||||
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/clbanning/mxj v1.8.4 // 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
|
||||
@@ -50,23 +50,25 @@ require (
|
||||
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/gabriel-vasile/mimetype v1.4.8 // 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-playground/validator/v10 v10.27.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/goccy/go-json v0.10.2 // indirect
|
||||
github.com/goccy/go-yaml v1.18.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/go-querystring v1.0.0 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 // indirect
|
||||
github.com/hashicorp/go-uuid v1.0.3 // indirect
|
||||
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
|
||||
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
|
||||
@@ -80,9 +82,11 @@ require (
|
||||
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/mitchellh/mapstructure v1.4.3 // 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/mozillazg/go-httpheader v0.2.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
|
||||
@@ -91,8 +95,8 @@ require (
|
||||
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/quic-go/qpack v0.5.1 // indirect
|
||||
github.com/quic-go/quic-go v0.54.0 // indirect
|
||||
github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9 // indirect
|
||||
github.com/sagikazarmark/locafero v0.11.0 // indirect
|
||||
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect
|
||||
@@ -101,7 +105,7 @@ require (
|
||||
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/ugorji/go/codec v1.3.0 // 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
|
||||
@@ -112,15 +116,18 @@ require (
|
||||
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/mock v0.5.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/arch v0.20.0 // indirect
|
||||
golang.org/x/crypto v0.44.0 // indirect
|
||||
golang.org/x/mod v0.29.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
|
||||
golang.org/x/tools v0.38.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
|
||||
104
go.sum
104
go.sum
@@ -1,7 +1,9 @@
|
||||
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=
|
||||
git.hlsq.asia/alex/proto v0.1.7-0.20261019060756-d28143475e8e h1:8sQI9i9wKOc8a0HvsXvn0FWynvXeodFSd8Fw8LI3PL4=
|
||||
git.hlsq.asia/alex/proto v0.1.7-0.20261019060756-d28143475e8e/go.mod h1:O77R475sJfEtjQQnhf859EpecejAkpRqdz7K6zDiYAk=
|
||||
github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk=
|
||||
github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||
github.com/IBM/sarama v1.46.3 h1:njRsX6jNlnR+ClJ8XmkO+CM4unbrNr/2vB5KK6UA+IE=
|
||||
github.com/IBM/sarama v1.46.3/go.mod h1:GTUYiF9DMOZVe3FwyGT+dtSPceGFIgA+sPc5u6CBwko=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
@@ -10,18 +12,16 @@ 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/bytedance/sonic v1.14.0 h1:/OfKt8HFw0kh2rj8N0F6C/qPGRESq0BbaNZgcNXXzQQ=
|
||||
github.com/bytedance/sonic v1.14.0/go.mod h1:WoEbx8WTcFJfzCe0hbmyTGrfjt8PzNEBdxlNUO24NhA=
|
||||
github.com/bytedance/sonic/loader v0.3.0 h1:dskwH8edlzNMctoruo8FPTJDF3vLtDT0sXZwvZJyqeA=
|
||||
github.com/bytedance/sonic/loader v0.3.0/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
|
||||
github.com/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/clbanning/mxj v1.8.4 h1:HuhwZtbyvyOw+3Z1AowPkU87JkJUSv751ELWaiTpj8I=
|
||||
github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng=
|
||||
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=
|
||||
@@ -45,8 +45,8 @@ github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHk
|
||||
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/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
|
||||
github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=
|
||||
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=
|
||||
@@ -62,8 +62,8 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.28.0 h1:Q7ibns33JjyW48gHkuFT91qX48KG0ktULL6FgHdG688=
|
||||
github.com/go-playground/validator/v10 v10.28.0/go.mod h1:GoI6I1SjPBh9p7ykNE/yj3fFYbyDOpwMn5KXd+m2hUU=
|
||||
github.com/go-playground/validator/v10 v10.27.0 h1:w8+XrWVMhGkxOaaowyKH35gFydVHOvC0/uWoy2Fzwn4=
|
||||
github.com/go-playground/validator/v10 v10.27.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo=
|
||||
github.com/go-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=
|
||||
@@ -74,24 +74,26 @@ 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/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
||||
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw=
|
||||
github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
|
||||
github.com/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.2.3/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||
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/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
|
||||
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
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=
|
||||
@@ -135,6 +137,8 @@ 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/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs=
|
||||
github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
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=
|
||||
@@ -142,6 +146,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE=
|
||||
github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
|
||||
github.com/mozillazg/go-httpheader v0.2.1 h1:geV7TrjbL8KXSyvghnFm+NyTux/hxwueTSrwhe88TQQ=
|
||||
github.com/mozillazg/go-httpheader v0.2.1/go.mod h1:jJ8xECTlalr6ValeXYdOF8fFUISeBAdw6E61aqQma60=
|
||||
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=
|
||||
@@ -164,18 +170,25 @@ github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ
|
||||
github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I=
|
||||
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
||||
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
||||
github.com/quic-go/qpack v0.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/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI=
|
||||
github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg=
|
||||
github.com/quic-go/quic-go v0.54.0 h1:6s1YB9QotYI6Ospeiguknbp2Znb/jZYjZLRXn9kMQBg=
|
||||
github.com/quic-go/quic-go v0.54.0/go.mod h1:e68ZEaCdyviluZmy44P6Iey98v/Wfz6HCjQEm+l8zTY=
|
||||
github.com/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/rs/dnscache v0.0.0-20230804202142-fc85eb664529/go.mod h1:qe5TWALJ8/a1Lqznoc5BDHpYX/8HU60Hm2AwRmqzxqA=
|
||||
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/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
|
||||
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
|
||||
github.com/sony/sonyflake/v2 v2.2.0 h1:wSzEoewlWnUtc3SZX/MpT8zsWTuAnjwrprUYfuPl9Jg=
|
||||
github.com/sony/sonyflake/v2 v2.2.0/go.mod h1:09EcfmR846JLupbkgVfzp8QtQwJ+Y8e69VVayHdawzg=
|
||||
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 h1:+jumHNA0Wrelhe64i8F6HNlS8pkoyMv5sreGx2Ry5Rw=
|
||||
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8/go.mod h1:3n1Cwaq1E1/1lhQhtRK2ts/ZwZEhjcQeJQ1RuC6Q/8U=
|
||||
github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I=
|
||||
@@ -189,22 +202,24 @@ github.com/spf13/viper v1.21.0/go.mod h1:P0lhsswPGWD/1lZJ9ny3fYnVqxiegrlNrEmgLjb
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
|
||||
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.563/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/kms v1.0.563/go.mod h1:uom4Nvi9W+Qkom0exYiJ9VWJjXwyxtPYTkKkaLMlfE0=
|
||||
github.com/tencentyun/cos-go-sdk-v5 v0.7.72 h1:k9aD8ri7Sqy2hYGYo6I2+OslDgY6IT5R0jUOHHSjW5Y=
|
||||
github.com/tencentyun/cos-go-sdk-v5 v0.7.72/go.mod h1:STbTNaNKq03u+gscPEGOahKzLcGSYOj6Dzc5zNay7Pg=
|
||||
github.com/tencentyun/qcloud-cos-sts-sdk v0.0.0-20250515025012-e0eec8a5d123/go.mod h1:b18KQa4IxHbxeseW1GcZox53d7J0z39VNONTxvvlkXw=
|
||||
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/ugorji/go/codec v1.3.0 h1:Qd2W2sQawAfG8XSvzwhBeoGq71zXOC/Q1E9y/wUcsUA=
|
||||
github.com/ugorji/go/codec v1.3.0/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
|
||||
github.com/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=
|
||||
@@ -217,7 +232,6 @@ github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zU
|
||||
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=
|
||||
@@ -249,34 +263,34 @@ go.opentelemetry.io/proto/otlp v1.9.0 h1:l706jCMITVouPOqEnii2fIAuO3IVGBRPV5ICjce
|
||||
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/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU=
|
||||
go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM=
|
||||
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/arch v0.20.0 h1:dx1zTU0MAE98U+TQ8BLl7XsJbgze2WnNKF/8tGp/Q6c=
|
||||
golang.org/x/arch v0.20.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk=
|
||||
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/crypto v0.44.0 h1:A97SsFvM3AIwEEmTBiaxPPTYpDC47w720rdiiUvgoAU=
|
||||
golang.org/x/crypto v0.44.0/go.mod h1:013i+Nw79BMiQiMsOPcVCB5ZIJbYkerPrGnOa00tvmc=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.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/mod v0.29.0 h1:HV8lRxZC4l2cr3Zq1LvtOsi/ThTgWnUk/y64QSs8GwA=
|
||||
golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-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=
|
||||
@@ -285,7 +299,6 @@ 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=
|
||||
@@ -293,8 +306,6 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
|
||||
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=
|
||||
@@ -312,14 +323,13 @@ 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/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ=
|
||||
golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
@@ -332,8 +342,8 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 h1:
|
||||
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=
|
||||
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
|
||||
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
@@ -347,5 +357,7 @@ 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/gen v0.3.27 h1:ziocAFLpE7e0g4Rum69pGfB9S6DweTxK8gAun7cU8as=
|
||||
gorm.io/gen v0.3.27/go.mod h1:9zquz2xD1f3Eb/eHq4oLn2z6vDVvQlCY5S3uMBLv4EA=
|
||||
gorm.io/gorm v1.31.1 h1:7CA8FTFz/gRfgqgpeKIBcervUn3xSyPUmr6B2WXJ7kg=
|
||||
gorm.io/gorm v1.31.1/go.mod h1:XyQVbO2k6YkOis7C2437jSit3SsDK72s7n7rsSHd+Gs=
|
||||
|
||||
21
module/cos.go
Normal file
21
module/cos.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package module
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/alex/service-common/config"
|
||||
"git.hlsq.asia/alex/service-common/cos"
|
||||
)
|
||||
|
||||
// Cos 对象存储模块
|
||||
type Cos struct {
|
||||
DefaultModule
|
||||
Cfg map[string]*config.CosConfig
|
||||
}
|
||||
|
||||
func (m *Cos) Init() error {
|
||||
if cfg, ok := m.Cfg["tencent"]; ok {
|
||||
if err := cos.InitTencent(cfg); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
10
module/db.go
10
module/db.go
@@ -4,6 +4,7 @@ import (
|
||||
"git.hlsq.asia/alex/service-common/config"
|
||||
"git.hlsq.asia/alex/service-common/db/etcd"
|
||||
"git.hlsq.asia/alex/service-common/db/kafka"
|
||||
"git.hlsq.asia/alex/service-common/db/mongo"
|
||||
"git.hlsq.asia/alex/service-common/db/mysql"
|
||||
"git.hlsq.asia/alex/service-common/db/redis"
|
||||
"git.hlsq.asia/alex/service-common/log"
|
||||
@@ -41,6 +42,12 @@ func (m *DB) Init() error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// MONGO
|
||||
if m.Cfg.Mongo != nil {
|
||||
if err := mongo.Init(m.Cfg.Mongo); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -57,5 +64,8 @@ func (m *DB) Stop() error {
|
||||
if err := kafka.Close(); err != nil {
|
||||
log.Errorf("close kafka failed: %v", err)
|
||||
}
|
||||
if err := mongo.Close(); err != nil {
|
||||
log.Errorf("close mongo failed: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
155
module/sensitive.go
Normal file
155
module/sensitive.go
Normal file
@@ -0,0 +1,155 @@
|
||||
package module
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"git.hlsq.asia/alex/service-common/config"
|
||||
"git.hlsq.asia/alex/service-common/cos"
|
||||
)
|
||||
|
||||
var SensitiveWordIns *SensitiveWord
|
||||
|
||||
type SensitiveWord struct {
|
||||
DefaultModule
|
||||
cfg *config.SensitiveWordConfig
|
||||
}
|
||||
|
||||
func NewSensitiveWord(cfg *config.SensitiveWordConfig) Module {
|
||||
SensitiveWordIns = &SensitiveWord{
|
||||
cfg: cfg,
|
||||
}
|
||||
return SensitiveWordIns
|
||||
}
|
||||
|
||||
func (m *SensitiveWord) Init() error {
|
||||
if m.cfg == nil {
|
||||
//下载文件
|
||||
contentBytes, err := cos.DownloadSimple(context.Background(), "server_file/sensitive_words.txt", "sensitive-word.txt")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var sensitiveWords map[string]struct{}
|
||||
err = json.Unmarshal(contentBytes, &sensitiveWords)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sensitiveWordsList := make([]string, 0, len(sensitiveWords))
|
||||
for word := range sensitiveWords {
|
||||
sensitiveWordsList = append(sensitiveWordsList, word)
|
||||
}
|
||||
sensitiveTrie = newTrie(sensitiveWordsList)
|
||||
}
|
||||
// todo 根据配置文件
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContainsSensitiveWords 判断是否包含敏感词
|
||||
func (m *SensitiveWord) ContainsSensitiveWords(text string) bool {
|
||||
return sensitiveTrie.containsSensitiveWords(text)
|
||||
}
|
||||
|
||||
// FilterSensitiveWords 过滤敏感词
|
||||
func (m *SensitiveWord) FilterSensitiveWords(text string) string {
|
||||
return sensitiveTrie.filterSensitiveWords(text)
|
||||
}
|
||||
|
||||
var sensitiveTrie *Trie
|
||||
|
||||
type trieNode struct {
|
||||
children map[rune]*trieNode
|
||||
isEnd bool
|
||||
}
|
||||
|
||||
type Trie struct {
|
||||
root *trieNode
|
||||
}
|
||||
|
||||
func newTrie(worlds []string) *Trie {
|
||||
t := &Trie{
|
||||
root: &trieNode{
|
||||
children: make(map[rune]*trieNode),
|
||||
isEnd: false,
|
||||
},
|
||||
}
|
||||
for _, str := range worlds {
|
||||
t.insert(str)
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
const replace = '*'
|
||||
|
||||
func (sensitiveTrie *Trie) insert(word string) {
|
||||
node := sensitiveTrie.root
|
||||
for _, c := range word {
|
||||
if _, ok := node.children[c]; !ok {
|
||||
node.children[c] = &trieNode{
|
||||
children: make(map[rune]*trieNode),
|
||||
isEnd: false,
|
||||
}
|
||||
}
|
||||
node = node.children[c]
|
||||
}
|
||||
node.isEnd = true
|
||||
}
|
||||
|
||||
func (sensitiveTrie *Trie) containsSensitiveWords(text string) bool {
|
||||
if len(text) == 0 {
|
||||
return false
|
||||
}
|
||||
length := len([]rune(text))
|
||||
runes := make([]rune, length)
|
||||
index := 0
|
||||
for _, char := range text {
|
||||
runes[index] = char
|
||||
index++
|
||||
}
|
||||
for pointIndex := 0; pointIndex < length; pointIndex++ {
|
||||
//判断
|
||||
node := sensitiveTrie.root
|
||||
for currentIndex := pointIndex; currentIndex < length; currentIndex++ {
|
||||
tn := node.children[runes[currentIndex]]
|
||||
if tn == nil {
|
||||
break
|
||||
}
|
||||
if tn.isEnd {
|
||||
return true
|
||||
}
|
||||
node = tn
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (sensitiveTrie *Trie) filterSensitiveWords(text string) string {
|
||||
if len(text) == 0 {
|
||||
return text
|
||||
}
|
||||
length := len([]rune(text))
|
||||
runes := make([]rune, length)
|
||||
index := 0
|
||||
for _, char := range text {
|
||||
runes[index] = char
|
||||
index++
|
||||
}
|
||||
for pointIndex := 0; pointIndex < length; pointIndex++ {
|
||||
//判断
|
||||
node := sensitiveTrie.root
|
||||
for currentIndex := pointIndex; currentIndex < length; currentIndex++ {
|
||||
tn := node.children[runes[currentIndex]]
|
||||
if tn == nil {
|
||||
break
|
||||
}
|
||||
if tn.isEnd {
|
||||
//替换字符
|
||||
for i := pointIndex; i < currentIndex+1; i++ {
|
||||
runes[i] = replace
|
||||
}
|
||||
pointIndex = currentIndex
|
||||
break
|
||||
}
|
||||
node = tn
|
||||
}
|
||||
}
|
||||
return string(runes)
|
||||
}
|
||||
25
module/server_status.go
Normal file
25
module/server_status.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package module
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/alex/service-common/server"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type ServerStatus struct {
|
||||
DefaultModule
|
||||
}
|
||||
|
||||
func (s *ServerStatus) Init() error {
|
||||
server.InitStatus()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ServerStatus) Start(ready *sync.WaitGroup) error {
|
||||
server.ListenStatus(ready)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ServerStatus) Stop() error {
|
||||
server.CloseStatus()
|
||||
return nil
|
||||
}
|
||||
25
module/server_whitelist.go
Normal file
25
module/server_whitelist.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package module
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/alex/service-common/server"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type ServerWhitelist struct {
|
||||
DefaultModule
|
||||
}
|
||||
|
||||
func (s *ServerWhitelist) Init() error {
|
||||
server.InitWhitelist()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ServerWhitelist) Start(ready *sync.WaitGroup) error {
|
||||
server.ListenWhitelist(ready)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ServerWhitelist) Stop() error {
|
||||
server.CloseWhitelist()
|
||||
return nil
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.hlsq.asia/alex/service-common/db/etcd"
|
||||
"git.hlsq.asia/alex/service-common/log"
|
||||
"git.hlsq.asia/alex/service-common/utils"
|
||||
clientv3 "go.etcd.io/etcd/client/v3"
|
||||
"go.etcd.io/etcd/client/v3/concurrency"
|
||||
@@ -25,7 +24,6 @@ func (m *Snowflake) Init() error {
|
||||
}
|
||||
m.snowflakeSession = session
|
||||
utils.InitSnowflake(node)
|
||||
log.Infof("snowflake node: %v", node)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -41,7 +39,7 @@ func acquire(ctx context.Context, min, max int) (int64, *concurrency.Session, er
|
||||
}
|
||||
|
||||
for _, n := range nums {
|
||||
key := fmt.Sprintf("node/num/%d", n)
|
||||
key := fmt.Sprintf("/node/num/%d", n)
|
||||
|
||||
session, err := concurrency.NewSession(
|
||||
etcd.GetClient().Raw(),
|
||||
|
||||
@@ -29,13 +29,17 @@ func (m *Tracer) Init() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
samplingRate := 1.0
|
||||
if 0 <= m.Cfg.Jaeger.SamplingRate && m.Cfg.Jaeger.SamplingRate <= 1 {
|
||||
samplingRate = m.Cfg.Jaeger.SamplingRate
|
||||
}
|
||||
m.tp = sdktrace.NewTracerProvider(
|
||||
sdktrace.WithBatcher(exporter),
|
||||
sdktrace.WithResource(resource.NewWithAttributes(
|
||||
semconv.SchemaURL,
|
||||
semconv.ServiceNameKey.String(m.ServiceName),
|
||||
)),
|
||||
sdktrace.WithSampler(sdktrace.ParentBased(sdktrace.TraceIDRatioBased(samplingRate))),
|
||||
)
|
||||
otel.SetTracerProvider(m.tp)
|
||||
otel.SetTextMapPropagator(propagation.TraceContext{})
|
||||
|
||||
24
net/grpc/grpcclient/client_admin.go
Normal file
24
net/grpc/grpcclient/client_admin.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package grpcclient
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/alex/proto/proto/rs/rspb"
|
||||
"git.hlsq.asia/alex/service-common/discover"
|
||||
"git.hlsq.asia/alex/service-common/discover/common"
|
||||
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
|
||||
)
|
||||
|
||||
func AdminNewClient(sid ...int64) (rspb.AdminClient, error) {
|
||||
c, err := discover.FindServer(common.KeyDiscoverAdmin, sid...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rspb.NewAdminClient(c), nil
|
||||
}
|
||||
|
||||
func AdminNewClientLB() (rspb.AdminClient, error) {
|
||||
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameAdmin)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rspb.NewAdminClient(c), nil
|
||||
}
|
||||
24
net/grpc/grpcclient/client_announcement.go
Normal file
24
net/grpc/grpcclient/client_announcement.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package grpcclient
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/alex/proto/proto/rs/rspb"
|
||||
"git.hlsq.asia/alex/service-common/discover"
|
||||
"git.hlsq.asia/alex/service-common/discover/common"
|
||||
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
|
||||
)
|
||||
|
||||
func AnnouncementNewClient(sid ...int64) (rspb.AnnouncementClient, error) {
|
||||
c, err := discover.FindServer(common.KeyDiscoverAnnouncement, sid...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rspb.NewAnnouncementClient(c), nil
|
||||
}
|
||||
|
||||
func AnnouncementNewClientLB() (rspb.AnnouncementClient, error) {
|
||||
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameAnnouncement)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rspb.NewAnnouncementClient(c), nil
|
||||
}
|
||||
24
net/grpc/grpcclient/client_court-physical.go
Normal file
24
net/grpc/grpcclient/client_court-physical.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package grpcclient
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/alex/proto/proto/rs/rspb"
|
||||
"git.hlsq.asia/alex/service-common/discover"
|
||||
"git.hlsq.asia/alex/service-common/discover/common"
|
||||
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
|
||||
)
|
||||
|
||||
func CourtPhysicalNewClient(sid ...int64) (rspb.CourtPhysicalClient, error) {
|
||||
c, err := discover.FindServer(common.KeyDiscoverCourtPhysical, sid...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rspb.NewCourtPhysicalClient(c), nil
|
||||
}
|
||||
|
||||
func CourtPhysicalNewClientLB() (rspb.CourtPhysicalClient, error) {
|
||||
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameCourtPhysical)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rspb.NewCourtPhysicalClient(c), nil
|
||||
}
|
||||
24
net/grpc/grpcclient/client_court.go
Normal file
24
net/grpc/grpcclient/client_court.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package grpcclient
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/alex/proto/proto/rs/rspb"
|
||||
"git.hlsq.asia/alex/service-common/discover"
|
||||
"git.hlsq.asia/alex/service-common/discover/common"
|
||||
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
|
||||
)
|
||||
|
||||
func CourtNewClient(sid ...int64) (rspb.CourtClient, error) {
|
||||
c, err := discover.FindServer(common.KeyDiscoverCourt, sid...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rspb.NewCourtClient(c), nil
|
||||
}
|
||||
|
||||
func CourtNewClientLB() (rspb.CourtClient, error) {
|
||||
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameCourt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rspb.NewCourtClient(c), nil
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package grpcclient
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/alex/proto/proto/rs/rspb"
|
||||
"git.hlsq.asia/alex/service-common/discover"
|
||||
"git.hlsq.asia/alex/service-common/discover/common"
|
||||
"git.hlsq.asia/alex/service-common/proto/rs/rspb"
|
||||
)
|
||||
|
||||
func GatewayNewClient(sid ...int64) (rspb.GatewayClient, error) {
|
||||
|
||||
24
net/grpc/grpcclient/client_post.go
Normal file
24
net/grpc/grpcclient/client_post.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package grpcclient
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/alex/proto/proto/rs/rspb"
|
||||
"git.hlsq.asia/alex/service-common/discover"
|
||||
"git.hlsq.asia/alex/service-common/discover/common"
|
||||
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
|
||||
)
|
||||
|
||||
func PostNewClient(sid ...int64) (rspb.PostClient, error) {
|
||||
c, err := discover.FindServer(common.KeyDiscoverPost, sid...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rspb.NewPostClient(c), nil
|
||||
}
|
||||
|
||||
func PostNewClientLB() (rspb.PostClient, error) {
|
||||
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNamePost)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rspb.NewPostClient(c), nil
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
package grpcclient
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.hlsq.asia/alex/proto/proto/rs/rspb"
|
||||
"git.hlsq.asia/alex/service-common/discover"
|
||||
"git.hlsq.asia/alex/service-common/discover/common"
|
||||
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
|
||||
"git.hlsq.asia/alex/service-common/proto/rs/rspb"
|
||||
)
|
||||
|
||||
// SceneNewClient 根据SID查找场景服,一般不用这个函数
|
||||
func SceneNewClient(sid ...int64) (rspb.SceneClient, error) {
|
||||
c, err := discover.FindServer(common.KeyDiscoverScene, sid...)
|
||||
if err != nil {
|
||||
@@ -15,6 +17,15 @@ func SceneNewClient(sid ...int64) (rspb.SceneClient, error) {
|
||||
return rspb.NewSceneClient(c), nil
|
||||
}
|
||||
|
||||
// SceneInstanceNewClient 根据副本唯一编号查找场景服
|
||||
func SceneInstanceNewClient(uniqueNO int64) (rspb.SceneClient, error) {
|
||||
sid := discover.FindInstanceByUniqueNo(uniqueNO)
|
||||
if sid == 0 {
|
||||
return nil, fmt.Errorf("instance not found: %v", uniqueNO)
|
||||
}
|
||||
return SceneNewClient(sid)
|
||||
}
|
||||
|
||||
func SceneNewClientLB() (rspb.SceneClient, error) {
|
||||
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameScene)
|
||||
if err != nil {
|
||||
|
||||
24
net/grpc/grpcclient/client_third-party.go
Normal file
24
net/grpc/grpcclient/client_third-party.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package grpcclient
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/alex/proto/proto/rs/rspb"
|
||||
"git.hlsq.asia/alex/service-common/discover"
|
||||
"git.hlsq.asia/alex/service-common/discover/common"
|
||||
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
|
||||
)
|
||||
|
||||
func ThirdPartyNewClient(sid ...int64) (rspb.ThirdPartyClient, error) {
|
||||
c, err := discover.FindServer(common.KeyDiscoverThirdParty, sid...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rspb.NewThirdPartyClient(c), nil
|
||||
}
|
||||
|
||||
func ThirdPartyNewClientLB() (rspb.ThirdPartyClient, error) {
|
||||
c, err := resolver.GetGrpcClientConn("etcd:///" + common.KeyDiscoverServiceNameThirdParty)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rspb.NewThirdPartyClient(c), nil
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package grpcclient
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/alex/proto/proto/rs/rspb"
|
||||
"git.hlsq.asia/alex/service-common/discover"
|
||||
"git.hlsq.asia/alex/service-common/discover/common"
|
||||
"git.hlsq.asia/alex/service-common/net/grpc/resolver"
|
||||
"git.hlsq.asia/alex/service-common/proto/rs/rspb"
|
||||
)
|
||||
|
||||
func UserNewClient(sid ...int64) (rspb.UserClient, error) {
|
||||
|
||||
@@ -3,7 +3,11 @@ package grpcclient
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"git.hlsq.asia/alex/proto/proto/rs/rspb"
|
||||
"git.hlsq.asia/alex/service-common/discover"
|
||||
"git.hlsq.asia/alex/service-common/discover/common"
|
||||
"git.hlsq.asia/alex/service-common/log"
|
||||
"git.hlsq.asia/alex/service-common/utils/locator"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"sync"
|
||||
@@ -13,6 +17,8 @@ type GatewayFun int
|
||||
|
||||
const (
|
||||
FunToClient GatewayFun = iota
|
||||
FunBroadcastClient
|
||||
FunBroadcastChannel
|
||||
)
|
||||
|
||||
var gatewayServer sync.Map // map[string]*gatewayStream
|
||||
@@ -37,7 +43,11 @@ func findGatewayBySID(sid int64, fun GatewayFun) (*gatewayStream, error) {
|
||||
var stream grpc.ClientStream
|
||||
switch fun {
|
||||
case FunToClient:
|
||||
stream, err = client.ToClient(context.Background())
|
||||
stream, err = client.InnerToClient(context.Background())
|
||||
case FunBroadcastClient:
|
||||
stream, err = client.InnerBroadcastClient(context.Background())
|
||||
case FunBroadcastChannel:
|
||||
stream, err = client.InnerBroadcastChannel(context.Background())
|
||||
}
|
||||
if err != nil {
|
||||
log.Errorf("findGatewayBySID %v err: %v, sid: %v", fun, err, sid)
|
||||
@@ -53,7 +63,7 @@ func findGatewayBySID(sid int64, fun GatewayFun) (*gatewayStream, error) {
|
||||
return ss, nil
|
||||
}
|
||||
|
||||
func SendMessageToGateway(sid int64, fun GatewayFun, msg proto.Message, re ...bool) error {
|
||||
func sendMessageToGateway(sid int64, fun GatewayFun, msg proto.Message, re ...bool) error {
|
||||
ss, err := findGatewayBySID(sid, fun)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -71,13 +81,46 @@ func SendMessageToGateway(sid int64, fun GatewayFun, msg proto.Message, re ...bo
|
||||
}
|
||||
// 如果没有标识本次是重试的,就重试一次(默认重试)
|
||||
if re == nil || !re[0] {
|
||||
return SendMessageToGateway(sid, fun, msg, true)
|
||||
return sendMessageToGateway(sid, fun, msg, true)
|
||||
}
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SendMessageToClient 单播消息给客户端
|
||||
func SendMessageToClient(ctx context.Context, usn int64, msg proto.Message, platform ...rspb.PlatformType) error {
|
||||
if platform == nil || len(platform) == 0 {
|
||||
return nil
|
||||
}
|
||||
for _, pf := range platform {
|
||||
if gatewaySID := locator.NewLocator(ctx, usn, int32(pf)).LocateGateway(); gatewaySID > 0 {
|
||||
return sendMessageToGateway(gatewaySID, FunToClient, msg)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// BroadcastMessageToClient 广播消息给客户端
|
||||
func BroadcastMessageToClient(msg *rspb.InnerBroadcastClientReq) error {
|
||||
return broadcastMessageToGateway(FunBroadcastClient, msg)
|
||||
}
|
||||
|
||||
// BroadcastMessageToChannel 广播消息到频道(加入频道的能收到,不区分平台)
|
||||
func BroadcastMessageToChannel(msg *rspb.InnerBroadcastChannelReq) error {
|
||||
return broadcastMessageToGateway(FunBroadcastChannel, msg)
|
||||
}
|
||||
|
||||
func broadcastMessageToGateway(fun GatewayFun, msg proto.Message) error {
|
||||
sidArr := discover.FindServerAllSid(common.KeyDiscoverGateway)
|
||||
for _, sid := range sidArr {
|
||||
if err := sendMessageToGateway(sid, fun, msg); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func gatewayKey(sid int64, fun GatewayFun) string {
|
||||
return fmt.Sprintf("%v-%v", sid, fun)
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package grpcconn
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.hlsq.asia/alex/service-common/log"
|
||||
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/keepalive"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -22,6 +25,7 @@ func NewGrpcConnection(sid int64, address string) (*GrpcConnection, error) {
|
||||
address,
|
||||
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||
grpc.WithStatsHandler(otelgrpc.NewClientHandler()),
|
||||
grpc.WithUnaryInterceptor(sidInterceptor(sid)),
|
||||
grpc.WithKeepaliveParams(
|
||||
keepalive.ClientParameters{
|
||||
Time: 30 * time.Second, // 保活探测包发送的时间间隔
|
||||
@@ -41,3 +45,13 @@ func NewGrpcConnection(sid int64, address string) (*GrpcConnection, error) {
|
||||
func (g *GrpcConnection) GetConnection() *grpc.ClientConn {
|
||||
return g.conn
|
||||
}
|
||||
|
||||
func sidInterceptor(sid int64) grpc.UnaryClientInterceptor {
|
||||
sidStr := strconv.Itoa(int(sid))
|
||||
return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||
ctx = metadata.AppendToOutgoingContext(ctx,
|
||||
"X-Sid", sidStr,
|
||||
)
|
||||
return invoker(ctx, method, req, reply, cc, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,3 +60,11 @@ func (p *GrpcConnectionMgr) LoadAll() map[int64]*grpc.ClientConn {
|
||||
}
|
||||
return sidM
|
||||
}
|
||||
|
||||
func (p *GrpcConnectionMgr) LoadAllSid() []int64 {
|
||||
sidArr := make([]int64, 0)
|
||||
for sid := range p.poolM {
|
||||
sidArr = append(sidArr, sid)
|
||||
}
|
||||
return sidArr
|
||||
}
|
||||
|
||||
@@ -2,8 +2,11 @@ package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.hlsq.asia/alex/proto/proto/rs/rscommon"
|
||||
"git.hlsq.asia/alex/service-common/log"
|
||||
"git.hlsq.asia/alex/service-common/net/http/httpresp"
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
otelcodes "go.opentelemetry.io/otel/codes"
|
||||
@@ -12,6 +15,7 @@ import (
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -25,6 +29,19 @@ func (s *Base) RecoveryInterceptor(ctx context.Context, req interface{}, info *g
|
||||
return handler(ctx, req)
|
||||
}
|
||||
|
||||
func (s *Base) CheckSID(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
|
||||
if md, ok := metadata.FromIncomingContext(ctx); ok {
|
||||
sidArr := md.Get("X-Sid")
|
||||
if len(sidArr) > 0 {
|
||||
if strconv.Itoa(int(s.SID)) != sidArr[0] {
|
||||
err = status.Error(codes.Internal, "SID mismatch")
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
return handler(ctx, req)
|
||||
}
|
||||
|
||||
func (s *Base) LoggingInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
|
||||
usn := ""
|
||||
if md, ok := metadata.FromIncomingContext(ctx); ok {
|
||||
@@ -37,14 +54,17 @@ func (s *Base) LoggingInterceptor(ctx context.Context, req interface{}, info *gr
|
||||
_, 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)
|
||||
reqStr, _ := json.Marshal(req)
|
||||
reqString := fmt.Sprintf("[usn:%v] ↓↓↓ method: %s, Request: %v", usn, info.FullMethod, string(reqStr))
|
||||
span.SetAttributes(attribute.String("rpc.req", reqString))
|
||||
span.SetAttributes(attribute.String("usn", usn))
|
||||
log.Infof(reqString)
|
||||
start := time.Now()
|
||||
|
||||
resp, err = handler(ctx, req)
|
||||
|
||||
respString := fmt.Sprintf("[usn:%v] method: %s, Duration: %v, Response: %v, Error: %v", usn, info.FullMethod, time.Since(start), resp, err)
|
||||
respStr, _ := json.Marshal(resp)
|
||||
respString := fmt.Sprintf("[usn:%v] ↑↑↑ method: %s, Duration: %v, Response: %v, Error: %v", usn, info.FullMethod, time.Since(start), string(respStr), err)
|
||||
span.SetAttributes(attribute.String("rpc.resp", respString))
|
||||
log.Infof(respString)
|
||||
|
||||
@@ -53,8 +73,31 @@ func (s *Base) LoggingInterceptor(ctx context.Context, req interface{}, info *gr
|
||||
span.AddEvent("Stack Trace", trace.WithAttributes(
|
||||
attribute.String("stack.trace", fmt.Sprintf("%v", stack.StackTrace())),
|
||||
))
|
||||
if original, ok := err.(interface{ Original() error }); ok {
|
||||
if wrap, ok := original.Original().(interface{ Wrap() error }); ok {
|
||||
err = wrap.Wrap()
|
||||
} else {
|
||||
err = checkGRPCError(original.Original())
|
||||
}
|
||||
}
|
||||
} else if wrap, ok := err.(interface{ Wrap() error }); ok {
|
||||
err = wrap.Wrap()
|
||||
} else {
|
||||
err = checkGRPCError(err)
|
||||
}
|
||||
span.SetStatus(otelcodes.Error, err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func checkGRPCError(err error) error {
|
||||
if original, ok := err.(interface{ GRPCStatus() *status.Status }); ok {
|
||||
details := original.GRPCStatus().Details()
|
||||
if len(details) > 0 {
|
||||
if ei, ok := details[0].(*rscommon.ErrorInfo); ok {
|
||||
return httpresp.NewCode(int(ei.Code), ei.Msg).Wrap()
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ type Base struct {
|
||||
func (s *Base) Init(ready *sync.WaitGroup) {
|
||||
s.wg = &sync.WaitGroup{}
|
||||
s.wg.Add(1)
|
||||
s.SID = utils.SnowflakeInstance().Generate().Int64()
|
||||
s.SID = utils.SnowflakeInt64()
|
||||
go func() {
|
||||
defer s.wg.Done()
|
||||
defer s.OnClose()
|
||||
@@ -55,6 +55,7 @@ func (s *Base) Init(ready *sync.WaitGroup) {
|
||||
options := []grpc.ServerOption{
|
||||
grpc.ChainUnaryInterceptor(
|
||||
s.RecoveryInterceptor,
|
||||
s.CheckSID,
|
||||
s.LoggingInterceptor,
|
||||
),
|
||||
grpc.StatsHandler(otelgrpc.NewServerHandler()),
|
||||
@@ -79,6 +80,7 @@ func (s *Base) Init(ready *sync.WaitGroup) {
|
||||
}
|
||||
// 准备好了
|
||||
ready.Done()
|
||||
log.Infof("%v registered grpc sid: %v", s.Target, s.SID)
|
||||
if err = s.Serve.Serve(lis); err != nil {
|
||||
log.Errorf("%v Serve err: %v", s.Target, err)
|
||||
return
|
||||
@@ -91,7 +93,6 @@ func (s *Base) SetReady() {
|
||||
if s.healthcheck != nil {
|
||||
s.healthcheck.SetServingStatus("", grpc_health_v1.HealthCheckResponse_SERVING)
|
||||
}
|
||||
log.Infof("%v server ready, port: %v", s.Target, s.Cfg.Port)
|
||||
}
|
||||
|
||||
func (s *Base) Close() {
|
||||
|
||||
@@ -1,22 +1,95 @@
|
||||
package httpresp
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/alex/service-common/proto/rs/rscommon"
|
||||
"git.hlsq.asia/alex/proto/proto/rs/rscommon"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
var (
|
||||
OK = NewCode(0, "OK")
|
||||
Failed = NewCode(1, "Failed")
|
||||
TokenInvalid = NewCode(2, "Token Invalid")
|
||||
MethodNotAllowed = NewCode(3, "Method Not Allowed")
|
||||
NotFound = NewCode(4, "Not Found")
|
||||
ParamError = NewCode(1001, "参数错误")
|
||||
NameEmpty = NewCode(1002, "名称不能为空")
|
||||
NameDuplicate = NewCode(1003, "名称或编号不能重复")
|
||||
ListEmpty = NewCode(1004, "列表不能为空")
|
||||
RepeatCommit = NewCode(1005, "请勿重复提交")
|
||||
OK = NewCode(0, "OK")
|
||||
Failed = NewCode(1, "Failed")
|
||||
TokenInvalid = NewCode(2, "Token Invalid")
|
||||
MethodNotAllowed = NewCode(3, "Method Not Allowed")
|
||||
NotFound = NewCode(4, "Not Found")
|
||||
TokenForbidden = NewCode(5, "Token Forbidden")
|
||||
AdminNotExist = NewCode(6, "Admin Not Exist")
|
||||
ServerMaintenance = NewCode(7, "Server Maintenance")
|
||||
RequestTooFast = NewCode(8, "Request too fast") // 请求太频繁了
|
||||
ParamError = NewCode(1001, "参数错误")
|
||||
PageQueryError = NewCode(1002, "page query param error")
|
||||
PhoneCodeError = NewCode(1003, "Phone or code error") // 手机验证码错误
|
||||
PhoneHasBeenBind = NewCode(1004, "Phone number has been bind") // 手机号已经被绑定
|
||||
WeChatHasBeenBind = NewCode(1005, "WeChat has been bind") // 微信已经被绑定
|
||||
BindTicketError = NewCode(1006, "Bind ticket error") // 登录绑定凭证无效
|
||||
RoundIsEnd = NewCode(2001, "Round is end")
|
||||
RoundNotEnd = NewCode(2002, "Round not end")
|
||||
|
||||
NameEmpty = NewCode(1002, "名称不能为空")
|
||||
NameDuplicate = NewCode(1003, "名称或编号不能重复")
|
||||
ListEmpty = NewCode(1004, "列表不能为空")
|
||||
RepeatCommit = NewCode(1005, "请勿重复提交")
|
||||
|
||||
// ----------------user 10000-11000--------------------
|
||||
UserNotFound = NewCode(10001, "User not found")
|
||||
CharNickNameTooLong = NewCode(10002, "Character nickname too long")
|
||||
CharNickNameIllegal = NewCode(10003, "Character nickname illegal")
|
||||
CharNickNameEmpty = NewCode(10004, "Character nickname empty")
|
||||
CharModelEmpty = NewCode(10005, "Character model empty")
|
||||
CharModelNotExist = NewCode(10006, "Character model not exist")
|
||||
CharAvatarEmpty = NewCode(10007, "Character avatar empty")
|
||||
CharAvatarNotExist = NewCode(10008, "Character avatar not exist")
|
||||
CharSexInvalid = NewCode(10009, "Character sex invalid")
|
||||
RewardAlreadyBindError = NewCode(10010, "Reward already bind") // 奖励已绑定
|
||||
|
||||
// ----------------SCENE 10010-10100--------------------
|
||||
SceneRoomNumberGenError = NewCode(10010, "Room number gen error")
|
||||
RoomNotExistsError = NewCode(10011, "Room not exists error")
|
||||
RoomPlayerUpperLimit = NewCode(10012, "Room player upper limit") // 房间人数满了
|
||||
RoomStatusNotAllowEnter = NewCode(10013, "Room status not allow enter") // 房间状态不允许中途进入
|
||||
PlayerAlreadyInRoom = NewCode(10014, "Player already in room") //玩家已经在房间中
|
||||
PlayerHandicapNotMeet = NewCode(10015, "Player handicap not meet") //玩家等级不足
|
||||
NoAvailableRoom = NewCode(10016, "No available room") // 没有符合的房间
|
||||
SceneRoomDescriptionWidthError = NewCode(10017, "Room description width more than error")
|
||||
// ----------------court-physical 11001-12000--------------------
|
||||
CourtPhysicalNotFind = NewCode(11001, "没有找到线下球场配置")
|
||||
CourtPhysicalNotFindCompetitionl = NewCode(11002, "没有找到比赛")
|
||||
CourtPhysicalCompetitionlNotPermission = NewCode(11003, "你不是房主无权编辑")
|
||||
CourtPhysicalCompetitionlNotHole = NewCode(11004, "球场配置错误,没有洞的数据")
|
||||
CourtPhysicalCompetitionlPlayerUpperLimit = NewCode(11005, "比赛球员已达上限")
|
||||
CourtPhysicalCompetitionlPlayerIsRoom = NewCode(11006, "用户已在房间")
|
||||
CourtPhysicalCompetitionlStart = NewCode(11007, "比赛已开始")
|
||||
CourtPhysicalCompetitionlPlayerJoinFailed = NewCode(11008, "用户加入比赛失败")
|
||||
CourtPhysicalCompetitionlNotRemovedHomeowner = NewCode(11009, "不能移除房主")
|
||||
CourtPhysicalCompetitionlNotFindPlayer = NewCode(11010, "房间没有该用户")
|
||||
CourtPhysicalCompetitionlNotGamePlayer = NewCode(11011, "该用户不是球员")
|
||||
CourtPhysicalCompetitionlNotIn = NewCode(11012, "该用户不在本局比赛")
|
||||
CourtPhysicalCompetitionlStartFail = NewCode(11013, "比赛开始初始化数据失败")
|
||||
CourtPhysicalCompetitionlEnd = NewCode(11014, "比赛已结束")
|
||||
CourtPhysicalCompetitionlNotStart = NewCode(11015, "比赛未开始")
|
||||
CourtPhysicalCompetitionlPKFail = NewCode(11016, "PK玩法配置错误")
|
||||
CourtPhysicalCompetitionlPKTigerNot3Player = NewCode(11017, "PK玩法配置错误:Tiger玩法参赛选手需≥3")
|
||||
CourtPhysicalCompetitionlPKTigerNotTiger = NewCode(11018, "PK玩法配置错误:Tiger玩法不能没有老虎")
|
||||
CourtPhysicalCompetitionlPKTigerNotHole = NewCode(11019, "PK玩法配置错误:Tiger玩法至少要选择一个球洞")
|
||||
CourtPhysicalCompetitionlPKTigerEnhanceFail = NewCode(11020, "PK玩法配置错误:Tiger玩法比洞才有受让杆")
|
||||
CourtPhysicalCompetitionlPKTigerTopHoleFail = NewCode(11021, "PK玩法配置错误:Tiger玩法比洞才有顶洞和收顶洞")
|
||||
CourtPhysicalCompetitionlPKRyderCupNot4Player = NewCode(11022, "PK玩法配置错误:莱德杯玩法需4名参赛选手")
|
||||
CourtPhysicalCompetitionlPKRyderCupLeastFormat = NewCode(11023, "PK玩法配置错误:莱德杯玩法至少要选择一个赛制")
|
||||
CourtPhysicalCompetitionlPKRyderCupHoleFail = NewCode(11024, "PK玩法配置错误:莱德杯玩法球洞配置冲突")
|
||||
CourtPhysicalCompetitionlPKRyderCupTeamFail = NewCode(11025, "PK玩法配置错误:莱德杯玩法两队人数不对")
|
||||
CourtPhysicalCompetitionlNameIllegal = NewCode(11026, "比赛昵称存在违禁词")
|
||||
CourtPhysicalCompetitionlLinkError = NewCode(11027, "生成微信链接错误")
|
||||
|
||||
// 锦标赛 ----------------court 12001-13000--------------------
|
||||
CourtTournamentNotInvited = NewCode(12002, "仅限受邀用户参赛") // 未在邀请名单内
|
||||
CourtTournamentHandicapNotMeet = NewCode(12003, "差点不符合参赛要求") // 无有效差点或超出要求区间
|
||||
CourtTournamentRoundAlreadyStarted = NewCode(12004, "本轮比赛已开始") // 并发重复开赛(竞态)
|
||||
CourtTournamentRoundNotInProgress = NewCode(12005, "轮次未开始,不能开赛") // 轮次不是进行中
|
||||
CourtTournamentJoinEnded = NewCode(12006, "已淘汰,无法继续比赛") // 报名已结束(已淘汰)
|
||||
CourtTournamentPracticeNotAllowed = NewCode(12007, "该锦标赛未开放练习") // 未配置练习次数
|
||||
CourtTournamentPracticeEnded = NewCode(12008, "比赛已结束,不允许练习") // 决赛结束/已完成/已取消
|
||||
CourtTournamentPracticeTimesNotEnough = NewCode(12009, "练习次数已用完") // 已练习次数达上限
|
||||
CourtTournamentShelfStatusNotAllowed = NewCode(12010, "该锦标赛不允许下架") // 该锦标赛不允许下架
|
||||
)
|
||||
|
||||
type Code struct {
|
||||
|
||||
@@ -43,5 +43,9 @@ func JsonNotFound(c *gin.Context) {
|
||||
}
|
||||
|
||||
func JsonUnauthorized(c *gin.Context) {
|
||||
c.JSON(http.StatusUnauthorized, Error(TokenInvalid))
|
||||
c.JSON(http.StatusOK, Error(TokenInvalid))
|
||||
}
|
||||
|
||||
func JsonMaintenance(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, Error(ServerMaintenance))
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package socket
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Action int
|
||||
|
||||
const (
|
||||
@@ -31,9 +27,8 @@ type ISocketServer interface {
|
||||
OnOpen(ISocketConn) ([]byte, Action) // 开启连接
|
||||
OnHandShake(ISocketConn) Action // 开始握手
|
||||
OnMessage(ISocketConn, []byte) Action // 收到消息
|
||||
OnPong(ISocketConn)
|
||||
OnClose(ISocketConn, error) Action // 关闭连接
|
||||
OnTick() (time.Duration, Action)
|
||||
OnClose(ISocketConn, error) Action // 关闭连接
|
||||
OnTick() Action // 定时调用(由网络层决定)
|
||||
}
|
||||
|
||||
// ISocketConn 由网络层实现
|
||||
@@ -41,7 +36,7 @@ type ISocketConn interface {
|
||||
GetParam(key string) interface{}
|
||||
SetParam(key string, values interface{})
|
||||
RemoteAddr() string
|
||||
Ping() error // 需要隔一段时间调用一下,建议20s
|
||||
Ping() error
|
||||
Write(data []byte) error
|
||||
Close() error
|
||||
IsClose() bool
|
||||
|
||||
@@ -3,6 +3,8 @@ package websocket
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"git.hlsq.asia/alex/service-common/log"
|
||||
"git.hlsq.asia/alex/service-common/net/socket"
|
||||
"github.com/panjf2000/gnet/v2"
|
||||
"github.com/panjf2000/gnet/v2/pkg/logging"
|
||||
@@ -31,7 +33,7 @@ func NewWSServer(i socket.ISocketServer, logger logging.Logger, upgradeTimeout t
|
||||
}
|
||||
}
|
||||
|
||||
func (s *WSServer) Run(addr string, multicore bool, numEventLoop int, tcpNoDelay gnet.TCPSocketOpt, readBufferCap, writeBufferCap int, lockOSThread bool, reusePort, ticker bool, logger logging.Logger) error {
|
||||
func (s *WSServer) Run(addr string, multicore bool, numEventLoop int, tcpNoDelay gnet.TCPSocketOpt, readBufferCap, writeBufferCap int, lockOSThread bool, reusePort, ticker bool) error {
|
||||
return gnet.Run(
|
||||
s,
|
||||
addr,
|
||||
@@ -43,7 +45,7 @@ func (s *WSServer) Run(addr string, multicore bool, numEventLoop int, tcpNoDelay
|
||||
gnet.WithLockOSThread(lockOSThread),
|
||||
gnet.WithReusePort(reusePort),
|
||||
gnet.WithTicker(ticker),
|
||||
gnet.WithLogger(logger),
|
||||
gnet.WithLogger(s.logger),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -65,7 +67,7 @@ func (s *WSServer) OnOpen(c gnet.Conn) ([]byte, gnet.Action) {
|
||||
isUpgrade: false,
|
||||
openTime: time.Now().Unix(),
|
||||
buf: bytes.Buffer{},
|
||||
logger: s.logger,
|
||||
logger: log.GetLogger().Named(fmt.Sprintf("CONN %v", c.RemoteAddr().String())),
|
||||
wsMessageBuf: wsMessageBuf{
|
||||
curHeader: nil,
|
||||
cachedBuf: bytes.Buffer{},
|
||||
@@ -86,7 +88,7 @@ func (s *WSServer) OnClose(c gnet.Conn, err error) (action gnet.Action) {
|
||||
ws, ok := c.Context().(*WSConn)
|
||||
if ok {
|
||||
ws.isClose = true
|
||||
ws.logger.Warnf("connection close, err: %v", err)
|
||||
ws.logger.Infof("Connection close, err: %v", err)
|
||||
return gnet.Action(s.i.OnClose(ws, err))
|
||||
}
|
||||
return
|
||||
@@ -121,14 +123,10 @@ func (s *WSServer) OnTraffic(c gnet.Conn) gnet.Action {
|
||||
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 {
|
||||
if socket.OpCode(m.OpCode) == socket.OpPing || socket.OpCode(m.OpCode) == socket.OpPong {
|
||||
continue
|
||||
}
|
||||
a := s.i.OnMessage(ws, m.Payload)
|
||||
@@ -176,9 +174,8 @@ func (s *WSServer) OnTick() (delay time.Duration, action gnet.Action) {
|
||||
v.logger.Errorf("upgrade ws time out close socket error: %v", err)
|
||||
}
|
||||
}
|
||||
d, a := s.i.OnTick()
|
||||
delay = d
|
||||
action = gnet.Action(a)
|
||||
delay = 5 * time.Second
|
||||
action = gnet.Action(s.i.OnTick())
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -4,12 +4,13 @@ import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"errors"
|
||||
"io"
|
||||
"net/url"
|
||||
|
||||
"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接口
|
||||
@@ -22,7 +23,7 @@ type WSConn struct {
|
||||
isClose bool
|
||||
param map[string]interface{}
|
||||
openTime int64 // 开启连接的时间
|
||||
remoteAddr string // 远程ID地址
|
||||
remoteAddr string // 远程IP地址
|
||||
wsMessageBuf
|
||||
}
|
||||
|
||||
@@ -46,7 +47,7 @@ func (w *WSConn) readBytesBuf(c gnet.Conn) gnet.Action {
|
||||
read, err := c.Read(buf)
|
||||
if err != nil {
|
||||
if w.logger != nil {
|
||||
w.logger.Errorf("ws read bytes buf error", err)
|
||||
w.logger.Errorf("ws read bytes buf error: %v", err)
|
||||
}
|
||||
return gnet.Close
|
||||
}
|
||||
@@ -132,7 +133,7 @@ func (w *WSConn) readWsMessages() (messages []wsutil.Message, err error) {
|
||||
}
|
||||
} else { //数据不完整
|
||||
if w.logger != nil {
|
||||
w.logger.Debugf("ws read ws message incomplete data", in.Len(), dataLen)
|
||||
w.logger.Debugf("ws read ws message incomplete data ,%v,%v", in.Len(), dataLen)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,153 +0,0 @@
|
||||
// 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 rscommon
|
||||
|
||||
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, 0x37, 0x5a, 0x35, 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, 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
|
||||
}
|
||||
@@ -1,212 +0,0 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: ./proto/rs/rspb/service_user_grpc.pb.go
|
||||
|
||||
// Package mocks is a generated GoMock package.
|
||||
package mocks
|
||||
|
||||
import (
|
||||
context "context"
|
||||
reflect "reflect"
|
||||
|
||||
rspb "git.hlsq.asia/alex/service-common/proto/rs/rspb"
|
||||
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 *rspb.GetUserInfoReq, opts ...grpc.CallOption) (*rspb.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].(*rspb.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 *rspb.PhoneLoginReq, opts ...grpc.CallOption) (*rspb.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].(*rspb.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 *rspb.WxMiniLoginReq, opts ...grpc.CallOption) (*rspb.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].(*rspb.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 *rspb.GetUserInfoReq) (*rspb.GetUserInfoResp, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetUserInfo", arg0, arg1)
|
||||
ret0, _ := ret[0].(*rspb.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 *rspb.PhoneLoginReq) (*rspb.PhoneLoginResp, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "PhoneLogin", arg0, arg1)
|
||||
ret0, _ := ret[0].(*rspb.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 *rspb.WxMiniLoginReq) (*rspb.WxMiniLoginResp, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "WxMiniLogin", arg0, arg1)
|
||||
ret0, _ := ret[0].(*rspb.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))
|
||||
}
|
||||
@@ -1,342 +0,0 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.32.0
|
||||
// protoc v4.25.1
|
||||
// source: service_gateway.proto
|
||||
|
||||
package rspb
|
||||
|
||||
import (
|
||||
_ "git.hlsq.asia/alex/service-common/proto/rs/rscommon"
|
||||
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, 0x33, 0x5a, 0x31, 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, 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
|
||||
}
|
||||
@@ -1,178 +0,0 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.2.0
|
||||
// - protoc v4.25.1
|
||||
// source: service_gateway.proto
|
||||
|
||||
package rspb
|
||||
|
||||
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
@@ -1,910 +0,0 @@
|
||||
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
||||
// source: service_qgdzs.proto
|
||||
|
||||
/*
|
||||
Package rspb is a reverse proxy.
|
||||
|
||||
It translates gRPC into RESTful JSON APIs.
|
||||
*/
|
||||
package rspb
|
||||
|
||||
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_CustomAnswerQuestion_0(ctx context.Context, marshaler runtime.Marshaler, client QgdzsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq CustomAnswerQuestionReq
|
||||
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.CustomAnswerQuestion(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func local_request_Qgdzs_CustomAnswerQuestion_0(ctx context.Context, marshaler runtime.Marshaler, server QgdzsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq CustomAnswerQuestionReq
|
||||
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.CustomAnswerQuestion(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_CustomAnswerQuestion_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/CustomAnswerQuestion", runtime.WithHTTPPathPattern("/qgdzs/auth/custom_answer"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Qgdzs_CustomAnswerQuestion_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_CustomAnswerQuestion_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_CustomAnswerQuestion_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/CustomAnswerQuestion", runtime.WithHTTPPathPattern("/qgdzs/auth/custom_answer"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Qgdzs_CustomAnswerQuestion_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_CustomAnswerQuestion_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_CustomAnswerQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"qgdzs", "auth", "custom_answer"}, ""))
|
||||
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_CustomAnswerQuestion_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
|
||||
)
|
||||
@@ -1,573 +0,0 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.2.0
|
||||
// - protoc v4.25.1
|
||||
// source: service_qgdzs.proto
|
||||
|
||||
package rspb
|
||||
|
||||
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)
|
||||
// 自定义问答
|
||||
CustomAnswerQuestion(ctx context.Context, in *CustomAnswerQuestionReq, opts ...grpc.CallOption) (*CustomAnswerQuestionResp, 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) CustomAnswerQuestion(ctx context.Context, in *CustomAnswerQuestionReq, opts ...grpc.CallOption) (*CustomAnswerQuestionResp, error) {
|
||||
out := new(CustomAnswerQuestionResp)
|
||||
err := c.cc.Invoke(ctx, "/Qgdzs/CustomAnswerQuestion", 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)
|
||||
// 自定义问答
|
||||
CustomAnswerQuestion(context.Context, *CustomAnswerQuestionReq) (*CustomAnswerQuestionResp, 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) CustomAnswerQuestion(context.Context, *CustomAnswerQuestionReq) (*CustomAnswerQuestionResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CustomAnswerQuestion 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_CustomAnswerQuestion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CustomAnswerQuestionReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(QgdzsServer).CustomAnswerQuestion(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/Qgdzs/CustomAnswerQuestion",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(QgdzsServer).CustomAnswerQuestion(ctx, req.(*CustomAnswerQuestionReq))
|
||||
}
|
||||
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: "CustomAnswerQuestion",
|
||||
Handler: _Qgdzs_CustomAnswerQuestion_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",
|
||||
}
|
||||
@@ -1,555 +0,0 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.32.0
|
||||
// protoc v4.25.1
|
||||
// source: service_scene.proto
|
||||
|
||||
package rspb
|
||||
|
||||
import (
|
||||
_ "git.hlsq.asia/alex/service-common/proto/rs/rscommon"
|
||||
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, 0x33, 0x5a, 0x31, 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, 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
|
||||
}
|
||||
@@ -1,212 +0,0 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.2.0
|
||||
// - protoc v4.25.1
|
||||
// source: service_scene.proto
|
||||
|
||||
package rspb
|
||||
|
||||
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",
|
||||
}
|
||||
@@ -1,518 +0,0 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.32.0
|
||||
// protoc v4.25.1
|
||||
// source: service_user.proto
|
||||
|
||||
package rspb
|
||||
|
||||
import (
|
||||
_ "git.hlsq.asia/alex/service-common/proto/rs/rscommon"
|
||||
_ "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, 0x33,
|
||||
0x5a, 0x31, 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, 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
|
||||
}
|
||||
@@ -1,154 +0,0 @@
|
||||
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
||||
// source: service_user.proto
|
||||
|
||||
/*
|
||||
Package rspb is a reverse proxy.
|
||||
|
||||
It translates gRPC into RESTful JSON APIs.
|
||||
*/
|
||||
package rspb
|
||||
|
||||
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
|
||||
)
|
||||
@@ -1,179 +0,0 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.2.0
|
||||
// - protoc v4.25.1
|
||||
// source: service_user.proto
|
||||
|
||||
package rspb
|
||||
|
||||
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",
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.32.0
|
||||
// protoc v4.25.1
|
||||
// source: ss_common.proto
|
||||
|
||||
package sscommon
|
||||
|
||||
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, 0x37, 0x5a, 0x35, 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, 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
|
||||
}
|
||||
@@ -1,527 +0,0 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.32.0
|
||||
// protoc v4.25.1
|
||||
// source: action.proto
|
||||
|
||||
package sspb
|
||||
|
||||
import (
|
||||
_ "git.hlsq.asia/alex/service-common/proto/ss/sscommon"
|
||||
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, 0x33, 0x5a, 0x31, 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, 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
|
||||
}
|
||||
@@ -1,233 +0,0 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.32.0
|
||||
// protoc v4.25.1
|
||||
// source: define.proto
|
||||
|
||||
package sspb
|
||||
|
||||
import (
|
||||
_ "git.hlsq.asia/alex/service-common/proto/ss/sscommon"
|
||||
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, 0x33, 0x5a, 0x31, 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, 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
|
||||
}
|
||||
@@ -1,349 +0,0 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.32.0
|
||||
// protoc v4.25.1
|
||||
// source: service.proto
|
||||
|
||||
package sspb
|
||||
|
||||
import (
|
||||
_ "git.hlsq.asia/alex/service-common/proto/ss/sscommon"
|
||||
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, 0x33, 0x5a, 0x31, 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, 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
|
||||
}
|
||||
143
server/status.go
Normal file
143
server/status.go
Normal file
@@ -0,0 +1,143 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.hlsq.asia/alex/service-common/db/etcd"
|
||||
"git.hlsq.asia/alex/service-common/log"
|
||||
"go.etcd.io/etcd/api/v3/mvccpb"
|
||||
clientv3 "go.etcd.io/etcd/client/v3"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var (
|
||||
statusWg = &sync.WaitGroup{}
|
||||
statusStopFunc context.CancelFunc
|
||||
)
|
||||
|
||||
const (
|
||||
serverStatusKey = "/server/status" // 状态key
|
||||
)
|
||||
|
||||
type StatusType string
|
||||
|
||||
const (
|
||||
StatusInit StatusType = "init" // 初始化状态
|
||||
StatusRunning StatusType = "running" // 运行中
|
||||
StatusMaintenance StatusType = "maintenance" // 维护中
|
||||
StatusWhitelist StatusType = "whitelist" // 白名单模式
|
||||
)
|
||||
|
||||
var serverStatus *Status
|
||||
|
||||
type Status struct {
|
||||
etcdClient *etcd.Client
|
||||
status StatusType
|
||||
mu sync.RWMutex
|
||||
callbacks []func(status StatusType)
|
||||
}
|
||||
|
||||
func InitStatus() {
|
||||
serverStatus = &Status{
|
||||
etcdClient: etcd.GetClient(),
|
||||
status: StatusInit,
|
||||
mu: sync.RWMutex{},
|
||||
}
|
||||
}
|
||||
|
||||
func GetServerStatus() *Status {
|
||||
return serverStatus
|
||||
}
|
||||
|
||||
func ListenStatus(ready *sync.WaitGroup) {
|
||||
var stopCtx context.Context
|
||||
stopCtx, statusStopFunc = context.WithCancel(context.Background())
|
||||
statusWg.Add(1)
|
||||
|
||||
go func(stopCtx context.Context) {
|
||||
defer statusWg.Done()
|
||||
// 监听状态变化
|
||||
serverStatusResp, _ := serverStatus.etcdClient.Get(serverStatusKey)
|
||||
for _, kv := range serverStatusResp.Kvs {
|
||||
serverStatus.onStatusChange(clientv3.EventTypePut, string(kv.Key), string(kv.Value))
|
||||
}
|
||||
serverStatusWatchChan := serverStatus.etcdClient.Watch(serverStatusKey,
|
||||
clientv3.WithRev(serverStatusResp.Header.Revision+1))
|
||||
|
||||
ready.Done()
|
||||
for {
|
||||
select {
|
||||
case msg := <-serverStatusWatchChan:
|
||||
for _, event := range msg.Events {
|
||||
serverStatus.onStatusChange(event.Type, string(event.Kv.Key), string(event.Kv.Value))
|
||||
}
|
||||
case <-stopCtx.Done():
|
||||
return
|
||||
}
|
||||
}
|
||||
}(stopCtx)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func CloseStatus() {
|
||||
if statusStopFunc != nil {
|
||||
statusStopFunc()
|
||||
statusWg.Wait()
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Status) GetStatus() StatusType {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
|
||||
return s.status
|
||||
}
|
||||
|
||||
func (s *Status) CanAccess(usn int64) bool {
|
||||
var status StatusType
|
||||
s.mu.RLock()
|
||||
status = s.status
|
||||
s.mu.RUnlock()
|
||||
switch status {
|
||||
case StatusRunning:
|
||||
return true
|
||||
case StatusMaintenance:
|
||||
return false
|
||||
case StatusWhitelist:
|
||||
return GetServerWhitelist().CheckWhitelist(usn)
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Status) RegisterChangeCallback(fc func(status StatusType)) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
s.callbacks = append(s.callbacks, fc)
|
||||
}
|
||||
|
||||
func (s *Status) SetStatus(status string) {
|
||||
_, err := s.etcdClient.Put(serverStatusKey, status)
|
||||
if err != nil {
|
||||
log.Errorf("server status set failed: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (s *Status) onStatusChange(t mvccpb.Event_EventType, key, value string) {
|
||||
if key != serverStatusKey {
|
||||
return
|
||||
}
|
||||
|
||||
switch t {
|
||||
case clientv3.EventTypePut:
|
||||
s.mu.Lock()
|
||||
s.status = StatusType(value)
|
||||
s.mu.Unlock()
|
||||
for _, fc := range s.callbacks {
|
||||
fc(StatusType(value))
|
||||
}
|
||||
}
|
||||
}
|
||||
215
server/whitelist.go
Normal file
215
server/whitelist.go
Normal file
@@ -0,0 +1,215 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"git.hlsq.asia/alex/service-common/db/etcd"
|
||||
"git.hlsq.asia/alex/service-common/log"
|
||||
"go.etcd.io/etcd/api/v3/mvccpb"
|
||||
clientv3 "go.etcd.io/etcd/client/v3"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var (
|
||||
whiteListenWg = &sync.WaitGroup{}
|
||||
whiteListenStopFunc context.CancelFunc
|
||||
)
|
||||
|
||||
const (
|
||||
serverWhitelistKey = "/server/whitelist" // 白名单列表key
|
||||
serverFactoryWhitelistKey = "/server/factory_whitelist" // 工厂白名单列表key
|
||||
)
|
||||
|
||||
const whitelistUsnList = "usn_list" // usn白名单列表字段名
|
||||
|
||||
type Whitelist struct {
|
||||
etcdClient *etcd.Client
|
||||
mu sync.RWMutex
|
||||
whitelist map[int64]struct{}
|
||||
factoryWhitelist map[int64]struct{}
|
||||
}
|
||||
|
||||
var serverWhitelist *Whitelist
|
||||
|
||||
func InitWhitelist() {
|
||||
serverWhitelist = &Whitelist{
|
||||
etcdClient: etcd.GetClient(),
|
||||
mu: sync.RWMutex{},
|
||||
whitelist: make(map[int64]struct{}),
|
||||
factoryWhitelist: make(map[int64]struct{}),
|
||||
}
|
||||
}
|
||||
|
||||
func ListenWhitelist(ready *sync.WaitGroup) {
|
||||
var stopCtx context.Context
|
||||
stopCtx, whiteListenStopFunc = context.WithCancel(context.Background())
|
||||
whiteListenWg.Add(1)
|
||||
|
||||
go func(stopCtx context.Context) {
|
||||
defer whiteListenWg.Done()
|
||||
// 监听工厂白名单变化
|
||||
serverFactoryWhitelistResp, _ := serverWhitelist.etcdClient.Get(serverFactoryWhitelistKey)
|
||||
for _, kv := range serverFactoryWhitelistResp.Kvs {
|
||||
serverWhitelist.onFactoryWhitelistChange(clientv3.EventTypePut, string(kv.Key), string(kv.Value))
|
||||
}
|
||||
serverFactoryWhitelistWatchChan := serverWhitelist.etcdClient.Watch(serverFactoryWhitelistKey,
|
||||
clientv3.WithRev(serverFactoryWhitelistResp.Header.Revision+1))
|
||||
|
||||
// 监听白名单变化
|
||||
serverWhitelistResp, _ := serverWhitelist.etcdClient.Get(serverWhitelistKey)
|
||||
for _, kv := range serverWhitelistResp.Kvs {
|
||||
serverWhitelist.onWhitelistChange(clientv3.EventTypePut, string(kv.Key), string(kv.Value))
|
||||
}
|
||||
serverWhitelistWatchChan := serverWhitelist.etcdClient.Watch(serverWhitelistKey,
|
||||
clientv3.WithRev(serverWhitelistResp.Header.Revision+1))
|
||||
|
||||
ready.Done()
|
||||
for {
|
||||
select {
|
||||
case msg := <-serverFactoryWhitelistWatchChan:
|
||||
for _, event := range msg.Events {
|
||||
serverWhitelist.onFactoryWhitelistChange(event.Type, string(event.Kv.Key), string(event.Kv.Value))
|
||||
}
|
||||
case msg := <-serverWhitelistWatchChan:
|
||||
for _, event := range msg.Events {
|
||||
serverWhitelist.onWhitelistChange(event.Type, string(event.Kv.Key), string(event.Kv.Value))
|
||||
}
|
||||
case <-stopCtx.Done():
|
||||
return
|
||||
}
|
||||
}
|
||||
}(stopCtx)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func CloseWhitelist() {
|
||||
if whiteListenStopFunc != nil {
|
||||
whiteListenStopFunc()
|
||||
whiteListenWg.Wait()
|
||||
}
|
||||
}
|
||||
|
||||
func GetServerWhitelist() *Whitelist {
|
||||
return serverWhitelist
|
||||
}
|
||||
|
||||
func (s *Whitelist) GetWhitelist() map[int64]struct{} {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
|
||||
return s.whitelist
|
||||
}
|
||||
|
||||
func (s *Whitelist) SetWhitelist(whitelist []int64) {
|
||||
white := make(map[string]interface{})
|
||||
white[whitelistUsnList] = whitelist
|
||||
|
||||
whiteStr, err := json.Marshal(white)
|
||||
if err != nil {
|
||||
log.Errorf("server whitelist set failed: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = s.etcdClient.Put(serverWhitelistKey, string(whiteStr))
|
||||
if err != nil {
|
||||
log.Errorf("server whitelist set failed: %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Whitelist) CheckWhitelist(usn int64) bool {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
|
||||
_, ok := s.whitelist[usn]
|
||||
return ok
|
||||
}
|
||||
|
||||
func (s *Whitelist) GetFactoryWhitelist() map[int64]struct{} {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
|
||||
return s.factoryWhitelist
|
||||
}
|
||||
|
||||
func (s *Whitelist) SetFactoryWhitelist(whitelist []int64) {
|
||||
white := make(map[string]interface{})
|
||||
white[whitelistUsnList] = whitelist
|
||||
|
||||
whiteStr, err := json.Marshal(white)
|
||||
if err != nil {
|
||||
log.Errorf("server factory whitelist set failed: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = s.etcdClient.Put(serverFactoryWhitelistKey, string(whiteStr))
|
||||
if err != nil {
|
||||
log.Errorf("server factory whitelist set failed: %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Whitelist) CheckFactoryWhitelist(usn int64) bool {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
|
||||
_, ok := s.factoryWhitelist[usn]
|
||||
return ok
|
||||
}
|
||||
|
||||
func (s *Whitelist) onFactoryWhitelistChange(t mvccpb.Event_EventType, key, value string) {
|
||||
if key != serverFactoryWhitelistKey {
|
||||
return
|
||||
}
|
||||
|
||||
switch t {
|
||||
case clientv3.EventTypePut:
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
userSns := s.handlerWhitelistChange(value)
|
||||
|
||||
s.factoryWhitelist = make(map[int64]struct{})
|
||||
for _, usn := range userSns {
|
||||
s.factoryWhitelist[usn] = struct{}{}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Whitelist) onWhitelistChange(t mvccpb.Event_EventType, key, value string) {
|
||||
if key != serverWhitelistKey {
|
||||
return
|
||||
}
|
||||
|
||||
switch t {
|
||||
case clientv3.EventTypePut:
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
userSns := s.handlerWhitelistChange(value)
|
||||
|
||||
s.whitelist = make(map[int64]struct{})
|
||||
for _, usn := range userSns {
|
||||
s.whitelist[usn] = struct{}{}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Whitelist) handlerWhitelistChange(value string) []int64 {
|
||||
userSns := make([]int64, 0)
|
||||
|
||||
white := make(map[string]interface{})
|
||||
if err := json.Unmarshal([]byte(value), &white); err != nil {
|
||||
log.Errorf("server whitelist set failed: %v", err)
|
||||
return userSns
|
||||
}
|
||||
|
||||
if usnList, ok := white[whitelistUsnList].([]interface{}); ok {
|
||||
for _, usn := range usnList {
|
||||
userSns = append(userSns, int64(usn.(float64)))
|
||||
}
|
||||
}
|
||||
|
||||
return userSns
|
||||
}
|
||||
85
template/notice/constant.go
Normal file
85
template/notice/constant.go
Normal file
@@ -0,0 +1,85 @@
|
||||
package notice
|
||||
|
||||
import "git.hlsq.asia/alex/proto/topic"
|
||||
|
||||
const (
|
||||
// 在线比赛通知
|
||||
|
||||
onlineMatchNoticeStart = iota // 在线比赛开始提醒
|
||||
|
||||
// 锦标赛通知
|
||||
|
||||
tournamentMatchRemind // 比赛提醒
|
||||
tournamentMatchScoreAnnouncementPromoted // 成绩公告-晋级决赛
|
||||
tournamentMatchScoreAnnouncementNotPromoted // 成绩公告-未晋级决赛
|
||||
tournamentMatchScoreAnnouncementFinalEnd // 成绩公告-决赛结束后
|
||||
tournamentMatchRewardDistribute // 奖励发放
|
||||
tournamentMatchViolateNotice // 违规通报
|
||||
)
|
||||
|
||||
type TemplateNoticeLang string
|
||||
|
||||
const (
|
||||
ZhCN TemplateNoticeLang = "zh-CN"
|
||||
)
|
||||
|
||||
var defaultLang = ZhCN
|
||||
|
||||
var noticeTemplate = map[int32]map[TemplateNoticeLang]topic.TemplateNoticeData{
|
||||
onlineMatchNoticeStart: {
|
||||
ZhCN: topic.TemplateNoticeData{
|
||||
Title: "",
|
||||
Msg: "您的队友正在等待您开局,点击返回>>",
|
||||
XiaomiTemplateId: "P20513",
|
||||
CustomParam: `{"type":1, "param":[]}`,
|
||||
},
|
||||
},
|
||||
tournamentMatchRemind: {
|
||||
ZhCN: topic.TemplateNoticeData{
|
||||
Title: "比赛提醒",
|
||||
Msg: "%v锦标赛第%v轮将于明天开启,记得前来参赛!",
|
||||
XiaomiTemplateId: "P20086",
|
||||
CustomParam: `{"type":2, "param":["%v", "1", "%v"]}`,
|
||||
},
|
||||
},
|
||||
tournamentMatchScoreAnnouncementPromoted: {
|
||||
ZhCN: topic.TemplateNoticeData{
|
||||
Title: "成绩公告",
|
||||
Msg: "恭喜您在%v锦标赛晋级赛获得第%v名,成功晋级决赛!",
|
||||
XiaomiTemplateId: "P20088",
|
||||
CustomParam: `{"type":2, "param":["%v", "2", "%v"]}`,
|
||||
},
|
||||
},
|
||||
tournamentMatchScoreAnnouncementNotPromoted: {
|
||||
ZhCN: topic.TemplateNoticeData{
|
||||
Title: "成绩公告",
|
||||
Msg: "很遗憾,您在%v锦标赛晋级赛中未能进入下一阶段比赛。感谢您的参与!",
|
||||
XiaomiTemplateId: "P20088",
|
||||
CustomParam: `{"type":2, "param":["%v", "2", "%v"]}`,
|
||||
},
|
||||
},
|
||||
tournamentMatchScoreAnnouncementFinalEnd: {
|
||||
ZhCN: topic.TemplateNoticeData{
|
||||
Title: "成绩公告",
|
||||
Msg: "恭喜您在%v锦标赛决赛获得第%v名!",
|
||||
XiaomiTemplateId: "P20088",
|
||||
CustomParam: `{"type":2, "param":["%v", "2", "%v"]}`,
|
||||
},
|
||||
},
|
||||
tournamentMatchRewardDistribute: {
|
||||
ZhCN: topic.TemplateNoticeData{
|
||||
Title: "奖励发放",
|
||||
Msg: "%v锦标赛于%v月%v日成功完赛,点击查看最终排名!",
|
||||
XiaomiTemplateId: "P20084",
|
||||
CustomParam: `{"type":2, "param":["%v", "2", "%v"]}`,
|
||||
},
|
||||
},
|
||||
tournamentMatchViolateNotice: {
|
||||
ZhCN: topic.TemplateNoticeData{
|
||||
Title: "违规通报",
|
||||
Msg: "后台检测到您在%v锦标赛第%v轮比赛中存在违规情况,本次比赛成绩无效,有任何疑问请联系客服。",
|
||||
XiaomiTemplateId: "P20085",
|
||||
CustomParam: `{"type":0, "param":[]}`,
|
||||
},
|
||||
},
|
||||
}
|
||||
120
template/notice/notice.go
Normal file
120
template/notice/notice.go
Normal file
@@ -0,0 +1,120 @@
|
||||
package notice
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.hlsq.asia/alex/proto/topic"
|
||||
)
|
||||
|
||||
// GetOnlineMatchNoticeStart 在线比赛开始通知
|
||||
// lang 语言
|
||||
func GetOnlineMatchNoticeStart(lang ...TemplateNoticeLang) topic.TemplateNoticeData {
|
||||
if len(lang) != 0 {
|
||||
defaultLang = lang[0]
|
||||
}
|
||||
|
||||
return noticeTemplate[onlineMatchNoticeStart][defaultLang]
|
||||
}
|
||||
|
||||
// GetTournamentMatchRemind 比赛提醒
|
||||
// name 锦标赛名称
|
||||
// wheel 锦标赛轮次
|
||||
// sn 锦标赛sn
|
||||
// channel 频道名称
|
||||
func GetTournamentMatchRemind(name string, wheel int32, sn int64, channelName string,
|
||||
lang ...TemplateNoticeLang) topic.TemplateNoticeData {
|
||||
if len(lang) != 0 {
|
||||
defaultLang = lang[0]
|
||||
}
|
||||
|
||||
data := noticeTemplate[tournamentMatchRemind][defaultLang]
|
||||
data.Msg = fmt.Sprintf(data.Msg, name, wheel)
|
||||
data.CustomParam = fmt.Sprintf(data.CustomParam, sn, channelName)
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
// GetTournamentMatchScoreAnnouncementPromoted 成绩公告-晋级决赛
|
||||
// name 锦标赛名称
|
||||
// ranking 排名
|
||||
// sn 锦标赛sn
|
||||
// channel 频道名称
|
||||
func GetTournamentMatchScoreAnnouncementPromoted(name string, ranking int32, sn int64, channelName string,
|
||||
lang ...TemplateNoticeLang) topic.TemplateNoticeData {
|
||||
if len(lang) != 0 {
|
||||
defaultLang = lang[0]
|
||||
}
|
||||
|
||||
data := noticeTemplate[tournamentMatchScoreAnnouncementPromoted][defaultLang]
|
||||
data.Msg = fmt.Sprintf(data.Msg, name, ranking)
|
||||
data.CustomParam = fmt.Sprintf(data.CustomParam, sn, channelName)
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
// GetTournamentMatchScoreAnnouncementNotPromoted 成绩公告-未晋级决赛
|
||||
// name 锦标赛名称
|
||||
// sn 锦标赛sn
|
||||
// channel 频道名称
|
||||
func GetTournamentMatchScoreAnnouncementNotPromoted(name string, sn int64, channelName string,
|
||||
lang ...TemplateNoticeLang) topic.TemplateNoticeData {
|
||||
if len(lang) != 0 {
|
||||
defaultLang = lang[0]
|
||||
}
|
||||
|
||||
data := noticeTemplate[tournamentMatchScoreAnnouncementNotPromoted][defaultLang]
|
||||
data.Msg = fmt.Sprintf(data.Msg, name)
|
||||
data.CustomParam = fmt.Sprintf(data.CustomParam, sn, channelName)
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
// GetTournamentMatchScoreAnnouncementFinalEnd 成绩公告-决赛结束后
|
||||
// name 锦标赛名称
|
||||
// ranking 排名
|
||||
// sn 锦标赛sn
|
||||
// channel 频道名称
|
||||
func GetTournamentMatchScoreAnnouncementFinalEnd(name string, ranking int32, sn int64, channelName string,
|
||||
lang ...TemplateNoticeLang) topic.TemplateNoticeData {
|
||||
if len(lang) != 0 {
|
||||
defaultLang = lang[0]
|
||||
}
|
||||
|
||||
data := noticeTemplate[tournamentMatchScoreAnnouncementFinalEnd][defaultLang]
|
||||
data.Msg = fmt.Sprintf(data.Msg, name, ranking)
|
||||
data.CustomParam = fmt.Sprintf(data.CustomParam, sn, channelName)
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
// GetTournamentMatchRewardDistribute 奖励发放
|
||||
// name 锦标赛名称
|
||||
// month 月份
|
||||
// day 日
|
||||
// sn 锦标赛sn
|
||||
// channel 频道名称
|
||||
func GetTournamentMatchRewardDistribute(name string, month, day int32, sn int64, channelName string,
|
||||
lang ...TemplateNoticeLang) topic.TemplateNoticeData {
|
||||
if len(lang) != 0 {
|
||||
defaultLang = lang[0]
|
||||
}
|
||||
|
||||
data := noticeTemplate[tournamentMatchRewardDistribute][defaultLang]
|
||||
data.Msg = fmt.Sprintf(data.Msg, name, month, day)
|
||||
data.CustomParam = fmt.Sprintf(data.CustomParam, sn, channelName)
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
// GetTournamentMatchViolateNotice 违规通报
|
||||
// name 锦标赛名称
|
||||
// wheel 锦标赛轮次
|
||||
func GetTournamentMatchViolateNotice(name string, wheel int32, lang ...TemplateNoticeLang) topic.TemplateNoticeData {
|
||||
if len(lang) != 0 {
|
||||
defaultLang = lang[0]
|
||||
}
|
||||
|
||||
data := noticeTemplate[tournamentMatchViolateNotice][defaultLang]
|
||||
data.Msg = fmt.Sprintf(data.Msg, name, wheel)
|
||||
|
||||
return data
|
||||
}
|
||||
37
template/sms/lianlu.go
Normal file
37
template/sms/lianlu.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package sms
|
||||
|
||||
//
|
||||
//import "git.hlsq.asia/alex/proto/topic"
|
||||
//
|
||||
//type CountryCode string
|
||||
//
|
||||
//const (
|
||||
// CountryCodeChina CountryCode = "+86" // 中国
|
||||
// CountryCodeHongKong CountryCode = "+852" // 中国香港
|
||||
// CountryCodeMacau CountryCode = "+853" // 中国澳门
|
||||
// CountryCodeTaiwan CountryCode = "+886" // 中国台湾
|
||||
// CountryCodeJapan CountryCode = "+81" // 日本
|
||||
// CountryCodeSouthKorea CountryCode = "+82" // 韩国
|
||||
//)
|
||||
//
|
||||
//const (
|
||||
// TemplateCodeVerificationCodeChinese topic.SmsTemplateCode = "70630138" // 验证码(中文)
|
||||
// TemplateCodeVerificationCodeEnglish topic.SmsTemplateCode = "54236" // 验证码(英文)
|
||||
// TemplateCodeVerificationCodeJapanese topic.SmsTemplateCode = "54270" // 验证码(日文)
|
||||
// TemplateCodeVerificationCodeKorean topic.SmsTemplateCode = "54271" // 验证码(韩文)
|
||||
// TemplateCodeVerificationCodeChineseTraditional topic.SmsTemplateCode = "54272" // 验证码(繁体中文)
|
||||
//)
|
||||
//
|
||||
//func GetTemplateCodeVerificationCodeByCountryCode(countryCode CountryCode) topic.SmsTemplateCode {
|
||||
// switch countryCode {
|
||||
// case CountryCodeChina:
|
||||
// return TemplateCodeVerificationCodeChinese
|
||||
// case CountryCodeHongKong, CountryCodeMacau, CountryCodeTaiwan:
|
||||
// return TemplateCodeVerificationCodeChineseTraditional
|
||||
// case CountryCodeJapan:
|
||||
// return TemplateCodeVerificationCodeJapanese
|
||||
// case CountryCodeSouthKorea:
|
||||
// return TemplateCodeVerificationCodeKorean
|
||||
// }
|
||||
// return TemplateCodeVerificationCodeEnglish
|
||||
//}
|
||||
36
template/sms/zhongtian.go
Normal file
36
template/sms/zhongtian.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package sms
|
||||
|
||||
import "git.hlsq.asia/alex/proto/topic"
|
||||
|
||||
type CountryCode string
|
||||
|
||||
const (
|
||||
CountryCodeChina CountryCode = "+86" // 中国
|
||||
CountryCodeHongKong CountryCode = "+852" // 中国香港
|
||||
CountryCodeMacau CountryCode = "+853" // 中国澳门
|
||||
CountryCodeTaiwan CountryCode = "+886" // 中国台湾
|
||||
CountryCodeJapan CountryCode = "+81" // 日本
|
||||
CountryCodeSouthKorea CountryCode = "+82" // 韩国
|
||||
)
|
||||
|
||||
const (
|
||||
TemplateCodeVerificationCodeChinese topic.SmsTemplateCode = "【巢云互动】您的验证码是:%v,该验证码5分钟内有效,请勿泄漏于他人!" // 验证码(中文)
|
||||
TemplateCodeVerificationCodeEnglish topic.SmsTemplateCode = "[NEXQUB] Your verification code is %v. It is valid for 5 minutes. Please do not share it with anyone." // 验证码(英文)
|
||||
TemplateCodeVerificationCodeJapanese topic.SmsTemplateCode = "[NEXQUB] 認証コード:%v 有効期限5分。このコードを他人に教えないでください。" // 验证码(日文)
|
||||
TemplateCodeVerificationCodeKorean topic.SmsTemplateCode = "[NEXQUB] 인증번호 %v 유효시간 5분. 타인과 공유하지 마세요." // 验证码(韩文)
|
||||
TemplateCodeVerificationCodeChineseTraditional topic.SmsTemplateCode = "[NEXQUB] 您的驗證碼是:%v,5分鐘內有效,請勿向他人提供。" // 验证码(繁体中文)
|
||||
)
|
||||
|
||||
func GetTemplateCodeVerificationCodeByCountryCode(countryCode CountryCode) topic.SmsTemplateCode {
|
||||
switch countryCode {
|
||||
case CountryCodeChina:
|
||||
return TemplateCodeVerificationCodeChinese
|
||||
case CountryCodeHongKong, CountryCodeMacau, CountryCodeTaiwan:
|
||||
return TemplateCodeVerificationCodeChineseTraditional
|
||||
case CountryCodeJapan:
|
||||
return TemplateCodeVerificationCodeJapanese
|
||||
case CountryCodeSouthKorea:
|
||||
return TemplateCodeVerificationCodeKorean
|
||||
}
|
||||
return TemplateCodeVerificationCodeEnglish
|
||||
}
|
||||
6
utils/admin_info.go
Normal file
6
utils/admin_info.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package utils
|
||||
|
||||
type AdminInfo struct {
|
||||
Usn int64 `redis:"usn"`
|
||||
RoleCode string `redis:"roleCode"`
|
||||
}
|
||||
13
utils/channel.go
Normal file
13
utils/channel.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.hlsq.asia/alex/proto/proto/ss/sspb"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// GetChannelName 获得频道名称
|
||||
func GetChannelName(t sspb.ChannelType, sn int64) string {
|
||||
s := sspb.ChannelType_name[int32(t)]
|
||||
return fmt.Sprintf("%v-%v", strings.TrimPrefix(s, "CHANNEL_TYPE_"), sn)
|
||||
}
|
||||
@@ -9,8 +9,13 @@ import (
|
||||
)
|
||||
|
||||
type WrapErrors struct {
|
||||
message string
|
||||
trace []string
|
||||
original error
|
||||
message string
|
||||
trace []string
|
||||
}
|
||||
|
||||
func (e *WrapErrors) Original() error {
|
||||
return e.original
|
||||
}
|
||||
|
||||
func (e *WrapErrors) Error() string {
|
||||
@@ -30,7 +35,9 @@ func ErrorsWrap(err error, message ...string) error {
|
||||
}
|
||||
var e *WrapErrors
|
||||
if !errors.As(err, &e) {
|
||||
e = &WrapErrors{}
|
||||
e = &WrapErrors{
|
||||
original: err,
|
||||
}
|
||||
}
|
||||
if len(message) > 0 {
|
||||
e.message = fmt.Sprintf("%v: %v", message[0], err.Error())
|
||||
@@ -47,7 +54,9 @@ func ErrorsWrapF(err error, message string, a ...any) error {
|
||||
}
|
||||
var e *WrapErrors
|
||||
if !errors.As(err, &e) {
|
||||
e = &WrapErrors{}
|
||||
e = &WrapErrors{
|
||||
original: err,
|
||||
}
|
||||
}
|
||||
e.message = fmt.Sprintf("%v: %v", fmt.Sprintf(message, a...), err.Error())
|
||||
e.trace = append(e.trace, getErrorPath())
|
||||
|
||||
32
utils/jwt.go
32
utils/jwt.go
@@ -37,3 +37,35 @@ func ParseToken(tokenString string, secret string) (*Claims, error) {
|
||||
}
|
||||
return claims, nil
|
||||
}
|
||||
|
||||
type PhoneClaims struct {
|
||||
Phone string `json:"phone"`
|
||||
jwt.RegisteredClaims
|
||||
}
|
||||
|
||||
func GenPhoneToken(phone string, secret string, expires time.Duration) (string, error) {
|
||||
token := jwt.NewWithClaims(jwt.SigningMethodHS256, PhoneClaims{
|
||||
Phone: phone,
|
||||
RegisteredClaims: jwt.RegisteredClaims{
|
||||
ExpiresAt: jwt.NewNumericDate(time.Now().Add(expires)),
|
||||
},
|
||||
})
|
||||
return token.SignedString([]byte(secret))
|
||||
}
|
||||
|
||||
func ParsePhoneToken(tokenString string, secret string) (*PhoneClaims, error) {
|
||||
if tokenString == "" {
|
||||
return nil, errors.New("invalid token")
|
||||
}
|
||||
claims := &PhoneClaims{}
|
||||
token, err := jwt.ParseWithClaims(tokenString, claims, func(_ *jwt.Token) (interface{}, error) {
|
||||
return []byte(secret), nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !token.Valid {
|
||||
return nil, errors.New("invalid token")
|
||||
}
|
||||
return claims, nil
|
||||
}
|
||||
|
||||
82
utils/locator/locator.go
Normal file
82
utils/locator/locator.go
Normal file
@@ -0,0 +1,82 @@
|
||||
package locator
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"git.hlsq.asia/alex/service-common/db/redis"
|
||||
"git.hlsq.asia/alex/service-common/log"
|
||||
)
|
||||
|
||||
// 玩家定位器
|
||||
|
||||
const (
|
||||
KeyGatewayInfo = "gateway:info:%v"
|
||||
HFieldInfoGatewaySID = "gateway_sid_%v"
|
||||
)
|
||||
|
||||
var (
|
||||
scriptBindGatewaySha1 string
|
||||
scriptBindGateway = `
|
||||
local gateway_key = KEYS[1]
|
||||
local field_key = ARGV[1]
|
||||
local new_sid = ARGV[2]
|
||||
|
||||
local existing_sid = redis.call("HGET", gateway_key, field_key)
|
||||
if existing_sid then
|
||||
return 0
|
||||
end
|
||||
|
||||
redis.call("HSET", gateway_key, field_key, new_sid)
|
||||
return 1
|
||||
`
|
||||
)
|
||||
|
||||
func NewLocator(ctx context.Context, usn int64, platform int32) *Locator {
|
||||
return &Locator{
|
||||
ctx: ctx,
|
||||
usn: usn,
|
||||
platform: platform,
|
||||
}
|
||||
}
|
||||
|
||||
type Locator struct {
|
||||
ctx context.Context
|
||||
usn int64
|
||||
platform int32
|
||||
}
|
||||
|
||||
// BindGateway 绑定网关
|
||||
func (l *Locator) BindGateway(gatewaySID int64) bool {
|
||||
if scriptBindGatewaySha1 == "" {
|
||||
scriptBindGatewaySha1 = redis.GetClient().ScriptLoad(l.ctx, scriptBindGateway).Val()
|
||||
}
|
||||
|
||||
result, err := redis.GetClient().EvalSha(
|
||||
l.ctx,
|
||||
scriptBindGatewaySha1,
|
||||
[]string{fmt.Sprintf(KeyGatewayInfo, l.usn)},
|
||||
fmt.Sprintf(HFieldInfoGatewaySID, l.platform),
|
||||
gatewaySID,
|
||||
).Int64()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
if result == 0 {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// UnbindGateway 解绑网关
|
||||
func (l *Locator) UnbindGateway() {
|
||||
err := redis.GetClient().HDel(l.ctx, fmt.Sprintf(KeyGatewayInfo, l.usn), fmt.Sprintf(HFieldInfoGatewaySID, l.platform)).Err()
|
||||
if err != nil {
|
||||
log.Errorf("UnbindGateway Failed %v-%v, err: %v", l.usn, l.platform, err)
|
||||
}
|
||||
}
|
||||
|
||||
// LocateGateway 定位网关
|
||||
func (l *Locator) LocateGateway() int64 {
|
||||
sid, _ := redis.GetClient().HGet(l.ctx, fmt.Sprintf(KeyGatewayInfo, l.usn), fmt.Sprintf(HFieldInfoGatewaySID, l.platform)).Int64()
|
||||
return sid
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"github.com/shopspring/decimal"
|
||||
"math/rand"
|
||||
"strconv"
|
||||
)
|
||||
@@ -26,3 +27,86 @@ func StringToInt64(s string) int64 {
|
||||
func Int64ToString(i int64) string {
|
||||
return strconv.FormatInt(i, 10)
|
||||
}
|
||||
|
||||
// AddFloat64 对浮点数求和
|
||||
func AddFloat64(places int32, number ...float64) float64 {
|
||||
if len(number) == 0 {
|
||||
return 0
|
||||
}
|
||||
result := decimal.NewFromFloat(0)
|
||||
for _, n := range number {
|
||||
result = result.Add(decimal.NewFromFloat(n))
|
||||
}
|
||||
return result.Round(places).InexactFloat64()
|
||||
}
|
||||
|
||||
// SubFloat64 对浮点数求差
|
||||
func SubFloat64(places int32, number ...float64) float64 {
|
||||
if len(number) == 0 {
|
||||
return 0
|
||||
}
|
||||
result := decimal.NewFromFloat(number[0])
|
||||
for i := 1; i < len(number); i++ {
|
||||
result = result.Sub(decimal.NewFromFloat(number[i]))
|
||||
}
|
||||
return result.Round(places).InexactFloat64()
|
||||
}
|
||||
|
||||
// MulFloat64 对浮点数求积
|
||||
func MulFloat64(places int32, number ...float64) float64 {
|
||||
if len(number) == 0 {
|
||||
return 0
|
||||
}
|
||||
result := decimal.NewFromFloat(1)
|
||||
for _, n := range number {
|
||||
result = result.Mul(decimal.NewFromFloat(n))
|
||||
}
|
||||
return result.Round(places).InexactFloat64()
|
||||
}
|
||||
|
||||
// DivFloat64 对浮点数求商
|
||||
func DivFloat64(places int32, number ...float64) float64 {
|
||||
if len(number) == 0 {
|
||||
return 0
|
||||
}
|
||||
result := decimal.NewFromFloat(number[0])
|
||||
for i := 1; i < len(number); i++ {
|
||||
if number[i] == 0 {
|
||||
return 0 // 避免除以零
|
||||
}
|
||||
result = result.Div(decimal.NewFromFloat(number[i]))
|
||||
}
|
||||
return result.Round(places).InexactFloat64()
|
||||
}
|
||||
|
||||
// MaxInt32 返回两个 int32 中的较大值
|
||||
func MaxInt32(a, b int32) int32 {
|
||||
if a > b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// MinInt32 返回两个 int32 中的较小值
|
||||
func MinInt32(a, b int32) int32 {
|
||||
if a < b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// MaxFloat64 返回两个 float64 中的较大值
|
||||
func MaxFloat64(a, b float64) float64 {
|
||||
if a > b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// MinFloat64 返回两个 float64 中的较小值
|
||||
func MinFloat64(a, b float64) float64 {
|
||||
if a < b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
62
utils/page.go
Normal file
62
utils/page.go
Normal file
@@ -0,0 +1,62 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"math"
|
||||
|
||||
"git.hlsq.asia/alex/proto/proto/rs/rscommon"
|
||||
"gorm.io/gen/field"
|
||||
)
|
||||
|
||||
func PageGetOffSet(page *rscommon.PageArgs) int {
|
||||
if page == nil || page.PageSize <= 0 {
|
||||
return 0
|
||||
}
|
||||
return int((page.PageIndex - 1) * page.PageSize)
|
||||
}
|
||||
|
||||
func CalcTotalPage(totalCount, pageSize int32) int32 {
|
||||
if pageSize <= 0 {
|
||||
return 0
|
||||
}
|
||||
return int32(math.Ceil(float64(totalCount) / float64(pageSize)))
|
||||
}
|
||||
|
||||
func BuildPageInfoReply(page *rscommon.PageArgs, totalCount int32) *rscommon.PageInfoReply {
|
||||
if page == nil {
|
||||
page = &rscommon.PageArgs{PageIndex: 1, PageSize: 10}
|
||||
}
|
||||
if page.PageSize <= 0 {
|
||||
page.PageSize = 10
|
||||
}
|
||||
if page.PageIndex <= 0 {
|
||||
page.PageIndex = 1
|
||||
}
|
||||
if totalCount <= 0 {
|
||||
totalCount = 0
|
||||
return &rscommon.PageInfoReply{
|
||||
PageIndex: page.PageIndex,
|
||||
PageSize: page.PageSize,
|
||||
TotalCount: totalCount,
|
||||
}
|
||||
}
|
||||
return &rscommon.PageInfoReply{
|
||||
PageIndex: page.PageIndex,
|
||||
PageSize: page.PageSize,
|
||||
TotalCount: totalCount,
|
||||
}
|
||||
}
|
||||
|
||||
func GetOrderInfo(orderList []*rscommon.OrderInfo, getField func(field string) field.OrderExpr) []field.Expr {
|
||||
orders := make([]field.Expr, 0, len(orderList))
|
||||
for _, order := range orderList {
|
||||
expr := getField(order.Field)
|
||||
if expr != nil {
|
||||
if order.Asc {
|
||||
orders = append(orders, expr.Asc())
|
||||
} else {
|
||||
orders = append(orders, expr.Desc())
|
||||
}
|
||||
}
|
||||
}
|
||||
return orders
|
||||
}
|
||||
33
utils/pool_object.go
Normal file
33
utils/pool_object.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
type ObjectPool[T any] struct {
|
||||
pool sync.Pool
|
||||
}
|
||||
|
||||
func NewObjectPool[T any]() *ObjectPool[T] {
|
||||
return &ObjectPool[T]{
|
||||
pool: sync.Pool{
|
||||
New: func() any {
|
||||
return new(T)
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (p *ObjectPool[T]) Get() *T {
|
||||
return p.pool.Get().(*T)
|
||||
}
|
||||
|
||||
func (p *ObjectPool[T]) Put(obj *T) {
|
||||
*obj = zero[T]()
|
||||
p.pool.Put(obj)
|
||||
}
|
||||
|
||||
func zero[T any]() T {
|
||||
var z T
|
||||
return z
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/alex/service-common/log"
|
||||
"sync"
|
||||
)
|
||||
|
||||
@@ -27,6 +28,11 @@ func WorkerPool(tasks []interface{}, taskFunc func(interface{}), maxWorkers ...i
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
defer func() {
|
||||
if e := recover(); e != nil {
|
||||
log.Errorf("WorkerPool panic: %v", e)
|
||||
}
|
||||
}()
|
||||
for task := range jobs {
|
||||
taskFunc(task)
|
||||
}
|
||||
19
utils/qr.go
Normal file
19
utils/qr.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
|
||||
"github.com/skip2/go-qrcode"
|
||||
)
|
||||
|
||||
func GetQRCodeIO(content string, size ...int) string {
|
||||
s := 260 // 写死尺寸 260*260
|
||||
if len(size) > 0 {
|
||||
s = size[0]
|
||||
}
|
||||
png, err := qrcode.Encode(content, qrcode.High, s)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return "data:image/png;base64," + base64.StdEncoding.EncodeToString(png)
|
||||
}
|
||||
59
utils/replay.go
Normal file
59
utils/replay.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"git.hlsq.asia/alex/service-common/db/redis"
|
||||
"git.hlsq.asia/alex/service-common/net/http/httpresp"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
replayTTL = 2 * time.Minute // 防重放缓存有效期
|
||||
lockTTL = 10 * time.Second // 分布式锁有效期
|
||||
)
|
||||
|
||||
// WrapPreventReplay 防止重放请求
|
||||
func WrapPreventReplay[T any](ctx context.Context, usn int64, fun func() (T, error)) (T, error) {
|
||||
var zero T
|
||||
key := ""
|
||||
if md, ok := metadata.FromIncomingContext(ctx); ok {
|
||||
ridArr := md.Get("Request-Id")
|
||||
if len(ridArr) == 0 || ridArr[0] == "" {
|
||||
return fun()
|
||||
}
|
||||
key = fmt.Sprintf("cache:replay:%v:%v", usn, ridArr[0])
|
||||
} else {
|
||||
return fun()
|
||||
}
|
||||
|
||||
// 先查缓存,命中直接返回
|
||||
if val := getReplayCache[T](ctx, key); val != nil {
|
||||
return *val, nil
|
||||
}
|
||||
|
||||
// 尝试抢分布式锁,抢到就执行,没抢到报错
|
||||
lockKey := fmt.Sprintf("%s:lock", key)
|
||||
locked, err := redis.GetClient().SetNX(ctx, lockKey, "1", lockTTL).Result()
|
||||
if err == nil && locked {
|
||||
defer redis.GetClient().Del(ctx, lockKey)
|
||||
result, err := fun()
|
||||
// 这里报错了是没有缓存的
|
||||
if err != nil {
|
||||
return zero, err
|
||||
}
|
||||
redis.GetCacheClient().Set(ctx, key, result, replayTTL)
|
||||
return result, nil
|
||||
}
|
||||
return zero, httpresp.RequestTooFast
|
||||
}
|
||||
|
||||
// getReplayCache 从 Redis 读取重放缓存
|
||||
func getReplayCache[T any](ctx context.Context, key string) *T {
|
||||
var dst T
|
||||
if redis.GetCacheClient().Get(ctx, key, &dst) {
|
||||
return &dst
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package utils
|
||||
import (
|
||||
"context"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type UserSession struct {
|
||||
@@ -17,6 +19,17 @@ func (us *UserSession) GetUsnKey() string {
|
||||
return "usn"
|
||||
}
|
||||
|
||||
func (us *UserSession) GetAccessTokenKey() string {
|
||||
return "at"
|
||||
}
|
||||
|
||||
func (us *UserSession) GetRefreshTokenKey() string {
|
||||
return "rt"
|
||||
}
|
||||
|
||||
// Deprecated: 请使用 ShouldGetUsn 替代,示例:
|
||||
// usn := utils.ShouldGetUsn(ctx)
|
||||
// 不需要判断 usn 是否为 0,只有不鉴权接口的 usn 才可能是 0。
|
||||
func ShouldBindUsn(ctx context.Context, usn *int64) bool {
|
||||
if md, ok := metadata.FromIncomingContext(ctx); ok {
|
||||
usnArr := md.Get("X-Usn")
|
||||
@@ -27,3 +40,30 @@ func ShouldBindUsn(ctx context.Context, usn *int64) bool {
|
||||
}
|
||||
return *usn != 0
|
||||
}
|
||||
|
||||
func ShouldGetUsn(ctx context.Context) int64 {
|
||||
if md, ok := metadata.FromIncomingContext(ctx); ok {
|
||||
usnArr := md.Get("X-Usn")
|
||||
if len(usnArr) == 0 || usnArr[0] == "" {
|
||||
return 0
|
||||
}
|
||||
return StringToInt64(usnArr[0])
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func GetPlatformAndUsn(token string) (int32, int64, bool) {
|
||||
str := strings.Split(token, ":")
|
||||
if len(str) != 3 {
|
||||
return 0, 0, false
|
||||
}
|
||||
platform, err := strconv.Atoi(str[0])
|
||||
if err != nil {
|
||||
return 0, 0, false
|
||||
}
|
||||
usn, err := strconv.Atoi(str[1])
|
||||
if err != nil {
|
||||
return 0, 0, false
|
||||
}
|
||||
return int32(platform), int64(usn), true
|
||||
}
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"github.com/bwmarrin/snowflake"
|
||||
"github.com/sony/sonyflake/v2"
|
||||
"log"
|
||||
)
|
||||
|
||||
var instance *snowflake.Node
|
||||
var instance *sonyflake.Sonyflake
|
||||
|
||||
func InitSnowflake(node int64) *snowflake.Node {
|
||||
n, err := snowflake.NewNode(node)
|
||||
func InitSnowflake(node int64) *sonyflake.Sonyflake {
|
||||
n, err := sonyflake.New(sonyflake.Settings{
|
||||
BitsMachineID: 10,
|
||||
MachineID: func() (int, error) {
|
||||
return int(node), nil
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("create snowflake's node failed: %v", err)
|
||||
}
|
||||
@@ -16,9 +21,10 @@ func InitSnowflake(node int64) *snowflake.Node {
|
||||
return instance
|
||||
}
|
||||
|
||||
func SnowflakeInstance() *snowflake.Node {
|
||||
func SnowflakeInt64() int64 {
|
||||
if instance == nil {
|
||||
log.Fatal("snowflake's not init")
|
||||
}
|
||||
return instance
|
||||
id, _ := instance.NextID()
|
||||
return id
|
||||
}
|
||||
|
||||
49
utils/string.go
Normal file
49
utils/string.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
// GetMD5Encode 获取Md5编码
|
||||
func GetMD5Encode(data string) string {
|
||||
h := md5.New()
|
||||
h.Write([]byte(data))
|
||||
return hex.EncodeToString(h.Sum(nil))
|
||||
}
|
||||
|
||||
const (
|
||||
StringChars1 = "0123456789"
|
||||
StringChars2 = "abcdefghijklmnopqrstuvwxyz"
|
||||
StringChars3 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
StringChars4 = "0123456789abcdefghijklmnopqrstuvwxyz"
|
||||
StringChars5 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
StringChars6 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
StringChars7 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
)
|
||||
|
||||
// RandomString 获取随机字符串
|
||||
func RandomString(chars string, length int8) string {
|
||||
result := make([]byte, length)
|
||||
for i := int8(0); i < length; i++ {
|
||||
result[i] = chars[rand.Intn(len(chars))]
|
||||
if i == 0 && result[i] == '0' {
|
||||
i--
|
||||
}
|
||||
}
|
||||
return string(result)
|
||||
}
|
||||
|
||||
// GetDisplayWidth 获取字符串长度
|
||||
func GetDisplayWidth(text string) int {
|
||||
width := 0
|
||||
for _, r := range text {
|
||||
if r <= 0x7F {
|
||||
width += 1 // ASCII,半角
|
||||
} else {
|
||||
width += 2 // CJK、日文假名等,全角
|
||||
}
|
||||
}
|
||||
return width
|
||||
}
|
||||
26
utils/time.go
Normal file
26
utils/time.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"math"
|
||||
"time"
|
||||
)
|
||||
|
||||
// CalcDaysDiff 计算两个日期相差多少天
|
||||
func CalcDaysDiff(one, two time.Time) int32 {
|
||||
oneZero := time.Date(
|
||||
one.Year(),
|
||||
one.Month(),
|
||||
one.Day(),
|
||||
0, 0, 0, 0,
|
||||
time.Local,
|
||||
)
|
||||
twoZero := time.Date(
|
||||
two.Year(),
|
||||
two.Month(),
|
||||
two.Day(),
|
||||
0, 0, 0, 0,
|
||||
time.Local,
|
||||
)
|
||||
// 计算相差天数
|
||||
return int32(math.Abs(oneZero.Sub(twoZero).Hours() / 24))
|
||||
}
|
||||
Reference in New Issue
Block a user