Browse Source

压测提交

liliang 8 months ago
parent
commit
a74f5ea500

+ 1 - 1
components/data-config/source_redis.go

@@ -27,7 +27,7 @@ type (
 	redisConfig struct {
 		Address      string `json:"address"`       // redis地址
 		Password     string `json:"password"`      // 密码
-		DB           int    `json:"db"`            // db index
+		DB           int    `json:"database"`      // database index
 		PrefixKey    string `json:"prefix_key"`    // 前缀
 		SubscribeKey string `json:"subscribe_key"` // 订阅key
 	}

+ 2 - 2
components/gorm/component.go

@@ -76,9 +76,9 @@ func (s *Component) Init() {
 		return
 	}
 
-	dbConfig := cprofile.GetConfig("db")
+	dbConfig := cprofile.GetConfig("database")
 	if dbConfig.LastError() != nil {
-		clog.Panic("`db` property not exists in profile file.")
+		clog.Panic("`database` property not exists in profile file.")
 	}
 
 	for _, groupId := range dbConfig.Keys() {

+ 1 - 1
components/mongo/component.go

@@ -138,7 +138,7 @@ func CreateDatabase(uri, dbName string, tlsEnable int, maxPoolSize uint64, minPo
 		return nil, err
 	}
 
-	clog.Infof("ping db [uri = %s] is ok", uri)
+	clog.Infof("ping database [uri = %s] is ok", uri)
 
 	return client.Database(dbName), nil
 }

+ 2 - 2
const/const.go

@@ -5,7 +5,7 @@ import (
 )
 
 const (
-	version = "1.0.35"
+	version = "1.0.37"
 )
 
 var logo = `
@@ -20,7 +20,7 @@ var logo = `
 ◇◇◇◆◆◇◆◆◆◇◇◆◇◇◇◇◇◇◇◇◆◇◇◇◆◇◇◇◇◇◇◇◇◇◆◆◆◆◆◆◆◆◇◇◇◇◇◇◇◇◇◇◆◆◇◇◇◇◇◇◇◇◇◇◆◆◆◆◆◆◆◆◇◇◇
 ◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◆◆◆◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇
 ◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◆◆◆◆◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇
-db sever framework @v%s
+database sever framework @v%s
 `
 
 func GetLOGO() string {

+ 2 - 2
extend/file/file_test.go

@@ -6,7 +6,7 @@ import (
 )
 
 func TestWalkFiles(t *testing.T) {
-	files := WalkFiles("../../db/config/", ".json")
+	files := WalkFiles("../../database/config/", ".json")
 
 	for _, file := range files {
 		fmt.Println(file)
@@ -14,7 +14,7 @@ func TestWalkFiles(t *testing.T) {
 }
 
 func TestReadDir(t *testing.T) {
-	files, err := ReadDir("../../db/config/", "profile-", ".json")
+	files, err := ReadDir("../../database/config/", "profile-", ".json")
 	if err != nil {
 		fmt.Println(err)
 		return

+ 1 - 1
extend/mapstructure/mapstructure.go

@@ -5,7 +5,7 @@
 // The Go structure can be arbitrarily complex, containing slices,
 // other structs, etc. and the decoder will properly decode nested
 // maps and so on into the proper structures in the native Go struct.
-// See the db to see what the decoder is capable of.
+// See the database to see what the decoder is capable of.
 //
 // The simplest function to start with is Decode.
 //

+ 1 - 1
extend/snowflake/snowflake_test.go

@@ -75,7 +75,7 @@ func TestRace(t *testing.T) {
 }
 
 func TestAtomicInt64(t *testing.T) {
-	nodeId := "db-123"
+	nodeId := "database-123"
 	nodeIdCRC32 := CRC32(nodeId)
 
 	t.Logf("nodeIdCRC32 : %#v", nodeIdCRC32)

+ 2 - 2
game/config/profile-gc.json

@@ -256,7 +256,7 @@
     ]
   },
   "redis": {
-    "address": "127.0.0.1:6379",
+    "address": "s5.z100.vip:36379",
     "password": "",
     "db": 0,
     "tls": 0
@@ -272,7 +272,7 @@
     "redis": {
       "prefix_key": "data_config",
       "subscribe_key": "data_config_change",
-      "address": "127.0.0.1:6379",
+      "address": "s5.z100.vip:36379",
       "password": "",
       "db": 7,
       "tls": 0

+ 1 - 1
game/game_cluster/internal/constant/constant.go

@@ -1,7 +1,7 @@
 package constant
 
 const (
-	GameNodeType   = "db"
+	GameNodeType   = "database"
 	Token          = "Token"
 	RankKey        = "rank"
 	CountryRankKey = "countryRank"

+ 3 - 3
game/game_cluster/internal/mdb/component.go

@@ -23,7 +23,7 @@ var (
 )
 
 func (p *ActorDB) AliasID() string {
-	return "db" + p.Name
+	return "database" + p.Name
 }
 
 // OnInit Actor初始化前触发该函数
@@ -52,14 +52,14 @@ func (p *ActorDB) OnInit() {
 		RDB = redis.NewUniversalClient(&redis.UniversalOptions{
 			Addrs:     strings.Split(redisConfig.GetString("address"), ","),
 			Password:  redisConfig.GetString("password"),
-			DB:        redisConfig.GetInt("db"),
+			DB:        redisConfig.GetInt("database"),
 			TLSConfig: tlsConfig,
 		})
 	} else {
 		RDB = redis.NewUniversalClient(&redis.UniversalOptions{
 			Addrs:    strings.Split(redisConfig.GetString("address"), ","),
 			Password: redisConfig.GetString("password"),
-			DB:       redisConfig.GetInt("db"),
+			DB:       redisConfig.GetInt("database"),
 		})
 	}
 

+ 1 - 1
game/game_cluster/internal/rpc/center/center.go

@@ -18,7 +18,7 @@ import (
 
 const (
 	centerType = "center"
-	gameType   = "db"
+	gameType   = "database"
 )
 
 const (

+ 1 - 1
game/game_cluster/internal/rpc/game/game.go

@@ -32,5 +32,5 @@ func SessionClose(app cfacade.IApplication, session *cproto.Session) {
 	app.ActorSystem().Call("", targetPath, sessionClose, &pb.Int64{
 		Value: session.Uid,
 	})
-	//clog.Infof("send close session to db node. [node = %s, uid = %d]", nodeId, session.Uid)
+	//clog.Infof("send close session to database node. [node = %s, uid = %d]", nodeId, session.Uid)
 }

+ 1 - 1
game/game_cluster/nodes/adminapi/entity/admin.go

@@ -1,6 +1,6 @@
 package entity
 
-// AdminResp \db\game_cluster\nodes\adminapi\entity\admin.go
+// AdminResp \database\game_cluster\nodes\adminapi\entity\admin.go
 type AdminResp struct {
 	ToKen  string `json:"token"`
 	RoleID string `json:"role_id"`

+ 1 - 1
game/game_cluster/nodes/adminapi/entity/user_withdrawal.go

@@ -5,7 +5,7 @@ type UserWithdrawalResp struct {
 	Total   int64                   `json:"total"`
 }
 
-// UserWithdrawalResp \db\game_cluster\nodes\adminapi\entity\user_withdrawal.go
+// UserWithdrawalResp \database\game_cluster\nodes\adminapi\entity\user_withdrawal.go
 type UserWithdrawalDetail struct {
 	Id          string      `json:"id" bson:"_id"`                    // Id
 	UserName    string      `json:"user_name" bson:"userName"`        // 用户ID

+ 1 - 1
game/game_cluster/nodes/adminapi/web/web.go

@@ -12,7 +12,7 @@ import (
 
 func main() {
 	// 配置mhaya引擎,加载profile配置文件
-	app := mhaya.Configure("./db/config/profile-gc.json", "m-web-admin-api-1", false, mhaya.Cluster)
+	app := mhaya.Configure("./database/config/profile-gc.json", "m-web-admin-api-1", false, mhaya.Cluster)
 
 	// // 注册调度组件
 	// app.Register(mhayaCron.New())

+ 1 - 1
game/game_cluster/nodes/db/db.go

@@ -12,7 +12,7 @@ import (
 )
 
 func main() {
-	nodeId := "m-db"
+	nodeId := "m-database"
 	// 配置mhaya引擎
 	app := mhaya.Configure("./config/profile-gc.json", nodeId, false, mhaya.Cluster)
 

+ 1 - 1
game/game_cluster/nodes/game/module/player/actor_player.go

@@ -218,7 +218,7 @@ func (p *actorPlayer) SetRewardToDB() {
 			for k, r := range p.Player.PlayerReward {
 				_, err := mdb.MDB.Collection(constant.CNamePlayerReward).InsertOne(context.Background(), r)
 				if err != nil {
-					clog.Errorf("[actorPlayer] set invite to db error: %v", err)
+					clog.Errorf("[actorPlayer] set invite to database error: %v", err)
 				}
 				delete(p.Player.PlayerReward, k)
 			}

+ 12 - 12
game/game_cluster/nodes/main.go

@@ -9,7 +9,7 @@ import (
 	"github.com/mhaya/game/game_cluster/nodes/game/game"
 	"github.com/mhaya/game/game_cluster/nodes/webadmin"
 
-	//	"github.com/mhaya/db/game_cluster/nodes/gate"
+	//	"github.com/mhaya/database/game_cluster/nodes/gate"
 	"github.com/mhaya/game/game_cluster/nodes/master/master"
 	"github.com/mhaya/game/game_cluster/nodes/web/web"
 	"github.com/urfave/cli/v2"
@@ -18,8 +18,8 @@ import (
 
 func main() {
 	app := &cli.App{
-		Name:        "db cluster node",
-		Description: "db cluster node db",
+		Name:        "database cluster node",
+		Description: "database cluster node database",
 		Commands: []*cli.Command{
 			versionCommand(),
 			masterCommand(),
@@ -53,7 +53,7 @@ func masterCommand() *cli.Command {
 	return &cli.Command{
 		Name:      "master",
 		Usage:     "run master node",
-		UsageText: "node master --path=./db/config/profile-gc.json --node=m-master",
+		UsageText: "node master --path=./database/config/profile-gc.json --node=m-master",
 		Flags:     getFlag(),
 		Action: func(c *cli.Context) error {
 			path, node := getParameters(c)
@@ -67,7 +67,7 @@ func centerCommand() *cli.Command {
 	return &cli.Command{
 		Name:      "center",
 		Usage:     "run center node",
-		UsageText: "node center --path=./db/config/profile-gc.json --node=m-center",
+		UsageText: "node center --path=./database/config/profile-gc.json --node=m-center",
 		Flags:     getFlag(),
 		Action: func(c *cli.Context) error {
 			path, node := getParameters(c)
@@ -81,7 +81,7 @@ func webCommand() *cli.Command {
 	return &cli.Command{
 		Name:      "web",
 		Usage:     "run web node",
-		UsageText: "node web --path=./db/config/profile-gc.json --node=m-web-1",
+		UsageText: "node web --path=./database/config/profile-gc.json --node=m-web-1",
 		Flags:     getFlag(),
 		Action: func(c *cli.Context) error {
 			path, node := getParameters(c)
@@ -95,7 +95,7 @@ func webadminCommand() *cli.Command {
 	return &cli.Command{
 		Name:      "webadmin",
 		Usage:     "run webadmin node",
-		UsageText: "node webadmin --path=./db/config/profile-gc.json --node=m-webadmin-1",
+		UsageText: "node webadmin --path=./database/config/profile-gc.json --node=m-webadmin-1",
 		Flags:     getFlag(),
 		Action: func(c *cli.Context) error {
 			path, node := getParameters(c)
@@ -109,7 +109,7 @@ func adminApiCommand() *cli.Command {
 	return &cli.Command{
 		Name:      "adminapi",
 		Usage:     "run adminapi node",
-		UsageText: "node adminapi --path=./db/config/profile-gc.json --node=m-web-admin-api-1",
+		UsageText: "node adminapi --path=./database/config/profile-gc.json --node=m-web-admin-api-1",
 		Flags:     getFlag(),
 		Action: func(c *cli.Context) error {
 			path, node := getParameters(c)
@@ -123,7 +123,7 @@ func adminApiCommand() *cli.Command {
 	return &cli.Command{
 		Name:      "gate",
 		Usage:     "run gate node",
-		UsageText: "node gate --path=./db/config/profile-gc.json --node=m-gate-1",
+		UsageText: "node gate --path=./database/config/profile-gc.json --node=m-gate-1",
 		Flags:     getFlag(),
 		Action: func(c *cli.Context) error {
 			path, node := getParameters(c)
@@ -137,7 +137,7 @@ func gameCommand() *cli.Command {
 	return &cli.Command{
 		Name:      "game",
 		Usage:     "run game node",
-		UsageText: "node game --path=./db/config/profile-gc.json --node=10001",
+		UsageText: "node game --path=./database/config/profile-gc.json --node=10001",
 		Flags:     getFlag(),
 		Action: func(c *cli.Context) error {
 			path, node := getParameters(c)
@@ -151,7 +151,7 @@ func dbCommand() *cli.Command {
 	return &cli.Command{
 		Name:      "database",
 		Usage:     "run database node",
-		UsageText: "node database --path=./db/config/profile-gc.json --node=m-db",
+		UsageText: "node database --path=./database/config/profile-gc.json --node=m-database",
 		Flags:     getFlag(),
 		Action: func(c *cli.Context) error {
 			path, node := getParameters(c)
@@ -173,7 +173,7 @@ func getFlag() []cli.Flag {
 			Name:     "path",
 			Usage:    "profile config path",
 			Required: false,
-			Value:    "./db/config/profile-gc.json",
+			Value:    "./database/config/profile-gc.json",
 		},
 		&cli.StringFlag{
 			Name:     "node",

+ 1 - 1
game/game_cluster/nodes/master/master.go

@@ -5,6 +5,6 @@ import (
 )
 
 func main() {
-	app := mhaya.Configure("./db/config/profile-gc.json", "m-master", false, mhaya.Cluster)
+	app := mhaya.Configure("./database/config/profile-gc.json", "m-master", false, mhaya.Cluster)
 	app.Startup()
 }

+ 1 - 1
game/game_cluster/nodes/web/controller/controller.go

@@ -268,7 +268,7 @@ func (p *Controller) auth(c *mhayaGin.Context) {
 					code.RenderResult(c, code.LoginError)
 					return
 				}
-				dbPath := cfacade.NewChildPath("m-db", "dbs", playerId)
+				dbPath := cfacade.NewChildPath("m-database", "dbs", playerId)
 				ctl.Call(dbPath, "setAccountDb", account)
 		*/
 		//重新获取认证 需要断天原来服务器

+ 1 - 1
game/game_cluster/nodes/webadmin/entity/admin.go

@@ -2,7 +2,7 @@ package entity
 
 import "github.com/mhaya/game/game_cluster/internal/mdb/models"
 
-// AdminResp \db\game_cluster\nodes\webadmin\entity\admin.go
+// AdminResp \database\game_cluster\nodes\webadmin\entity\admin.go
 type AdminResp struct {
 	ToKen  string `json:"token"`
 	RoleID string `json:"role_id"`

+ 1 - 1
game/game_cluster/nodes/webadmin/entity/user_withdrawal.go

@@ -1,6 +1,6 @@
 package entity
 
-// UserWithdrawalResp \db\game_cluster\nodes\webadmin\entity\user_withdrawal.go
+// UserWithdrawalResp \database\game_cluster\nodes\webadmin\entity\user_withdrawal.go
 type UserWithdrawalResp struct {
 	Id          string      `json:"id" bson:"_id"`                    // Id
 	UserName    string      `json:"user_name" bson:"userName"`        // 用户ID

+ 1 - 1
game/game_cluster/nodes/webadmin/web/web.go

@@ -15,7 +15,7 @@ import (
 
 func main() {
 	// 配置mhaya引擎,加载profile配置文件
-	app := mhaya.Configure("./db/config/profile-gc.json", "m-web-admin-1", false, mhaya.Cluster)
+	app := mhaya.Configure("./database/config/profile-gc.json", "m-web-admin-1", false, mhaya.Cluster)
 
 	// 注册调度组件
 	app.Register(mhayaCron.New())

+ 1 - 1
game/game_cluster/robot_client/main.go

@@ -324,7 +324,7 @@ func Invite(url string, params map[string]interface{}, token string) {
 //	}
 //
 //	elapsedTime := cli.StartTime.DiffInMillisecond(mhayaTime.Now())
-//	mhayaLogger.Debugf("[%s] is enter to db. elapsed time:%dms", cli.TagName, elapsedTime)
+//	mhayaLogger.Debugf("[%s] is enter to database. elapsed time:%dms", cli.TagName, elapsedTime)
 //
 //	//cli.Disconnect()
 //

+ 3 - 3
game/game_cluster/robot_client/robot.go

@@ -103,7 +103,7 @@ func (p *Robot) UserLogin(serverId int32) error {
 
 // PlayerSelect 查看玩家列表
 func (p *Robot) PlayerSelect() error {
-	route := "db.player.select"
+	route := "database.player.select"
 
 	msg, err := p.Request(route, &pb.None{})
 	if err != nil {
@@ -136,7 +136,7 @@ func (p *Robot) ActorCreate() error {
 		return nil
 	}
 
-	route := "db.player.create"
+	route := "database.player.create"
 	gender := rand.Int31n(1)
 
 	req := &pb.PlayerCreateRequest{
@@ -165,7 +165,7 @@ func (p *Robot) ActorCreate() error {
 
 // ActorEnter 角色进入游戏
 func (p *Robot) ActorEnter() error {
-	route := "db.player.enter"
+	route := "database.player.enter"
 	req := &pb.Int64{
 		Value: p.PlayerId,
 	}

+ 2 - 2
profile/profile_test.go

@@ -6,7 +6,7 @@ import (
 )
 
 func TestLoadFile(t *testing.T) {
-	path := "../../db/config/profile-dev.json"
-	node, err := Init(path, "db-1")
+	path := "../../database/config/profile-dev.json"
+	node, err := Init(path, "database-1")
 	fmt.Println(node, err)
 }

+ 1 - 1
ver.sh

@@ -13,7 +13,7 @@ sed -i 's/version\s*=\s*"[0-9.]\+"/version = "'"${number}"'"/' ${file_path}
 file_path='components/**/go.mod'
 sed -i 's/mhaya v[0-9.]\+/mhaya v'"${number}"'/' ${file_path}
 
-file_path='db/go.mod'
+file_path='database/go.mod'
 sed -i 's/mhaya v[0-9.]\+/mhaya v'"${number}"'/' ${file_path}
 sed -i 's/components\/cron v[0-9.]\+/components\/cron v'"${number}"'/' ${file_path}
 sed -i 's/components\/data-config v[0-9.]\+/components\/data-config v'"${number}"'/' ${file_path}

+ 23 - 2
z-deploy/docker/docker-compose.yml

@@ -52,7 +52,7 @@ services:
       - "27017:27017"
     volumes:
       - ./mongo/mongod.conf:/etc/mongod.conf
-      - ./mongo/db:/data/db
+      - ./mongo/database:/data/database
       - ./mongo/data/log:/data/log
     command: [ "mongod", "--config", "/etc/mongod.conf" ]
     restart: always
@@ -97,7 +97,7 @@ services:
     build:
       context: ./game
       dockerfile: Dockerfile
-    container_name: db
+    container_name: database
     environment:
       - GO_ENV=development  # 可以根据需要设置环境变量
     volumes:
@@ -197,6 +197,27 @@ services:
       - redis
       - mongodb
 
+  database:
+    build:
+      context: ./database
+      dockerfile: Dockerfile
+    container_name: database
+    ports:
+      - "20000:20000"
+    environment:
+      - GO_ENV=development  # 可以根据需要设置环境变量
+    volumes:
+      - .:/app  # 如果需要将本地代码挂载到容器中进行开发
+      - ./config:/config  # 挂载宿主机的配置文件目录到容器内的 /config
+    restart: always
+    networks:
+      - my_custom_network
+    depends_on:
+      - etcd
+      - nats
+      - redis
+      - mongodb
+
   adminapi:
     build:
       context: ./adminapi

+ 1 - 1
z-deploy/docker/game/Dockerfile

@@ -7,7 +7,7 @@ WORKDIR /root/
 # 将编译好的二进制文件复制到镜像中
 #COPY config ./config
 COPY game .
-RUN chmod +x ./db
+RUN chmod +x ./database
 
 # 暴露端口(如果需要)
 #EXPOSE 8080