Refactor: Remove deprecated gRPC service files and implement new API structure
- Deleted old gRPC service definitions in `game_grpc.pb.go` and `public.go`. - Added new API server implementations for objectstory, player, and shop services. - Introduced configuration files for new APIs in `etc/*.yaml`. - Created main entry points for each service in `objectstory.go`, `player.go`, and `shop.go`. - Removed unused user update handler and user API files. - Added utility functions for context management and HTTP header parsing. - Introduced PostgreSQL backup configuration in `backup/postgreSql.yaml`.
This commit is contained in:
@@ -1,16 +1,19 @@
|
||||
package svc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"juwan-backend/app/shop/rpc/internal/config"
|
||||
"juwan-backend/app/shop/rpc/internal/models"
|
||||
"juwan-backend/app/snowflake/rpc/snowflake"
|
||||
"juwan-backend/common/redisx"
|
||||
"juwan-backend/common/snowflakex"
|
||||
"juwan-backend/pkg/adapter"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"ariga.io/entcache"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
_ "github.com/jackc/pgx/v5/stdlib"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
@@ -40,10 +43,22 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
||||
|
||||
RWDrv := entcache.NewDriver(RWConn, entcache.TTL(30*time.Second), entcache.Levels(adapter.NewRedisCache(redisCluster.Client)))
|
||||
RODrv := entcache.NewDriver(ROConn, entcache.TTL(30*time.Second), entcache.Levels(adapter.NewRedisCache(redisCluster.Client)))
|
||||
|
||||
entLogFn := func(v ...any) {
|
||||
logx.Infof("[ent][shop] %s", fmt.Sprint(v...))
|
||||
}
|
||||
|
||||
rwModelOpts := []models.Option{models.Driver(RWDrv), models.Log(entLogFn)}
|
||||
roModelOpts := []models.Option{models.Driver(RODrv), models.Log(entLogFn)}
|
||||
if strings.EqualFold(c.Log.Level, "debug") {
|
||||
rwModelOpts = append(rwModelOpts, models.Debug())
|
||||
roModelOpts = append(roModelOpts, models.Debug())
|
||||
}
|
||||
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
Snowflake: snowflakex.NewClient(c.SnowflakeRpcConf),
|
||||
ShopModelRO: models.NewClient(models.Driver(RODrv)),
|
||||
ShopModelRW: models.NewClient(models.Driver(RWDrv)),
|
||||
ShopModelRO: models.NewClient(roModelOpts...),
|
||||
ShopModelRW: models.NewClient(rwModelOpts...),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user