58 lines
1.9 KiB
Go
58 lines
1.9 KiB
Go
package base
|
|
|
|
import (
|
|
"context"
|
|
|
|
"go.etcd.io/etcd/client/v3"
|
|
"mongo.games.com/goserver/core/logger"
|
|
|
|
"mongo.games.com/game/etcd"
|
|
"mongo.games.com/game/model"
|
|
"mongo.games.com/game/protocol/webapi"
|
|
"mongo.games.com/game/srvdata"
|
|
)
|
|
|
|
var ConfigMgrInst = model.NewConfigMgr()
|
|
|
|
func init() {
|
|
// 个人水池
|
|
etcd.Register(etcd.ETCDKEY_PLAYERPOOL, webapi.PlayerPool{}, platformConfigEtcd)
|
|
// 游戏配置
|
|
etcd.Register(etcd.ETCDKEY_GAME_CONFIG, webapi.GameConfig{}, platformConfigEtcd)
|
|
// 道具列表
|
|
etcd.Register(etcd.ETCDKEY_Item, webapi.ItemConfig{}, platformConfigEtcd)
|
|
// 集卡活动
|
|
etcd.Register(etcd.ETCDKEY_ACT_Collect, webapi.WelfareCollectConfig{}, platformConfigEtcd)
|
|
// 渠道开关
|
|
etcd.Register(etcd.ETCDKEY_ChannelSwitch, webapi.ChannelSwitchConfig{}, platformConfigEtcd)
|
|
// 皮肤配置
|
|
etcd.Register(etcd.ETCDKEY_SKin, webapi.SkinConfig{}, platformConfigEtcd)
|
|
// 娃娃机配置
|
|
etcd.Register(etcd.ETCDKEY_MACHINE, webapi.MachineConfig{}, platformConfigEtcd)
|
|
}
|
|
|
|
func platformConfigEtcd(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{}) {
|
|
if event.Type == clientv3.EventTypeDelete {
|
|
return
|
|
}
|
|
switch d := data.(type) {
|
|
case *webapi.PlayerPool:
|
|
ConfigMgrInst.GetConfig(d.Platform).PlayerPool = d
|
|
case *webapi.GameConfig:
|
|
ConfigMgrInst.GetConfig(d.Platform).GameConfig = d
|
|
case *webapi.WelfareCollectConfig:
|
|
ConfigMgrInst.GetConfig(d.Platform).WelfareCollectConfig = d
|
|
case *webapi.ChannelSwitchConfig:
|
|
ConfigMgrInst.GetConfig(d.Platform).ChannelSwitch[d.GetTp()] = d
|
|
case *webapi.SkinConfig:
|
|
ConfigMgrInst.GetConfig(d.Platform).SkinConfig = d
|
|
case *webapi.MachineConfig:
|
|
ConfigMgrInst.GetConfig(d.Platform).MachineConfig = d
|
|
case *webapi.ItemConfig:
|
|
ConfigMgrInst.GetConfig(d.Platform).ItemConfig = d
|
|
srvdata.GameItemMgr.SetConfig(d)
|
|
default:
|
|
logger.Logger.Errorf("etcd completeKey:%s, Not processed", completeKey)
|
|
}
|
|
}
|