46 lines
1.3 KiB
Go
46 lines
1.3 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{}, func(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)
|
|
})
|
|
// 商城商品
|
|
etcd.Register(etcd.ETCDKEY_SHOP_ITEM, webapi.ItemShopList{}, func(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)
|
|
}
|