66 lines
1.9 KiB
Go
66 lines
1.9 KiB
Go
package main
|
|
|
|
import (
|
|
"go.etcd.io/etcd/client/v3"
|
|
"mongo.games.com/goserver/core/logger"
|
|
|
|
"mongo.games.com/game/etcd"
|
|
"mongo.games.com/game/protocol/webapi"
|
|
)
|
|
|
|
func init() {
|
|
// 个人水池配置
|
|
etcd.Register(etcd.ETCDKEY_PLAYERPOOL, webapi.PlayerPool{}, PlatformConfigEtcd)
|
|
// 商品兑换
|
|
etcd.Register(etcd.ETCDKEY_SHOP_EXCHANGE, webapi.ExchangeShopList{}, ExchangeShopList)
|
|
// 商城商品
|
|
etcd.Register(etcd.ETCDKEY_SHOP_ITEM, webapi.ItemShopList{}, ItemShopList)
|
|
// 集卡活动
|
|
etcd.Register(etcd.ETCDKEY_ACT_Collect, webapi.WelfareCollectConfig{}, WelfareCollectConfig)
|
|
}
|
|
|
|
//func ExchangeShopList(completeKey string, isInit bool, event *clientv3.Event, data interface{}) {}
|
|
|
|
func WelfareCollectConfig(completeKey string, isInit bool, event *clientv3.Event, data interface{}) {
|
|
if event.Type == clientv3.EventTypeDelete {
|
|
return
|
|
}
|
|
config, ok := data.(*webapi.WelfareCollectConfig)
|
|
if !ok {
|
|
logger.Logger.Errorf("etcd completeKey:%s, data type error", completeKey)
|
|
return
|
|
}
|
|
WelfareMgrSington.UpdateCollectConfig(config)
|
|
}
|
|
|
|
func ItemShopList(completeKey string, isInit bool, event *clientv3.Event, data interface{}) {
|
|
if event.Type == clientv3.EventTypeDelete {
|
|
return
|
|
}
|
|
config, ok := data.(*webapi.ItemShopList)
|
|
if !ok {
|
|
logger.Logger.Errorf("etcd completeKey:%s, data type error", completeKey)
|
|
return
|
|
}
|
|
ShopMgrSington.UpdateItemShop(config)
|
|
}
|
|
|
|
func PlatformConfigEtcd(completeKey string, isInit bool, event *clientv3.Event, data interface{}) {
|
|
if event.Type == clientv3.EventTypeDelete {
|
|
return
|
|
}
|
|
PlatformMgrSingleton.UpdateConfig(data)
|
|
}
|
|
|
|
func ExchangeShopList(completeKey string, isInit bool, event *clientv3.Event, data interface{}) {
|
|
if event.Type == clientv3.EventTypeDelete {
|
|
return
|
|
}
|
|
config, ok := data.(*webapi.ExchangeShopList)
|
|
if !ok {
|
|
logger.Logger.Errorf("etcd completeKey:%s, data type error", completeKey)
|
|
return
|
|
}
|
|
ShopMgrSington.UpExShop(config)
|
|
}
|