Compare commits

...

15 Commits

45 changed files with 2991 additions and 828 deletions

View File

@@ -27,6 +27,7 @@ type DBConfig struct {
MySQL map[string]*MySQLConfig `yaml:"mysql"`
Mongo map[string]*MongoConfig `yaml:"mongo"`
Redis *RedisConfig `yaml:"redis"`
Kafka *KafkaConfig `yaml:"kafka"`
}
type EtcdConfig struct {
@@ -52,12 +53,12 @@ type RedisConfig struct {
DB int `yaml:"db"`
}
type KafkaConfig struct {
Brokers []string `yaml:"brokers"`
}
type ServeConfig struct {
Grpc *struct {
Address string `yaml:"address"`
Port int32 `yaml:"port"`
TTL int64 `yaml:"ttl"`
} `yaml:"grpc"`
Grpc *GrpcConfig `yaml:"grpc"`
Socket *struct {
Web *AddressConfig `yaml:"web"`
Raw *AddressConfig `yaml:"raw"`
@@ -65,6 +66,12 @@ type ServeConfig struct {
Http *AddressConfig `yaml:"http"`
}
type GrpcConfig struct {
Address string `yaml:"address"`
Port int32 `yaml:"port"`
TTL int64 `yaml:"ttl"`
}
type AddressConfig struct {
Address string `yaml:"address"`
Port int32 `yaml:"port"`

View File

@@ -37,6 +37,10 @@ func GetClient() *Client {
return instance
}
func (c *Client) Raw() *clientv3.Client {
return c.cli
}
// Get 获取数据
func (c *Client) Get(key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error) {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)

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

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

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

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

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

@@ -0,0 +1,109 @@
package kafka
import (
"context"
"encoding/json"
"errors"
"fmt"
"git.hlsq.asia/mmorpg/service-common/log"
"git.hlsq.asia/mmorpg/service-common/utils"
"github.com/IBM/sarama"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
otelcodes "go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/trace"
"time"
)
func NewConsumer() *Consumer {
ctx, cancel := context.WithCancel(context.Background())
return &Consumer{
ctx: ctx,
cancel: cancel,
}
}
type Consumer struct {
ctx context.Context
cancel context.CancelFunc
}
func (c *Consumer) Consume(t []Topic) {
for {
topicArr := make([]string, 0)
handlerMap := make(map[string]Topic)
for _, v := range t {
topicArr = append(topicArr, v.Name())
handlerMap[v.Name()] = v
}
err := client.consumer.Consume(c.ctx, topicArr, &handler{
handler: handlerMap,
})
if errors.Is(err, context.Canceled) || errors.Is(c.ctx.Err(), context.Canceled) {
return
}
time.Sleep(time.Second)
}
}
func (c *Consumer) Stop() error {
c.cancel()
return nil
}
type Handler func(context.Context, []byte) error
type handler struct {
handler map[string]Topic
}
func (h *handler) Setup(_ sarama.ConsumerGroupSession) error {
return nil
}
func (h *handler) Cleanup(sess sarama.ConsumerGroupSession) error {
sess.Commit()
return nil
}
func (h *handler) ConsumeClaim(sess sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim) error {
for message := range claim.Messages() {
ctx := NewCarrier().ExtractConsumer(message.Headers)
_, span := otel.Tracer("common.db.kafka").Start(ctx, "kafka.consume")
cb := h.handler[message.Topic]
if cb == nil {
span.SetStatus(otelcodes.Error, "handler not found")
span.End()
return utils.ErrorsWrap(errors.New("handler not found"))
}
if err := json.Unmarshal(message.Value, cb); err != nil {
span.SetStatus(otelcodes.Error, "handler json.Unmarshal error")
span.End()
return utils.ErrorsWrap(err, "handler json.Unmarshal error")
}
if err := cb.OnMessage(ctx); err != nil {
if stack, ok := err.(interface{ StackTrace() string }); ok {
span.AddEvent("Stack Trace", trace.WithAttributes(
attribute.String("stack.trace", fmt.Sprintf("%v", stack.StackTrace())),
))
}
span.SetStatus(otelcodes.Error, err.Error())
span.End()
return utils.ErrorsWrap(err, "kafka handler error")
}
sess.MarkMessage(message, "")
span.End()
}
sess.Commit()
return nil
}
func consumerError() {
for err := range client.consumer.Errors() {
log.Errorf("kafka consumer error: %v", err)
}
}

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

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

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

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

View File

@@ -49,6 +49,10 @@ func (c *Client) Set(ctx context.Context, key string, value interface{}, expirat
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)
}
@@ -72,3 +76,11 @@ func (c *Client) HDel(ctx context.Context, key string, fields ...string) *redis.
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...)
}

View File

@@ -32,13 +32,13 @@ var (
// ServiceProvider 服务提供者
type ServiceProvider struct {
Target string
SID string
SID int64
Addr string
}
// InstanceProvider 副本提供者
type InstanceProvider struct {
InstanceID int // 副本ID
UniqueNo string // 副本唯一编号
SID string
InstanceID int // 副本ID
UniqueNo int64 // 副本唯一编号
SID int64
}

View File

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

View File

@@ -6,6 +6,7 @@ import (
"git.hlsq.asia/mmorpg/service-common/db/etcd"
"git.hlsq.asia/mmorpg/service-common/discover/common"
"git.hlsq.asia/mmorpg/service-common/log"
"git.hlsq.asia/mmorpg/service-common/utils"
"go.etcd.io/etcd/api/v3/mvccpb"
clientv3 "go.etcd.io/etcd/client/v3"
"strconv"
@@ -41,7 +42,7 @@ func onCBByType(t common.ListenerType, data any) {
}
}
func Listen() {
func Listen(ready *sync.WaitGroup) {
var stopCtx context.Context
stopCtx, stopFunc = context.WithCancel(context.Background())
wg.Add(1)
@@ -60,6 +61,8 @@ func Listen() {
onInstanceChange(clientv3.EventTypePut, string(kv.Key), string(kv.Value), nil)
}
chInstance := etcd.GetClient().Watch(common.KeyDiscoverScene, clientv3.WithPrefix(), clientv3.WithRev(instanceAll.Header.Revision+1), clientv3.WithPrevKV())
// 准备好了
ready.Done()
for {
select {
case msg := <-chService:
@@ -87,13 +90,13 @@ func onServerChange(t mvccpb.Event_EventType, key, value string) {
case clientv3.EventTypePut:
onCBByType(common.ListenerTypeNewServer, &common.ServiceProvider{
Target: common.KeyDiscoverService + "/" + split[2],
SID: split[3],
SID: utils.StringToInt64(split[3]),
Addr: value,
})
case clientv3.EventTypeDelete:
onCBByType(common.ListenerTypeCloseServer, &common.ServiceProvider{
Target: common.KeyDiscoverService + "/" + split[2],
SID: split[3],
SID: utils.StringToInt64(split[3]),
})
}
}
@@ -109,14 +112,14 @@ func onInstanceChange(t mvccpb.Event_EventType, key, value string, preKv *mvccpb
case clientv3.EventTypePut:
onCBByType(common.ListenerTypeNewInstance, &common.InstanceProvider{
InstanceID: instanceID,
UniqueNo: split[3],
SID: value,
UniqueNo: utils.StringToInt64(split[3]),
SID: utils.StringToInt64(value),
})
case clientv3.EventTypeDelete:
onCBByType(common.ListenerTypeCloseInstance, &common.InstanceProvider{
InstanceID: instanceID,
UniqueNo: split[3],
SID: string(preKv.Value),
UniqueNo: utils.StringToInt64(split[3]),
SID: utils.StringToInt64(string(preKv.Value)),
})
}
}

View File

@@ -15,7 +15,7 @@ import (
var (
serverMU = sync.RWMutex{}
conn = make(map[string]*grpc_conn.GrpcConnectionMgr)
serverLeaseM = make(map[string]clientv3.LeaseID)
serverLeaseM = make(map[int64]clientv3.LeaseID)
)
func init() {
@@ -24,7 +24,7 @@ func init() {
}
// FindServer 根据SID或随机查找服务
func FindServer(target string, sid ...string) (*grpc.ClientConn, error) {
func FindServer(target string, sid ...int64) (*grpc.ClientConn, error) {
serverMU.RLock()
defer serverMU.RUnlock()
if v, ok := conn[target]; ok {
@@ -33,17 +33,17 @@ func FindServer(target string, sid ...string) (*grpc.ClientConn, error) {
return nil, fmt.Errorf("cannot find server")
}
func FindServerAll(target string) map[string]*grpc.ClientConn {
func FindServerAll(target string) map[int64]*grpc.ClientConn {
serverMU.RLock()
defer serverMU.RUnlock()
if v, ok := conn[target]; ok {
return v.LoadAll()
}
return make(map[string]*grpc.ClientConn)
return make(map[int64]*grpc.ClientConn)
}
// RegisterGrpcServer 注册服务提供者
func RegisterGrpcServer(target string, sid string, addr string, ttl int64) error {
func RegisterGrpcServer(target string, sid int64, addr string, ttl int64) error {
serverMU.Lock()
defer serverMU.Unlock()
leaseID, err := common.NewLeaseAndKeepAlive(ttl)
@@ -59,7 +59,7 @@ func RegisterGrpcServer(target string, sid string, addr string, ttl int64) error
}
// UnRegisterGrpcServer 解注册服务提供者
func UnRegisterGrpcServer(sid string) {
func UnRegisterGrpcServer(sid int64) {
serverMU.Lock()
defer serverMU.Unlock()
if leaseID, ok := serverLeaseM[sid]; ok {

21
go.mod
View File

@@ -3,6 +3,7 @@ module git.hlsq.asia/mmorpg/service-common
go 1.24.0
require (
github.com/IBM/sarama v1.46.3
github.com/bwmarrin/snowflake v0.3.0
github.com/gin-gonic/gin v1.11.0
github.com/gobwas/ws v1.4.0
@@ -11,6 +12,7 @@ require (
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3
github.com/natefinch/lumberjack v2.0.0+incompatible
github.com/panjf2000/gnet/v2 v2.9.7
github.com/prometheus/client_golang v1.20.5
github.com/redis/go-redis/v9 v9.10.0
github.com/spf13/viper v1.21.0
github.com/stretchr/testify v1.11.1
@@ -33,6 +35,7 @@ require (
require (
filippo.io/edwards25519 v1.1.0 // indirect
github.com/BurntSushi/toml v1.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bytedance/gopkg v0.1.3 // indirect
github.com/bytedance/sonic v1.14.2 // indirect
github.com/bytedance/sonic/loader v0.4.0 // indirect
@@ -43,6 +46,9 @@ require (
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/eapache/go-resiliency v1.7.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.11 // indirect
github.com/gin-contrib/sse v1.1.0 // indirect
@@ -61,21 +67,33 @@ require (
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
github.com/jcmturner/gofork v1.7.6 // indirect
github.com/jcmturner/gokrb5/v8 v8.4.4 // indirect
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/klauspost/compress v1.18.1 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/panjf2000/ants/v2 v2.11.3 // indirect
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/pierrec/lz4/v4 v4.1.22 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.62.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/quic-go/qpack v0.6.0 // indirect
github.com/quic-go/quic-go v0.57.1 // indirect
github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9 // indirect
github.com/sagikazarmark/locafero v0.11.0 // indirect
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect
github.com/spf13/afero v1.15.0 // indirect
@@ -105,6 +123,5 @@ require (
golang.org/x/text v0.31.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

59
go.sum
View File

@@ -2,6 +2,10 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/IBM/sarama v1.46.3 h1:njRsX6jNlnR+ClJ8XmkO+CM4unbrNr/2vB5KK6UA+IE=
github.com/IBM/sarama v1.46.3/go.mod h1:GTUYiF9DMOZVe3FwyGT+dtSPceGFIgA+sPc5u6CBwko=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
@@ -29,6 +33,14 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/eapache/go-resiliency v1.7.0 h1:n3NRTnBn5N0Cbi/IeOHuQn9s2UwVUH7Ga0ZWcP+9JTA=
github.com/eapache/go-resiliency v1.7.0/go.mod h1:5yPzW0MIvSe0JDsv0v+DvcjEv2FyD6iZYSs1ZI+iQho=
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 h1:Oy0F4ALJ04o5Qqpdz8XLIpNA3WM/iSIXqxtqo7UGVws=
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3/go.mod h1:YvSRo5mw33fLEx1+DlK6L2VV43tJt5Eyel9n9XBcR+0=
github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc=
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
@@ -82,8 +94,25 @@ github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 h1:NmZ1PKzSTQbuGHw9DGPFomqkkLWMC+vZCkfs+FHv1Vg=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3/go.mod h1:zQrxl1YP88HQlA6i9c63DSVPFklWpGX4OWAc9bFuaH4=
github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8=
github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs=
github.com/jcmturner/dnsutils/v2 v2.0.0 h1:lltnkeZGL0wILNvrNiVCR6Ro5PGU/SeBvVO/8c/iPbo=
github.com/jcmturner/dnsutils/v2 v2.0.0/go.mod h1:b0TnjGOvI/n42bZa+hmXL+kFJZsFT7G4t3HTlQ184QM=
github.com/jcmturner/gofork v1.7.6 h1:QH0l3hzAU1tfT3rZCnW5zXl+orbkNMMRGJfdJjHVETg=
github.com/jcmturner/gofork v1.7.6/go.mod h1:1622LH6i/EZqLloHfE7IeZ0uEJwMSUyQ/nDd82IeqRo=
github.com/jcmturner/goidentity/v6 v6.0.1 h1:VKnZd2oEIMorCTsFBnJWbExfNN7yZr3EhJAxwOkZg6o=
github.com/jcmturner/goidentity/v6 v6.0.1/go.mod h1:X1YW3bgtvwAXju7V3LCIMpY0Gbxyjn/mY9zx4tFonSg=
github.com/jcmturner/gokrb5/v8 v8.4.4 h1:x1Sv4HaTpepFkXbt2IkL29DXRf8sOfZXo8eRKh687T8=
github.com/jcmturner/gokrb5/v8 v8.4.4/go.mod h1:1btQEpgT6k+unzCwX1KdWMEwPPkkgBtP+F6aCACiMrs=
github.com/jcmturner/rpc/v2 v2.0.3 h1:7FXXj8Ti1IaVFpSAziCZWNzbNuZmnvw/i6CqLNdWfZY=
github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
@@ -92,14 +121,16 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co=
github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0=
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
@@ -111,6 +142,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/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/natefinch/lumberjack v2.0.0+incompatible h1:4QJd3OLAMgj7ph+yZTuX13Ld4UpgHp07nNdFX7mqFfM=
github.com/natefinch/lumberjack v2.0.0+incompatible/go.mod h1:Wi9p2TTF5DG5oU+6YfsmYQpsTIOm0B1VNzQg9Mw6nPk=
github.com/panjf2000/ants/v2 v2.11.3 h1:AfI0ngBoXJmYOpDh9m516vjqoUu2sLrIVgppI9TZVpg=
@@ -119,12 +152,24 @@ github.com/panjf2000/gnet/v2 v2.9.7 h1:6zW7Jl3oAfXwSuh1PxHLndoL2MQRWx0AJR6aaQjxU
github.com/panjf2000/gnet/v2 v2.9.7/go.mod h1:WQTxDWYuQ/hz3eccH0FN32IVuvZ19HewEWx0l62fx7E=
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
github.com/pierrec/lz4/v4 v4.1.22 h1:cKFw6uJDK+/gfw5BcDL0JL5aBsAFdsIT18eRtLj7VIU=
github.com/pierrec/lz4/v4 v4.1.22/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ2Io=
github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I=
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8=
github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII=
github.com/quic-go/quic-go v0.57.1 h1:25KAAR9QR8KZrCZRThWMKVAwGoiHIrNbT72ULHTuI10=
github.com/quic-go/quic-go v0.57.1/go.mod h1:ly4QBAjHA2VhdnxhojRsCUOeJwKYg+taDlos92xb1+s=
github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9 h1:bsUq1dX0N8AOIL7EB/X911+m4EHsnWEHeJ0c+3TTBrg=
github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/redis/go-redis/v9 v9.10.0 h1:FxwK3eV8p/CQa0Ch276C7u2d0eNC9kCmAYQ7mCXCzVs=
github.com/redis/go-redis/v9 v9.10.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
@@ -146,8 +191,10 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS
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=
@@ -216,6 +263,7 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
@@ -224,11 +272,14 @@ golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -247,15 +298,18 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
@@ -285,6 +339,7 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

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

View File

@@ -3,6 +3,7 @@ package module
import (
"git.hlsq.asia/mmorpg/service-common/config"
"git.hlsq.asia/mmorpg/service-common/db/etcd"
"git.hlsq.asia/mmorpg/service-common/db/kafka"
"git.hlsq.asia/mmorpg/service-common/db/mysql"
"git.hlsq.asia/mmorpg/service-common/db/redis"
"git.hlsq.asia/mmorpg/service-common/log"
@@ -10,32 +11,36 @@ import (
// DB 数据库模块
type DB struct {
cfg *config.DBConfig
DefaultModule
Cfg *config.DBConfig
AppName string
}
func (m *DB) Init() error {
// ETCD
if m.cfg.Etcd != nil {
if err := etcd.Init(m.cfg.Etcd); err != nil {
if m.Cfg.Etcd != nil {
if err := etcd.Init(m.Cfg.Etcd); err != nil {
return err
}
}
// MYSQL
if m.cfg.MySQL != nil {
if err := mysql.Init(m.cfg.MySQL); err != nil {
if m.Cfg.MySQL != nil {
if err := mysql.Init(m.Cfg.MySQL); err != nil {
return err
}
}
// REDIS
if m.cfg.Redis != nil {
if err := redis.Init(m.cfg.Redis); err != nil {
if m.Cfg.Redis != nil {
if err := redis.Init(m.Cfg.Redis); err != nil {
return err
}
}
// KAFKA
if m.Cfg.Kafka != nil {
if err := kafka.Init(m.Cfg.Kafka, m.AppName); err != nil {
return err
}
}
return nil
}
func (m *DB) Start() error {
return nil
}
@@ -49,15 +54,8 @@ func (m *DB) Stop() error {
if err := redis.Close(); err != nil {
log.Errorf("close redis failed: %v", err)
}
if err := kafka.Close(); err != nil {
log.Errorf("close kafka failed: %v", err)
}
return nil
}
func (m *DB) Bind(data ...any) Module {
if data == nil || len(data) == 0 {
return m
}
if cfg, ok := data[0].(*config.DBConfig); ok {
m.cfg = cfg
}
return m
}

View File

@@ -1,17 +1,17 @@
package module
import "git.hlsq.asia/mmorpg/service-common/discover"
import (
"git.hlsq.asia/mmorpg/service-common/discover"
"sync"
)
// Discover 服务发现模块
type Discover struct {
DefaultModule
}
func (m *Discover) Init() error {
return nil
}
func (m *Discover) Start() error {
discover.Listen()
func (m *Discover) Start(ready *sync.WaitGroup) error {
discover.Listen(ready)
return nil
}
@@ -19,7 +19,3 @@ func (m *Discover) Stop() error {
discover.Close()
return nil
}
func (m *Discover) Bind(_ ...any) Module {
return m
}

27
module/grpc.go Normal file
View File

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

17
module/log.go Normal file
View File

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

View File

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

View File

@@ -13,9 +13,10 @@ import (
// Prometheus 普罗米修斯模块
type Prometheus struct {
wg *sync.WaitGroup
server *http.Server
metricCfg *config.MetricConfig
DefaultModule
Cfg *config.MetricConfig
wg *sync.WaitGroup
server *http.Server
}
func (m *Prometheus) Init() error {
@@ -23,14 +24,15 @@ func (m *Prometheus) Init() error {
return nil
}
func (m *Prometheus) Start() error {
func (m *Prometheus) Start(ready *sync.WaitGroup) error {
m.wg.Add(1)
go func() {
defer m.wg.Done()
m.server = &http.Server{
Addr: fmt.Sprintf("%v:%v", m.metricCfg.Prometheus.Address, m.metricCfg.Prometheus.Port),
Addr: fmt.Sprintf("%v:%v", m.Cfg.Prometheus.Address, m.Cfg.Prometheus.Port),
Handler: promhttp.Handler(),
}
ready.Done()
if err := m.server.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
log.Errorf("prometheus server failed: %v", err.Error())
}
@@ -46,13 +48,3 @@ func (m *Prometheus) Stop() error {
m.wg.Wait()
return nil
}
func (m *Prometheus) Bind(data ...any) Module {
if data == nil || len(data) == 0 {
return m
}
if mc, ok := data[0].(*config.MetricConfig); ok {
m.metricCfg = mc
}
return m
}

64
module/snowflake.go Normal file
View File

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

View File

@@ -14,16 +14,17 @@ import (
// Tracer 链路追踪模块
type Tracer struct {
DefaultModule
Cfg *config.MetricConfig
ServiceName string
tp *sdktrace.TracerProvider
metricCfg *config.MetricConfig
serviceName string
}
func (m *Tracer) Init() error {
exporter, err := otlptracegrpc.New(
context.Background(),
otlptracegrpc.WithInsecure(),
otlptracegrpc.WithEndpoint(m.metricCfg.Jaeger.Endpoint),
otlptracegrpc.WithEndpoint(m.Cfg.Jaeger.Endpoint),
)
if err != nil {
return err
@@ -33,7 +34,7 @@ func (m *Tracer) Init() error {
sdktrace.WithBatcher(exporter),
sdktrace.WithResource(resource.NewWithAttributes(
semconv.SchemaURL,
semconv.ServiceNameKey.String(m.serviceName),
semconv.ServiceNameKey.String(m.ServiceName),
)),
)
otel.SetTracerProvider(m.tp)
@@ -42,10 +43,6 @@ func (m *Tracer) Init() error {
return nil
}
func (m *Tracer) Start() error {
return nil
}
func (m *Tracer) Stop() error {
if m.tp != nil {
if err := m.tp.Shutdown(context.Background()); err != nil {
@@ -54,16 +51,3 @@ func (m *Tracer) Stop() error {
}
return nil
}
func (m *Tracer) Bind(data ...any) Module {
if data == nil || len(data) == 0 {
return m
}
if mc, ok := data[0].(*config.MetricConfig); ok {
m.metricCfg = mc
}
if name, ok := data[1].(string); ok {
m.serviceName = name
}
return m
}

View File

@@ -6,7 +6,7 @@ import (
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
)
func GatewayNewClient(sid ...string) (grpc_pb.GatewayClient, error) {
func GatewayNewClient(sid ...int64) (grpc_pb.GatewayClient, error) {
c, err := discover.FindServer(common.KeyDiscoverGateway, sid...)
if err != nil {
return nil, err
@@ -14,8 +14,8 @@ func GatewayNewClient(sid ...string) (grpc_pb.GatewayClient, error) {
return grpc_pb.NewGatewayClient(c), nil
}
func GatewayNewBroadcastClient() map[string]grpc_pb.GatewayClient {
clientM := make(map[string]grpc_pb.GatewayClient)
func GatewayNewBroadcastClient() map[int64]grpc_pb.GatewayClient {
clientM := make(map[int64]grpc_pb.GatewayClient)
connM := discover.FindServerAll(common.KeyDiscoverGateway)
for sid, conn := range connM {
clientM[sid] = grpc_pb.NewGatewayClient(conn)

View File

@@ -7,7 +7,7 @@ import (
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
)
func QgdzsNewClient(sid ...string) (grpc_pb.QgdzsClient, error) {
func QgdzsNewClient(sid ...int64) (grpc_pb.QgdzsClient, error) {
c, err := discover.FindServer(common.KeyDiscoverQgdzs, sid...)
if err != nil {
return nil, err

View File

@@ -7,7 +7,7 @@ import (
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
)
func SceneNewClient(sid ...string) (grpc_pb.SceneClient, error) {
func SceneNewClient(sid ...int64) (grpc_pb.SceneClient, error) {
c, err := discover.FindServer(common.KeyDiscoverScene, sid...)
if err != nil {
return nil, err
@@ -23,8 +23,8 @@ func SceneNewClientLB() (grpc_pb.SceneClient, error) {
return grpc_pb.NewSceneClient(c), nil
}
func SceneNewBroadcastClient() map[string]grpc_pb.SceneClient {
clientM := make(map[string]grpc_pb.SceneClient)
func SceneNewBroadcastClient() map[int64]grpc_pb.SceneClient {
clientM := make(map[int64]grpc_pb.SceneClient)
connM := discover.FindServerAll(common.KeyDiscoverScene)
for sid, conn := range connM {
clientM[sid] = grpc_pb.NewSceneClient(conn)

View File

@@ -7,7 +7,7 @@ import (
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
)
func UserNewClient(sid ...string) (grpc_pb.UserClient, error) {
func UserNewClient(sid ...int64) (grpc_pb.UserClient, error) {
c, err := discover.FindServer(common.KeyDiscoverUser, sid...)
if err != nil {
return nil, err

View File

@@ -2,10 +2,10 @@ package grpc_client
import (
"context"
"fmt"
"git.hlsq.asia/mmorpg/service-common/log"
"google.golang.org/grpc"
"google.golang.org/protobuf/proto"
"strconv"
"sync"
)
@@ -22,7 +22,7 @@ type gatewayStream struct {
stream grpc.ClientStream
}
func findGatewayBySID(sid string, fun GatewayFun) (*gatewayStream, error) {
func findGatewayBySID(sid int64, fun GatewayFun) (*gatewayStream, error) {
key := gatewayKey(sid, fun)
if v, ok := gatewayServer.Load(key); ok {
@@ -53,7 +53,7 @@ func findGatewayBySID(sid string, fun GatewayFun) (*gatewayStream, error) {
return ss, nil
}
func SendMessageToGateway(sid string, 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
@@ -78,6 +78,6 @@ func SendMessageToGateway(sid string, fun GatewayFun, msg proto.Message, re ...b
return nil
}
func gatewayKey(sid string, fun GatewayFun) string {
return sid + "-" + strconv.Itoa(int(fun))
func gatewayKey(sid int64, fun GatewayFun) string {
return fmt.Sprintf("%v-%v", sid, fun)
}

View File

@@ -2,10 +2,10 @@ package grpc_client
import (
"context"
"fmt"
"git.hlsq.asia/mmorpg/service-common/log"
"google.golang.org/grpc"
"google.golang.org/protobuf/proto"
"strconv"
"sync"
)
@@ -22,7 +22,7 @@ type sceneStream struct {
stream grpc.ClientStream
}
func findSceneBySID(sid string, fun SceneFun) (*sceneStream, error) {
func findSceneBySID(sid int64, fun SceneFun) (*sceneStream, error) {
key := sceneKey(sid, fun)
if v, ok := sceneServer.Load(key); ok {
@@ -53,7 +53,7 @@ func findSceneBySID(sid string, fun SceneFun) (*sceneStream, error) {
return ss, nil
}
func SendMessageToScene(sid string, fun SceneFun, msg proto.Message, re ...bool) error {
func SendMessageToScene(sid int64, fun SceneFun, msg proto.Message, re ...bool) error {
ss, err := findSceneBySID(sid, fun)
if err != nil {
return err
@@ -78,6 +78,6 @@ func SendMessageToScene(sid string, fun SceneFun, msg proto.Message, re ...bool)
return nil
}
func sceneKey(sid string, fun SceneFun) string {
return sid + "-" + strconv.Itoa(int(fun))
func sceneKey(sid int64, fun SceneFun) string {
return fmt.Sprintf("%v-%v", sid, fun)
}

View File

@@ -10,11 +10,11 @@ import (
)
type GrpcConnection struct {
sid string
sid int64
conn *grpc.ClientConn
}
func NewGrpcConnection(sid string, address string) (*GrpcConnection, error) {
func NewGrpcConnection(sid int64, address string) (*GrpcConnection, error) {
p := &GrpcConnection{
sid: sid,
}

View File

@@ -8,18 +8,18 @@ import (
)
type GrpcConnectionMgr struct {
poolM map[string]*GrpcConnection
poolM map[int64]*GrpcConnection
poolS []*GrpcConnection
}
func NewGrpcConnectionMgr() *GrpcConnectionMgr {
return &GrpcConnectionMgr{
poolM: make(map[string]*GrpcConnection),
poolM: make(map[int64]*GrpcConnection),
poolS: make([]*GrpcConnection, 0),
}
}
func (p *GrpcConnectionMgr) Store(sid string, addr string) {
func (p *GrpcConnectionMgr) Store(sid int64, addr string) {
pool, err := NewGrpcConnection(sid, addr)
if err != nil {
log.Errorf("create grpc err: %v, sid: %v, addr: %v", err, sid, addr)
@@ -29,7 +29,7 @@ func (p *GrpcConnectionMgr) Store(sid string, addr string) {
p.poolS = append(p.poolS, pool)
}
func (p *GrpcConnectionMgr) Delete(sid string) int {
func (p *GrpcConnectionMgr) Delete(sid int64) int {
delete(p.poolM, sid)
for i, pool := range p.poolS {
if pool.sid == sid {
@@ -40,9 +40,9 @@ func (p *GrpcConnectionMgr) Delete(sid string) int {
return len(p.poolS)
}
func (p *GrpcConnectionMgr) Load(sid ...string) (*grpc.ClientConn, error) {
func (p *GrpcConnectionMgr) Load(sid ...int64) (*grpc.ClientConn, error) {
var pool *GrpcConnection
if len(sid) > 0 && sid[0] != "" {
if len(sid) > 0 && sid[0] != 0 {
pool = p.poolM[sid[0]]
} else {
pool = p.poolS[rand.Intn(len(p.poolS))]
@@ -53,8 +53,8 @@ func (p *GrpcConnectionMgr) Load(sid ...string) (*grpc.ClientConn, error) {
return pool.GetConnection(), nil
}
func (p *GrpcConnectionMgr) LoadAll() map[string]*grpc.ClientConn {
sidM := make(map[string]*grpc.ClientConn)
func (p *GrpcConnectionMgr) LoadAll() map[int64]*grpc.ClientConn {
sidM := make(map[int64]*grpc.ClientConn)
for sid, pool := range p.poolM {
sidM[sid] = pool.GetConnection()
}

View File

@@ -9,12 +9,23 @@ import (
"time"
)
const serviceConfig = `{
"loadBalancingConfig": [
{
"round_robin": {}
}
],
"healthCheckConfig": {
"serviceName": ""
}
}`
func NewGrpcConnection(target string) (*grpc.ClientConn, error) {
cc, err := grpc.NewClient(
target,
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithStatsHandler(otelgrpc.NewClientHandler()),
grpc.WithDefaultServiceConfig(`{"loadBalancingConfig": [{"round_robin": {}}]}`),
grpc.WithDefaultServiceConfig(serviceConfig),
grpc.WithKeepaliveParams(
keepalive.ClientParameters{
Time: 30 * time.Second, // 保活探测包发送的时间间隔

View File

@@ -34,8 +34,7 @@ func (s *Base) LoggingInterceptor(ctx context.Context, req interface{}, info *gr
}
}
tracer := otel.Tracer(s.ServiceName)
_, span := tracer.Start(ctx, info.FullMethod)
_, 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)

View File

@@ -2,11 +2,14 @@ package service
import (
"fmt"
"git.hlsq.asia/mmorpg/service-common/config"
"git.hlsq.asia/mmorpg/service-common/discover"
"git.hlsq.asia/mmorpg/service-common/log"
"git.hlsq.asia/mmorpg/service-common/utils"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"google.golang.org/grpc"
"google.golang.org/grpc/health"
"google.golang.org/grpc/health/grpc_health_v1"
"google.golang.org/grpc/keepalive"
"net"
"sync"
@@ -14,34 +17,36 @@ import (
)
type IService interface {
Init(addr string, port int32)
Init(ready *sync.WaitGroup)
SetReady()
Close()
}
type Base struct {
Target string
ServiceName string
SID string
SID int64
Serve *grpc.Server
EtcdTTL int64
Cfg *config.GrpcConfig
OnCustomGrpcServerOption func() []grpc.ServerOption
OnInit func(serve *grpc.Server)
OnClose func()
wg *sync.WaitGroup
wg *sync.WaitGroup
healthcheck *health.Server
}
func (s *Base) Init(addr string, port int32) {
func (s *Base) Init(ready *sync.WaitGroup) {
s.wg = &sync.WaitGroup{}
s.wg.Add(1)
s.SID = utils.SnowflakeInstance().Generate().String()
s.SID = utils.SnowflakeInstance().Generate().Int64()
go func() {
defer s.wg.Done()
defer s.OnClose()
defer discover.UnRegisterGrpcServer(s.SID)
// 监听端口
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", s.Cfg.Port))
if err != nil {
log.Errorf("%v ListenPort err: %v", s.Target, err)
return
@@ -62,11 +67,18 @@ func (s *Base) Init(addr string, port int32) {
s.Serve = grpc.NewServer(options...)
s.OnInit(s.Serve)
// 健康检查
s.healthcheck = health.NewServer()
s.healthcheck.SetServingStatus("", grpc_health_v1.HealthCheckResponse_NOT_SERVING)
grpc_health_v1.RegisterHealthServer(s.Serve, s.healthcheck)
// 服务注册
if err = discover.RegisterGrpcServer(s.Target, s.SID, fmt.Sprintf("%v:%d", addr, port), s.EtcdTTL); err != nil {
if err = discover.RegisterGrpcServer(s.Target, s.SID, fmt.Sprintf("%v:%d", s.Cfg.Address, s.Cfg.Port), s.Cfg.TTL); err != nil {
log.Errorf("%v RegisterGrpcServer err: %v", s.Target, err)
return
}
// 准备好了
ready.Done()
if err = s.Serve.Serve(lis); err != nil {
log.Errorf("%v Serve err: %v", s.Target, err)
return
@@ -75,9 +87,18 @@ func (s *Base) Init(addr string, port int32) {
}()
}
func (s *Base) SetReady() {
if s.healthcheck != nil {
s.healthcheck.SetServingStatus("", grpc_health_v1.HealthCheckResponse_SERVING)
}
}
func (s *Base) Close() {
if s.healthcheck != nil {
s.healthcheck.SetServingStatus("", grpc_health_v1.HealthCheckResponse_NOT_SERVING)
}
if s.Serve != nil {
s.Serve.Stop()
s.Serve.GracefulStop()
s.wg.Wait()
}
}

View File

@@ -26,7 +26,7 @@ type ToClientReq struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
USN string `protobuf:"bytes,1,opt,name=USN,proto3" json:"USN,omitempty"`
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"`
}
@@ -63,11 +63,11 @@ func (*ToClientReq) Descriptor() ([]byte, []int) {
return file_service_gateway_proto_rawDescGZIP(), []int{0}
}
func (x *ToClientReq) GetUSN() string {
func (x *ToClientReq) GetUSN() int64 {
if x != nil {
return x.USN
}
return ""
return 0
}
func (x *ToClientReq) GetMessageID() int32 {
@@ -127,7 +127,7 @@ type KickUserReq struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
USN string `protobuf:"bytes,1,opt,name=USN,proto3" json:"USN,omitempty"`
USN int64 `protobuf:"varint,1,opt,name=USN,proto3" json:"USN,omitempty"`
}
func (x *KickUserReq) Reset() {
@@ -162,11 +162,11 @@ func (*KickUserReq) Descriptor() ([]byte, []int) {
return file_service_gateway_proto_rawDescGZIP(), []int{2}
}
func (x *KickUserReq) GetUSN() string {
func (x *KickUserReq) GetUSN() int64 {
if x != nil {
return x.USN
}
return ""
return 0
}
type KickUserResp struct {
@@ -214,13 +214,13 @@ var file_service_gateway_proto_rawDesc = []byte{
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, 0x09, 0x52, 0x03, 0x55, 0x53, 0x4e, 0x12, 0x1c, 0x0a, 0x09, 0x4d, 0x65, 0x73,
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, 0x09, 0x52, 0x03, 0x55,
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,

File diff suppressed because it is too large Load Diff

View File

@@ -59,75 +59,51 @@ func local_request_Qgdzs_GenerateQuestion_0(ctx context.Context, marshaler runti
return msg, metadata, err
}
func request_Qgdzs_GetQuestion_0(ctx context.Context, marshaler runtime.Marshaler, client QgdzsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
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 GetQuestionReq
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.GetQuestion(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
msg, err := client.RandomGetQuestion(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Qgdzs_GetQuestion_0(ctx context.Context, marshaler runtime.Marshaler, server QgdzsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
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 GetQuestionReq
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.GetQuestion(ctx, &protoReq)
msg, err := server.RandomGetQuestion(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) {
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 GetQuestionInfoReq
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.GetQuestionInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
msg, err := client.RandomAnswerQuestion(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) {
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 GetQuestionInfoReq
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.GetQuestionInfo(ctx, &protoReq)
return msg, metadata, err
}
func request_Qgdzs_AnswerQuestion_0(ctx context.Context, marshaler runtime.Marshaler, client QgdzsClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq AnswerQuestionReq
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.AnswerQuestion(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Qgdzs_AnswerQuestion_0(ctx context.Context, marshaler runtime.Marshaler, server QgdzsServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq AnswerQuestionReq
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.AnswerQuestion(ctx, &protoReq)
msg, err := server.RandomAnswerQuestion(ctx, &protoReq)
return msg, metadata, err
}
@@ -155,6 +131,102 @@ func local_request_Qgdzs_GetAllCategory_0(ctx context.Context, marshaler runtime
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
@@ -179,6 +251,78 @@ func local_request_Qgdzs_GetRecord_0(ctx context.Context, marshaler runtime.Mars
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.
@@ -205,25 +349,165 @@ func RegisterQgdzsHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
}
forward_Qgdzs_GenerateQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_GetQuestion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
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/GetQuestion", runtime.WithHTTPPathPattern("/qgdzs/open/get_question"))
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_GetQuestion_0(annotatedContext, inboundMarshaler, server, req, pathParams)
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_GetQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
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())
@@ -245,65 +529,45 @@ func RegisterQgdzsHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
}
forward_Qgdzs_GetQuestionInfo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_AnswerQuestion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
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/AnswerQuestion", runtime.WithHTTPPathPattern("/qgdzs/open/answer_question"))
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_AnswerQuestion_0(annotatedContext, inboundMarshaler, server, req, pathParams)
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_AnswerQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
forward_Qgdzs_GetPointRecord_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) {
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/GetAllCategory", runtime.WithHTTPPathPattern("/qgdzs/open/get_all_category"))
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_GetAllCategory_0(annotatedContext, inboundMarshaler, server, req, pathParams)
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_GetAllCategory_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()...)
forward_Qgdzs_GetPoint_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
@@ -362,62 +626,45 @@ func RegisterQgdzsHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
}
forward_Qgdzs_GenerateQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_GetQuestion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
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/GetQuestion", runtime.WithHTTPPathPattern("/qgdzs/open/get_question"))
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_GetQuestion_0(annotatedContext, inboundMarshaler, client, req, pathParams)
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_GetQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
forward_Qgdzs_RandomGetQuestion_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) {
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/GetQuestionInfo", runtime.WithHTTPPathPattern("/qgdzs/open/get_question_info"))
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_GetQuestionInfo_0(annotatedContext, inboundMarshaler, client, req, pathParams)
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_GetQuestionInfo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodPost, pattern_Qgdzs_AnswerQuestion_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/AnswerQuestion", runtime.WithHTTPPathPattern("/qgdzs/open/answer_question"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Qgdzs_AnswerQuestion_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_AnswerQuestion_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
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/get_all_category"))
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
@@ -430,6 +677,74 @@ func RegisterQgdzsHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
}
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()
@@ -447,23 +762,86 @@ func RegisterQgdzsHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
}
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_GetQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"qgdzs", "open", "get_question"}, ""))
pattern_Qgdzs_GetQuestionInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"qgdzs", "open", "get_question_info"}, ""))
pattern_Qgdzs_AnswerQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"qgdzs", "open", "answer_question"}, ""))
pattern_Qgdzs_GetAllCategory_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"qgdzs", "open", "get_all_category"}, ""))
pattern_Qgdzs_GetRecord_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"qgdzs", "auth", "get_record"}, ""))
pattern_Qgdzs_GenerateQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"qgdzs", "auth", "generate_question"}, ""))
pattern_Qgdzs_RandomGetQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"qgdzs", "open", "random", "question"}, ""))
pattern_Qgdzs_RandomAnswerQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"qgdzs", "open", "random", "answer"}, ""))
pattern_Qgdzs_GetAllCategory_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"qgdzs", "open", "category", "get_category"}, ""))
pattern_Qgdzs_CategoryGetQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"qgdzs", "open", "category", "question"}, ""))
pattern_Qgdzs_CategoryAnswerQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"qgdzs", "open", "category", "answer"}, ""))
pattern_Qgdzs_QuicklyGetQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"qgdzs", "open", "quickly", "question"}, ""))
pattern_Qgdzs_QuicklyAnswerQuestion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"qgdzs", "open", "quickly", "answer"}, ""))
pattern_Qgdzs_GetRecord_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"qgdzs", "auth", "get_record"}, ""))
pattern_Qgdzs_GetQuestionInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"qgdzs", "open", "get_question_info"}, ""))
pattern_Qgdzs_GetPointRecord_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"qgdzs", "auth", "point", "record"}, ""))
pattern_Qgdzs_GetPoint_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"qgdzs", "auth", "point", "info"}, ""))
)
var (
forward_Qgdzs_GenerateQuestion_0 = runtime.ForwardResponseMessage
forward_Qgdzs_GetQuestion_0 = runtime.ForwardResponseMessage
forward_Qgdzs_GetQuestionInfo_0 = runtime.ForwardResponseMessage
forward_Qgdzs_AnswerQuestion_0 = runtime.ForwardResponseMessage
forward_Qgdzs_GetAllCategory_0 = runtime.ForwardResponseMessage
forward_Qgdzs_GetRecord_0 = runtime.ForwardResponseMessage
forward_Qgdzs_GenerateQuestion_0 = runtime.ForwardResponseMessage
forward_Qgdzs_RandomGetQuestion_0 = runtime.ForwardResponseMessage
forward_Qgdzs_RandomAnswerQuestion_0 = runtime.ForwardResponseMessage
forward_Qgdzs_GetAllCategory_0 = runtime.ForwardResponseMessage
forward_Qgdzs_CategoryGetQuestion_0 = runtime.ForwardResponseMessage
forward_Qgdzs_CategoryAnswerQuestion_0 = runtime.ForwardResponseMessage
forward_Qgdzs_QuicklyGetQuestion_0 = runtime.ForwardResponseMessage
forward_Qgdzs_QuicklyAnswerQuestion_0 = runtime.ForwardResponseMessage
forward_Qgdzs_GetRecord_0 = runtime.ForwardResponseMessage
forward_Qgdzs_GetQuestionInfo_0 = runtime.ForwardResponseMessage
forward_Qgdzs_GetPointRecord_0 = runtime.ForwardResponseMessage
forward_Qgdzs_GetPoint_0 = runtime.ForwardResponseMessage
)

View File

@@ -24,16 +24,33 @@ const _ = grpc.SupportPackageIsVersion7
type QgdzsClient interface {
// 生成题目
GenerateQuestion(ctx context.Context, in *GenerateQuestionReq, opts ...grpc.CallOption) (*GenerateQuestionResp, error)
// ---------- 随机答题 ----------
// 获取题目
GetQuestion(ctx context.Context, in *GetQuestionReq, opts ...grpc.CallOption) (*GetQuestionResp, error)
// 获取具体的题目
GetQuestionInfo(ctx context.Context, in *GetQuestionInfoReq, opts ...grpc.CallOption) (*GetQuestionInfoResp, error)
RandomGetQuestion(ctx context.Context, in *RandomGetQuestionReq, opts ...grpc.CallOption) (*RandomGetQuestionResp, error)
// 回答题目
AnswerQuestion(ctx context.Context, in *AnswerQuestionReq, opts ...grpc.CallOption) (*AnswerQuestionResp, 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 {
@@ -53,27 +70,18 @@ func (c *qgdzsClient) GenerateQuestion(ctx context.Context, in *GenerateQuestion
return out, nil
}
func (c *qgdzsClient) GetQuestion(ctx context.Context, in *GetQuestionReq, opts ...grpc.CallOption) (*GetQuestionResp, error) {
out := new(GetQuestionResp)
err := c.cc.Invoke(ctx, "/Qgdzs/GetQuestion", in, out, opts...)
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) 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) AnswerQuestion(ctx context.Context, in *AnswerQuestionReq, opts ...grpc.CallOption) (*AnswerQuestionResp, error) {
out := new(AnswerQuestionResp)
err := c.cc.Invoke(ctx, "/Qgdzs/AnswerQuestion", in, out, opts...)
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
}
@@ -89,6 +97,42 @@ func (c *qgdzsClient) GetAllCategory(ctx context.Context, in *GetAllCategoryReq,
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...)
@@ -98,22 +142,66 @@ func (c *qgdzsClient) GetRecord(ctx context.Context, in *GetRecordReq, opts ...g
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)
// ---------- 随机答题 ----------
// 获取题目
GetQuestion(context.Context, *GetQuestionReq) (*GetQuestionResp, error)
// 获取具体的题目
GetQuestionInfo(context.Context, *GetQuestionInfoReq) (*GetQuestionInfoResp, error)
RandomGetQuestion(context.Context, *RandomGetQuestionReq) (*RandomGetQuestionResp, error)
// 回答题目
AnswerQuestion(context.Context, *AnswerQuestionReq) (*AnswerQuestionResp, 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()
}
@@ -124,21 +212,39 @@ type UnimplementedQgdzsServer struct {
func (UnimplementedQgdzsServer) GenerateQuestion(context.Context, *GenerateQuestionReq) (*GenerateQuestionResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GenerateQuestion not implemented")
}
func (UnimplementedQgdzsServer) GetQuestion(context.Context, *GetQuestionReq) (*GetQuestionResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetQuestion not implemented")
func (UnimplementedQgdzsServer) RandomGetQuestion(context.Context, *RandomGetQuestionReq) (*RandomGetQuestionResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method RandomGetQuestion not implemented")
}
func (UnimplementedQgdzsServer) GetQuestionInfo(context.Context, *GetQuestionInfoReq) (*GetQuestionInfoResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetQuestionInfo not implemented")
}
func (UnimplementedQgdzsServer) AnswerQuestion(context.Context, *AnswerQuestionReq) (*AnswerQuestionResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method AnswerQuestion 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.
@@ -170,56 +276,38 @@ func _Qgdzs_GenerateQuestion_Handler(srv interface{}, ctx context.Context, dec f
return interceptor(ctx, in, info, handler)
}
func _Qgdzs_GetQuestion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetQuestionReq)
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).GetQuestion(ctx, in)
return srv.(QgdzsServer).RandomGetQuestion(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Qgdzs/GetQuestion",
FullMethod: "/Qgdzs/RandomGetQuestion",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QgdzsServer).GetQuestion(ctx, req.(*GetQuestionReq))
return srv.(QgdzsServer).RandomGetQuestion(ctx, req.(*RandomGetQuestionReq))
}
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)
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).GetQuestionInfo(ctx, in)
return srv.(QgdzsServer).RandomAnswerQuestion(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Qgdzs/GetQuestionInfo",
FullMethod: "/Qgdzs/RandomAnswerQuestion",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QgdzsServer).GetQuestionInfo(ctx, req.(*GetQuestionInfoReq))
}
return interceptor(ctx, in, info, handler)
}
func _Qgdzs_AnswerQuestion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(AnswerQuestionReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QgdzsServer).AnswerQuestion(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/Qgdzs/AnswerQuestion",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QgdzsServer).AnswerQuestion(ctx, req.(*AnswerQuestionReq))
return srv.(QgdzsServer).RandomAnswerQuestion(ctx, req.(*RandomAnswerQuestionReq))
}
return interceptor(ctx, in, info, handler)
}
@@ -242,6 +330,78 @@ func _Qgdzs_GetAllCategory_Handler(srv interface{}, ctx context.Context, dec fun
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 {
@@ -260,6 +420,60 @@ func _Qgdzs_GetRecord_Handler(srv interface{}, ctx context.Context, dec func(int
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)
@@ -272,25 +486,49 @@ var Qgdzs_ServiceDesc = grpc.ServiceDesc{
Handler: _Qgdzs_GenerateQuestion_Handler,
},
{
MethodName: "GetQuestion",
Handler: _Qgdzs_GetQuestion_Handler,
MethodName: "RandomGetQuestion",
Handler: _Qgdzs_RandomGetQuestion_Handler,
},
{
MethodName: "GetQuestionInfo",
Handler: _Qgdzs_GetQuestionInfo_Handler,
},
{
MethodName: "AnswerQuestion",
Handler: _Qgdzs_AnswerQuestion_Handler,
MethodName: "RandomAnswerQuestion",
Handler: _Qgdzs_RandomAnswerQuestion_Handler,
},
{
MethodName: "GetAllCategory",
Handler: _Qgdzs_GetAllCategory_Handler,
},
{
MethodName: "CategoryGetQuestion",
Handler: _Qgdzs_CategoryGetQuestion_Handler,
},
{
MethodName: "CategoryAnswerQuestion",
Handler: _Qgdzs_CategoryAnswerQuestion_Handler,
},
{
MethodName: "QuicklyGetQuestion",
Handler: _Qgdzs_QuicklyGetQuestion_Handler,
},
{
MethodName: "QuicklyAnswerQuestion",
Handler: _Qgdzs_QuicklyAnswerQuestion_Handler,
},
{
MethodName: "GetRecord",
Handler: _Qgdzs_GetRecord_Handler,
},
{
MethodName: "GetQuestionInfo",
Handler: _Qgdzs_GetQuestionInfo_Handler,
},
{
MethodName: "GetPointRecord",
Handler: _Qgdzs_GetPointRecord_Handler,
},
{
MethodName: "GetPoint",
Handler: _Qgdzs_GetPoint_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "service_qgdzs.proto",

View File

@@ -26,9 +26,9 @@ type EnterReq struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
USN string `protobuf:"bytes,1,opt,name=USN,proto3" json:"USN,omitempty"` // 用户ID
GatewaySID string `protobuf:"bytes,2,opt,name=GatewaySID,proto3" json:"GatewaySID,omitempty"` // 网关服务ID
InstanceID int32 `protobuf:"varint,3,opt,name=InstanceID,proto3" json:"InstanceID,omitempty"` // 副本ID
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() {
@@ -63,18 +63,18 @@ func (*EnterReq) Descriptor() ([]byte, []int) {
return file_service_scene_proto_rawDescGZIP(), []int{0}
}
func (x *EnterReq) GetUSN() string {
func (x *EnterReq) GetUSN() int64 {
if x != nil {
return x.USN
}
return ""
return 0
}
func (x *EnterReq) GetGatewaySID() string {
func (x *EnterReq) GetGatewaySID() int64 {
if x != nil {
return x.GatewaySID
}
return ""
return 0
}
func (x *EnterReq) GetInstanceID() int32 {
@@ -89,8 +89,8 @@ type EnterResp struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
SceneSID string `protobuf:"bytes,1,opt,name=SceneSID,proto3" json:"SceneSID,omitempty"` // 场景服务ID
UniqueNo string `protobuf:"bytes,2,opt,name=UniqueNo,proto3" json:"UniqueNo,omitempty"` // 副本唯一编号
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"` // 消息负载
}
@@ -127,18 +127,18 @@ func (*EnterResp) Descriptor() ([]byte, []int) {
return file_service_scene_proto_rawDescGZIP(), []int{1}
}
func (x *EnterResp) GetSceneSID() string {
func (x *EnterResp) GetSceneSID() int64 {
if x != nil {
return x.SceneSID
}
return ""
return 0
}
func (x *EnterResp) GetUniqueNo() string {
func (x *EnterResp) GetUniqueNo() int64 {
if x != nil {
return x.UniqueNo
}
return ""
return 0
}
func (x *EnterResp) GetMessageID() int32 {
@@ -160,8 +160,8 @@ type LeaveReq struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
USN string `protobuf:"bytes,1,opt,name=USN,proto3" json:"USN,omitempty"` // 用户ID
UniqueNo string `protobuf:"bytes,2,opt,name=UniqueNo,proto3" json:"UniqueNo,omitempty"` // 副本唯一编号
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() {
@@ -196,18 +196,18 @@ func (*LeaveReq) Descriptor() ([]byte, []int) {
return file_service_scene_proto_rawDescGZIP(), []int{2}
}
func (x *LeaveReq) GetUSN() string {
func (x *LeaveReq) GetUSN() int64 {
if x != nil {
return x.USN
}
return ""
return 0
}
func (x *LeaveReq) GetUniqueNo() string {
func (x *LeaveReq) GetUniqueNo() int64 {
if x != nil {
return x.UniqueNo
}
return ""
return 0
}
type LeaveResp struct {
@@ -253,12 +253,12 @@ type ActionReq struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
UniqueNo string `protobuf:"bytes,1,opt,name=UniqueNo,proto3" json:"UniqueNo,omitempty"` // 副本唯一编号
USN string `protobuf:"bytes,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
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() {
@@ -293,18 +293,18 @@ func (*ActionReq) Descriptor() ([]byte, []int) {
return file_service_scene_proto_rawDescGZIP(), []int{4}
}
func (x *ActionReq) GetUniqueNo() string {
func (x *ActionReq) GetUniqueNo() int64 {
if x != nil {
return x.UniqueNo
}
return ""
return 0
}
func (x *ActionReq) GetUSN() string {
func (x *ActionReq) GetUSN() int64 {
if x != nil {
return x.USN
}
return ""
return 0
}
func (x *ActionReq) GetAction() int32 {
@@ -379,27 +379,27 @@ 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, 0x09, 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, 0x09, 0x52, 0x0a, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61,
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, 0x09, 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, 0x09, 0x52,
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, 0x09, 0x52, 0x03, 0x55, 0x53, 0x4e, 0x12,
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,
0x09, 0x52, 0x08, 0x55, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x4e, 0x6f, 0x22, 0x0b, 0x0a, 0x09, 0x4c,
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, 0x09, 0x52, 0x08, 0x55, 0x6e, 0x69, 0x71, 0x75, 0x65,
0x4e, 0x6f, 0x12, 0x10, 0x0a, 0x03, 0x55, 0x53, 0x4e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
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,

View File

@@ -83,7 +83,7 @@ type PhoneLoginResp struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
USN string `protobuf:"bytes,1,opt,name=USN,json=usn,proto3" json:"USN,omitempty"` // 用户ID
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"` // 用户名
}
@@ -119,11 +119,11 @@ func (*PhoneLoginResp) Descriptor() ([]byte, []int) {
return file_service_user_proto_rawDescGZIP(), []int{1}
}
func (x *PhoneLoginResp) GetUSN() string {
func (x *PhoneLoginResp) GetUSN() int64 {
if x != nil {
return x.USN
}
return ""
return 0
}
func (x *PhoneLoginResp) GetName() string {
@@ -186,7 +186,7 @@ type WxMiniLoginResp struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
USN string `protobuf:"bytes,1,opt,name=USN,json=usn,proto3" json:"USN,omitempty"` // 用户ID
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"` // 用户名
}
@@ -222,11 +222,11 @@ func (*WxMiniLoginResp) Descriptor() ([]byte, []int) {
return file_service_user_proto_rawDescGZIP(), []int{3}
}
func (x *WxMiniLoginResp) GetUSN() string {
func (x *WxMiniLoginResp) GetUSN() int64 {
if x != nil {
return x.USN
}
return ""
return 0
}
func (x *WxMiniLoginResp) GetName() string {
@@ -242,7 +242,7 @@ type GetUserInfoReq struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
USN string `protobuf:"bytes,1,opt,name=USN,json=usn,proto3" json:"USN,omitempty"`
USN int64 `protobuf:"varint,1,opt,name=USN,json=usn,proto3" json:"USN,omitempty"`
}
func (x *GetUserInfoReq) Reset() {
@@ -277,11 +277,11 @@ func (*GetUserInfoReq) Descriptor() ([]byte, []int) {
return file_service_user_proto_rawDescGZIP(), []int{4}
}
func (x *GetUserInfoReq) GetUSN() string {
func (x *GetUserInfoReq) GetUSN() int64 {
if x != nil {
return x.USN
}
return ""
return 0
}
type GetUserInfoResp struct {
@@ -289,7 +289,7 @@ type GetUserInfoResp struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
USN string `protobuf:"bytes,1,opt,name=USN,json=usn,proto3" json:"USN,omitempty"`
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"`
}
@@ -325,11 +325,11 @@ func (*GetUserInfoResp) Descriptor() ([]byte, []int) {
return file_service_user_proto_rawDescGZIP(), []int{5}
}
func (x *GetUserInfoResp) GetUSN() string {
func (x *GetUserInfoResp) GetUSN() int64 {
if x != nil {
return x.USN
}
return ""
return 0
}
func (x *GetUserInfoResp) GetName() string {
@@ -351,19 +351,19 @@ var file_service_user_proto_rawDesc = []byte{
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, 0x09, 0x52, 0x03, 0x75,
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, 0x09, 0x52, 0x03, 0x75, 0x73,
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, 0x09, 0x52, 0x03, 0x75, 0x73, 0x6e, 0x22, 0x37, 0x0a, 0x0f, 0x47, 0x65, 0x74,
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, 0x09, 0x52, 0x03, 0x75, 0x73, 0x6e, 0x12, 0x12,
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,

View File

@@ -259,9 +259,9 @@ type PositionInfo struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
USN string `protobuf:"bytes,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"`
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() {
@@ -296,11 +296,11 @@ func (*PositionInfo) Descriptor() ([]byte, []int) {
return file_action_proto_rawDescGZIP(), []int{3}
}
func (x *PositionInfo) GetUSN() string {
func (x *PositionInfo) GetUSN() int64 {
if x != nil {
return x.USN
}
return ""
return 0
}
func (x *PositionInfo) GetX() int32 {
@@ -388,7 +388,7 @@ var file_action_proto_rawDesc = []byte{
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, 0x09, 0x52, 0x03, 0x55, 0x53, 0x4e, 0x12, 0x0c, 0x0a, 0x01,
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,

View File

@@ -25,6 +25,9 @@ func (e *WrapErrors) StackTrace() string {
}
func ErrorsWrap(err error, message ...string) error {
if err == nil {
return nil
}
var e *WrapErrors
if !errors.As(err, &e) {
e = &WrapErrors{}
@@ -39,6 +42,9 @@ func ErrorsWrap(err error, message ...string) error {
}
func ErrorsWrapF(err error, message string, a ...any) error {
if err == nil {
return nil
}
var e *WrapErrors
if !errors.As(err, &e) {
e = &WrapErrors{}

View File

@@ -1,19 +1,17 @@
package utils
import (
"context"
"errors"
"github.com/golang-jwt/jwt/v5"
"google.golang.org/grpc/metadata"
"time"
)
type Claims struct {
USN string `json:"usn"`
USN int64 `json:"usn"`
jwt.RegisteredClaims
}
func GenToken(usn string, secret string, expires time.Duration) (string, error) {
func GenToken(usn int64, secret string, expires time.Duration) (string, error) {
token := jwt.NewWithClaims(jwt.SigningMethodHS256, Claims{
USN: usn,
RegisteredClaims: jwt.RegisteredClaims{
@@ -39,14 +37,3 @@ func ParseToken(tokenString string, secret string) (*Claims, error) {
}
return claims, nil
}
func ShouldBindUsn(ctx context.Context, usn *string) bool {
if md, ok := metadata.FromIncomingContext(ctx); ok {
usnArr := md.Get("X-Usn")
if len(usnArr) == 0 || usnArr[0] == "" {
return false
}
*usn = usnArr[0]
}
return *usn != ""
}

View File

@@ -21,3 +21,8 @@ func StringToInt64(s string) int64 {
}
return i
}
// Int64ToString converts int64 to string
func Int64ToString(i int64) string {
return strconv.FormatInt(i, 10)
}

29
utils/session.go Normal file
View File

@@ -0,0 +1,29 @@
package utils
import (
"context"
"google.golang.org/grpc/metadata"
)
type UserSession struct {
USN int64 `json:"usn" redis:"usn"`
IP string `json:"ip" redis:"ip"`
UserAgent string `json:"ua" redis:"ua"`
AccessToken string `json:"at" redis:"at"`
RefreshToken string `json:"rt" redis:"rt"`
}
func (us *UserSession) GetUsnKey() string {
return "usn"
}
func ShouldBindUsn(ctx context.Context, usn *int64) bool {
if md, ok := metadata.FromIncomingContext(ctx); ok {
usnArr := md.Get("X-Usn")
if len(usnArr) == 0 || usnArr[0] == "" {
return false
}
*usn = StringToInt64(usnArr[0])
}
return *usn != 0
}