33 lines
780 B
Go
33 lines
780 B
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)
|
|
}
|
|
}
|