45 lines
1.2 KiB
Go
45 lines
1.2 KiB
Go
package com
|
|
|
|
import (
|
|
"context"
|
|
|
|
"go.etcd.io/etcd/client/v3"
|
|
|
|
"mongo.games.com/game/etcd"
|
|
"mongo.games.com/game/model"
|
|
"mongo.games.com/game/protocol/webapi"
|
|
)
|
|
|
|
var ConfigMgrInst = model.NewConfigMgr()
|
|
|
|
func init() {
|
|
// 平台信息
|
|
etcd.Register(etcd.ETCDKEY_PLATFORM_PREFIX, webapi.Platform{}, PlatformConfigEtcd)
|
|
// 竞技馆房间配置
|
|
etcd.Register(etcd.ETCDKEY_RoomConfig, webapi.RoomConfig{}, PlatformConfigEtcd)
|
|
}
|
|
|
|
func PlatformConfigEtcd(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{}) {
|
|
if event.Type == clientv3.EventTypeDelete {
|
|
return
|
|
}
|
|
switch config := data.(type) {
|
|
case *webapi.Platform:
|
|
PlatformConfigSingleton.Update(config)
|
|
case *webapi.RoomConfig:
|
|
ConfigMgrInst.UpdateRoomConfig(config)
|
|
}
|
|
}
|
|
|
|
//func etcdHandler(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{}) {
|
|
// switch config := data.(type) {
|
|
// case *webapi.ShowLottery:
|
|
// switch event.Type {
|
|
// case clientv3.EventTypePut:
|
|
// ConfigMgrInst.GetConfig(config.Platform).LotteryShows[config.GetId()] = config
|
|
// case clientv3.EventTypeDelete:
|
|
// delete(ConfigMgrInst.GetConfig(config.Platform).LotteryShows, config.GetId())
|
|
// }
|
|
// }
|
|
//}
|