Documentation
¶
Index ¶
- Constants
- Variables
- func CheckModel(md IDataBaseModel) error
- func DBResolveModel(md IDataBaseModel) (result map[string]reflect.Value)
- func GetDBServer(dbsutil *dbsessionUtil, nttid uint64) (result uint64, reserr error)
- func GetKeyNameResolve(keyname string) (table string, uid uint64)
- func GetRowKeyName(data IDataBaseModel) string
- func GetRowKeyNameByPID(tname string) string
- func GetRowKeyNameByUID(tname string, uid uint64) string
- func NewEntityUtilDBData(pid uint64) (result *dbsessionUtil)
- func PackMsgData(v reflect.Value) (result []byte)
- func PostDBPlayer(pid, nttid uint64, reqMsg msgdef.IMsg)
- func SetDataModel(md IDataBaseModel, msgdata *protomsg.TableData)
- func SetDataModel2(md IDataBaseModel, msgdata *protomsg.TableData, args *DataArgs)
- func SetDataModel2ByMsg(md IDataBaseModel, msg *protomsg.DBDataModel, args *DataArgs)
- func SetDataModelByMsg(md IDataBaseModel, msg *protomsg.DBDataModel)
- func UnPackMsgDataToField(f reflect.Value, msgdata []byte)
- type DBPlayer
- func (this *DBPlayer) AddServiceModel(v IServiceModel)
- func (this *DBPlayer) AllDataSync()
- func (this *DBPlayer) AllDelayDataSync()
- func (this *DBPlayer) CheckLoaded() bool
- func (this *DBPlayer) DelayLoads()
- func (this *DBPlayer) GetIsPanic() bool
- func (this *DBPlayer) GetServiceModel(name string) (IServiceModel, bool)
- func (this *DBPlayer) Init(tmpli map[string]IDataBaseModel) (ok bool)
- func (this *DBPlayer) OnLoadedAll()
- func (this *DBPlayer) PopBackFunc(key uint64) GetData
- func (this *DBPlayer) Save()
- func (this *DBPlayer) SetBackFunc(key uint64, f GetData)
- func (this *DBPlayer) SetOnLoaded(f func())
- func (this *DBPlayer) SetPanic()
- type DataArgs
- func (args *DataArgs) Clear()
- func (args *DataArgs) Delete(md IDataBaseModel)
- func (args *DataArgs) GetDirtyData() map[string]IDataBaseModel
- func (args *DataArgs) GetIsDirty() bool
- func (args *DataArgs) GetModelByKeyName(keyname string) IDataBaseModel
- func (args *DataArgs) GetMsgByAllData(f func(v IDataBaseModel, db *protomsg.DBDataModel) (issync bool)) (result *protomsg.DBUpUserDatasReq)
- func (args *DataArgs) GetMsgByForFunc(f func(v IDataBaseModel, db *protomsg.DBDataModel) (issave bool)) (result *protomsg.DBUpUserDatasReq)
- func (args *DataArgs) GetPID() uint64
- func (args *DataArgs) GetRedisSave() (li map[string]IDataBaseModel, dbdatali []*protomsg.DBDataModel)
- func (args *DataArgs) LoadData(md IDataBaseModel)
- func (args *DataArgs) RevokeDelete(md IDataBaseModel)
- func (args *DataArgs) SetSaveF(f func())
- func (args *DataArgs) SetUpdate(md IDataBaseModel, k string, v interface{}) error
- func (args *DataArgs) String() string
- func (args *DataArgs) Update(md IDataBaseModel) error
- func (args *DataArgs) UpdateField(keyname, field string) error
- type DataUtil
- func (utilmd *DataUtil) DelDataArray(mli []*protomsg.DBDataModel)
- func (utilmd *DataUtil) DelDatas(tname string, keynames []string)
- func (utilmd *DataUtil) GetFieldKey(id uint64, modname string) (key string)
- func (utilmd *DataUtil) GetKeySplitToFieldName(key string) (id uint64, field string)
- func (utilmd *DataUtil) Key(tname string) string
- func (utilmd *DataUtil) RowsSingleDels(table string, uid uint64, li map[string]reflect.Value)
- func (utilmd *DataUtil) RowsSingleGet(table string) (result map[string][]byte, err error)
- func (utilmd *DataUtil) RowsSingleSet(table string, uid uint64, li map[string]reflect.Value) (err error)
- func (utilmd *DataUtil) SetDatas(pmsgs []*protomsg.DBDataModel) error
- type DelayLoadMgr
- type GetData
- type GetMsgForFunc
- type IDataBaseModel
- type IDeleted
- type IPlayer
- type IPlayerSubBase
- type IReal
- type IRedisValuer
- type IServiceModel
- type IServicePlayer
- type ISetArgs
- type ITable
- type MapModel
- func (this *MapModel) GetID() uint64
- func (this *MapModel) GetIsPartial() bool
- func (this *MapModel) GetPID() uint64
- func (this *MapModel) IsDeleted() bool
- func (this *MapModel) KeyName() string
- func (this *MapModel) Marshal() ([]byte, error)
- func (this *MapModel) RevokeDelete()
- func (this *MapModel) SetData(k string, v reflect.Value)
- func (this *MapModel) SetDelete()
- func (this *MapModel) SetID(id uint64)
- func (this *MapModel) SetPlayerID(v uint64)
- func (this *MapModel) TableName() string
- func (this *MapModel) Unmarshal(data []byte) error
- type ModuleBase
- func (this *ModuleBase) AllDataSyncClient()
- func (this *ModuleBase) DelRedisDatas(li map[string]IDataBaseModel, dbli []*protomsg.DBDataModel)
- func (this *ModuleBase) GetDataArgs() *DataArgs
- func (this *ModuleBase) GetIsLoaded() bool
- func (this *ModuleBase) GetLoadServerType() global.ServerTypeEnum
- func (this *ModuleBase) GetRedisTableDataAllDoMD(tnames []string) (result map[string][]IDataBaseModel, err error)
- func (this *ModuleBase) GetRedisTableDataDoMD(tname string) (result []IDataBaseModel, err error)
- func (this *ModuleBase) GetServiceName() string
- func (this *ModuleBase) GetTableNames() []string
- func (this *ModuleBase) InitLoaded()
- func (this *ModuleBase) IsSingleTable() (result bool, limit int32)
- func (this *ModuleBase) LoadDB(lis map[string][]IDataBaseModel)
- func (this *ModuleBase) LoadData(lis map[string][]IDataBaseModel)
- func (this *ModuleBase) OtherData(msg *protomsg.DBUpUserDatasReq)
- func (this *ModuleBase) SaveRedis(li map[string]IDataBaseModel, msg *protomsg.DBUpUserDatasReq)
- func (this *ModuleBase) SaveRedisDatas(li map[string]IDataBaseModel, dbli []*protomsg.DBDataModel)
- func (this *ModuleBase) SetRedisTableDataDoByte(data *MapModel)
- func (this *ModuleBase) SyncData()
- type NewTableFunc
- type OtherSrvMsgProc
- func (this *OtherSrvMsgProc) MsgProc_DBGetPlayerInfoAck(msg *protomsg.DBGetPlayerInfoAck)
- func (this *OtherSrvMsgProc) MsgProc_DBGetPlayerInfoEndAck(msg *protomsg.DBGetPlayerInfoEndAck)
- func (this *OtherSrvMsgProc) MsgProc_OtherGetPlayerInfoReq(msg *protomsg.OtherGetPlayerInfoReq)
- func (this *OtherSrvMsgProc) MsgProc_OtherUpUserDatasRet(msg *protomsg.OtherUpUserDatasRet)
- type PlayerBase
- type PropsDirtySave
- func (this *PropsDirtySave) FlagDirty(p props.IProp)
- func (this *PropsDirtySave) GetSorterType() props.EDPSorterType
- func (this *PropsDirtySave) HandlerAllList(consumeListFunc func(list []props.IProp) bool)
- func (this *PropsDirtySave) HandlerForEach(consumeFunc func(p props.IProp))
- func (this *PropsDirtySave) ListCount() int
- func (this *PropsDirtySave) PopDirtyList() (result []props.IProp)
- type TypeMgr
- func (mgr *TypeMgr) GetModelByKeyName(keyname string) IDataBaseModel
- func (mgr *TypeMgr) GetOtherTableList() map[string]ITable
- func (mgr *TypeMgr) GetTableList() map[string]NewTableFunc
- func (mgr *TypeMgr) GetTableNames() []string
- func (mgr *TypeMgr) GetTypeByTname(tname string) IDataBaseModel
- func (mgr TypeMgr) GetValueByTname(tname string) reflect.Value
- func (mgr *TypeMgr) RegisterOtherTable(md ITable)
- func (mgr *TypeMgr) RegisterType(f NewTableFunc)
- type ValueMD
Constants ¶
const DataList_Count = 50
一次收发消息的数据量
Variables ¶
var ( ErrPlayer = common.NewError(-1, " PlayerID == 0") // 玩家ID为0时的错误 ErrID = common.NewError(-1, " ID == 0") // ID为0时的错误 ErrPartial = common.NewError(-1, " SetUpdate fail GetIsPartial() fail") // 部分更新失败时的错误 ErrAllMD = common.NewError(-1, " SetUpdate fail is All data") // 全量更新失败时的错误 ErrNoData = common.NewError(-1, " Load redis no data") // 从Redis加载数据失败时的错误 ErrNoLoadData = common.NewError(-1, " Load data not exist.keyname:%s") // 缓存数据不存在时的错误 )
var (
Err_Player_Load = common.NewError(-1, "玩家数据加载失败 %s")
)
Functions ¶
func DBResolveModel ¶
func DBResolveModel(md IDataBaseModel) (result map[string]reflect.Value)
DBResolveModel 将数据模型分解为字段数据
func GetDBServer ¶
GetDBServer 获取玩家所在的DB服务器ID
func GetKeyNameResolve ¶
GetKeyNameResolve 解析键名,返回表名和用户ID
func GetRowKeyName ¶
func GetRowKeyName(data IDataBaseModel) string
GetRowKeyName 根据数据模型生成键名,支持单行和多行数据
func GetRowKeyNameByPID ¶
GetRowKeyNameByPID 根据表名生成单行数据的键名
func GetRowKeyNameByUID ¶
GetRowKeyNameByUID 根据表名和用户ID生成多行数据的键名
func NewEntityUtilDBData ¶
func NewEntityUtilDBData(pid uint64) (result *dbsessionUtil)
NewEntityUtilDBData 创建一个新的dbsessionUtil实例
func PostDBPlayer ¶
PostDBPlayer 发送消息到数据库服务器,支持重试机制
func SetDataModel ¶
func SetDataModel(md IDataBaseModel, msgdata *protomsg.TableData)
SetDataModel 设置数据到差量中去
func SetDataModel2 ¶
func SetDataModel2(md IDataBaseModel, msgdata *protomsg.TableData, args *DataArgs)
SetDataModel2 设置数据到差量中去,包含标脏
func SetDataModel2ByMsg ¶
func SetDataModel2ByMsg(md IDataBaseModel, msg *protomsg.DBDataModel, args *DataArgs)
SetDataModel2ByMsg 从消息中设置数据差量,包含标脏
func SetDataModelByMsg ¶
func SetDataModelByMsg(md IDataBaseModel, msg *protomsg.DBDataModel)
SetDataModelByMsg 从消息中设置数据差量
func UnPackMsgDataToField ¶
UnPackMsgDataToField 从消息中解包数据到字段
Types ¶
type DBPlayer ¶
type DBPlayer struct {
// 是否加载同步模块完成
IsLoadAllSync bool
// 是否加载所有模块
IsLoadAll bool
// 是否发生了异常
IsPanic bool
// 模块列表
ModelList map[string]IServiceModel
// 同步加载模块的加载顺序列表
SyncModelList []IServiceModel
// 延时加载的模块
DelayLoadLi map[global.ServerTypeEnum][]IServiceModel
// 需要保存的模块
DirtyModels []IServiceModel
// contains filtered or unexported fields
}
DBPlayer 是每个玩家身上的数据库管理对象,用于管理所有实现了 IServiceModel 接口的模块。
func NewDBPlayer ¶
func NewDBPlayer(player IServicePlayer, sid uint64, f func()) *DBPlayer
NewDBPlayer 创建一个新的 DBPlayer 实例
func (*DBPlayer) AddServiceModel ¶
func (this *DBPlayer) AddServiceModel(v IServiceModel)
AddServiceModel 添加服务模块,并按加载顺序进行管理
func (*DBPlayer) AllDelayDataSync ¶
func (this *DBPlayer) AllDelayDataSync()
AllDelayDataSync 同步延时加载的数据
func (*DBPlayer) GetServiceModel ¶
func (this *DBPlayer) GetServiceModel(name string) (IServiceModel, bool)
GetServiceModel 根据模块名称获取服务模块
func (*DBPlayer) Init ¶
func (this *DBPlayer) Init(tmpli map[string]IDataBaseModel) (ok bool)
Init 初始化加载数据,如果加载失败则走回调逻辑
func (*DBPlayer) PopBackFunc ¶
PopBackFunc 获取并移除回调函数
func (*DBPlayer) SetBackFunc ¶
SetBackFunc 设置回调函数
type DataArgs ¶
type DataArgs struct {
// contains filtered or unexported fields
}
DataArgs 用于管理数据更新和保存的上下文
func (*DataArgs) GetDirtyData ¶
func (args *DataArgs) GetDirtyData() map[string]IDataBaseModel
GetDirtyData 获取所有脏数据
func (*DataArgs) GetModelByKeyName ¶
func (args *DataArgs) GetModelByKeyName(keyname string) IDataBaseModel
GetModelByKeyName 使用Keyname获取数据对象
func (*DataArgs) GetMsgByAllData ¶
func (args *DataArgs) GetMsgByAllData(f func(v IDataBaseModel, db *protomsg.DBDataModel) (issync bool)) (result *protomsg.DBUpUserDatasReq)
GetMsgByAllData 获取全量更新数据包
func (*DataArgs) GetMsgByForFunc ¶
func (args *DataArgs) GetMsgByForFunc(f func(v IDataBaseModel, db *protomsg.DBDataModel) (issave bool)) (result *protomsg.DBUpUserDatasReq)
GetMsgByForFunc 返回发给DB服的消息,支持遍历时自定义处理函数
func (*DataArgs) GetRedisSave ¶
func (args *DataArgs) GetRedisSave() (li map[string]IDataBaseModel, dbdatali []*protomsg.DBDataModel)
GetRedisSave 获取需要保存到Redis的数据
func (*DataArgs) LoadData ¶
func (args *DataArgs) LoadData(md IDataBaseModel)
LoadData 加载需要支持差量更新的数据
func (*DataArgs) RevokeDelete ¶
func (args *DataArgs) RevokeDelete(md IDataBaseModel)
RevokeDelete 撤销删除操作
func (*DataArgs) SetUpdate ¶
func (args *DataArgs) SetUpdate(md IDataBaseModel, k string, v interface{}) error
SetUpdate 设置脏字段,进行部分Field更新
func (*DataArgs) UpdateField ¶
UpdateField 使用字段名更新数据
type DataUtil ¶
type DataUtil struct {
// contains filtered or unexported fields
}
DataUtil 用于管理玩家在Redis中的数据操作
func NewRedisUtilDBData ¶
NewRedisUtilDBData 创建一个新的DataUtil实例,用于管理指定玩家的Redis数据
func (*DataUtil) DelDataArray ¶
func (utilmd *DataUtil) DelDataArray(mli []*protomsg.DBDataModel)
DelDataArray 删除标记为需要删的数据行,根据DBDataModel列表删除Redis中的数据
func (*DataUtil) GetFieldKey ¶
GetFieldKey 获取字段Key,根据ID和字段名生成
func (*DataUtil) GetKeySplitToFieldName ¶
GetKeySplitToFieldName 获取字段名字和主键ID,将键名拆分为ID和字段名
func (*DataUtil) RowsSingleDels ¶
RowsSingleDels 删除多行数据,根据指定表和字段列表删除Redis中的数据
func (*DataUtil) RowsSingleGet ¶
RowsSingleGet 获取指定表的所有行数据,返回一个键值对的映射
type DelayLoadMgr ¶
type DelayLoadMgr struct {
IServiceModel
// contains filtered or unexported fields
}
DelayLoadMgr 是延时加载模块的管理器,负责处理延时加载的逻辑。
func (*DelayLoadMgr) DelayLoad ¶
func (this *DelayLoadMgr) DelayLoad(tmpli map[string]IDataBaseModel) bool
DelayLoad 处理数据库加载的回调,将加载的数据初始化并同步给客户端。 参数:
- tmpli: 从数据库加载的数据,按表名和模型分类。
返回值:
- bool: 始终返回 true,表示处理成功。
func (*DelayLoadMgr) SendDBLoadMsg ¶
func (this *DelayLoadMgr) SendDBLoadMsg(user *DBPlayer)
SendDBLoadMsg 发送数据库加载请求,根据是否单表加载选择不同的请求消息类型。 参数:
- user: 当前玩家对象,用于设置回调函数和发送消息。
type GetData ¶
type GetData func(tmpli map[string]IDataBaseModel) bool
GetData 定义了一个回调函数类型,用于处理从数据库获取的数据。
type GetMsgForFunc ¶
type GetMsgForFunc func(v IDataBaseModel, db *protomsg.DBDataModel) (issave bool)
用于ModuleBase在SyncData里对单个数据进行生成数据的回调函数 issave 为true表示需要保存在DB;
type IDataBaseModel ¶
type IDataBaseModel interface {
IDeleted
// KeyName 数据的唯一名字
KeyName() string
// GetPID 用户主键
GetPID() uint64
// TableName 拿到表名
TableName() string
// Marshal 序列化
Marshal() ([]byte, error)
// Unmarshal 反序列化
Unmarshal(data []byte) error
// GetIsPartial 是否支持部分更新
GetIsPartial() bool
}
IDataBaseModel 可以被DB管理器管理的类需要实现的接口
type IDeleted ¶
type IDeleted interface {
// IsDeleted 判断数据是否被删除
IsDeleted() bool
// SetDelete 标记数据为已删除
SetDelete()
// RevokeDelete 撤销删除
RevokeDelete()
}
IDeleted 支持数据删除操作的接口
type IPlayer ¶
type IPlayer interface {
GetDBID() uint64
// GetServiceModel 根据模块名称获取服务模块
GetServiceModel(name string) (IServiceModel, bool)
// SetBackFunc 设置回调函数
SetBackFunc(key uint64, f GetData)
// PopBackFunc 获取并移除回调函数
PopBackFunc(key uint64) GetData
}
IPlayer 定义了玩家接口,包含获取玩家ID、获取服务模块、设置回调函数等方法。
type IPlayerSubBase ¶
type IPlayerSubBase interface {
IDataBaseModel
// GetID 获取主键ID
GetID() uint64
// SetID 设置主键ID
SetID(id uint64)
}
IPlayerSubBase 支持一表多行的数据模型接口,每一行都会有一个自己的ID
type IReal ¶
type IReal interface {
IDataBaseModel
// GetMDReal 获取DB使用的真实数据模型
GetMDReal() IDataBaseModel
}
IReal 用于DBResolveModel分解字段时获取真实数据模型的接口
type IRedisValuer ¶
IRedisValuer 用于Redis保存数据的接口
type IServiceModel ¶
type IServiceModel interface {
// GetServiceName 返回系统模块的名称。
GetServiceName() string
// GetTableNames 返回系统模块需要的表名列表。
GetTableNames() []string
// GetLoadServerType 返回从哪个服务器类型加载数据,ServerTypeDefault 表示同步从DB加载,其他结果都是延迟从其他服加载。
GetLoadServerType() global.ServerTypeEnum
// GetDataArgs 返回脏数据收集器。
GetDataArgs() *DataArgs
// IsSingleTable 判断是否为单一表加载,并返回是否有Limit,如果没有限制,Limit为-1。
IsSingleTable() (result bool, limit int32)
// LoadDB 从DB获取数据,或从别的服获取数据后的加载方法。
LoadDB(lis map[string][]IDataBaseModel)
// LoadData 从Redis加载数据的方法。
LoadData(lis map[string][]IDataBaseModel)
// GetIsLoaded 返回系统模块是否已经加载过数据。
GetIsLoaded() bool
// OtherData 处理其他服务器同步过来的差量数据。
OtherData(msg *protomsg.DBUpUserDatasReq)
// InitLoaded 在LoadDB和LoadData成功后调用,用于填充数据后的初始化。
InitLoaded()
// SyncData 同步数据到客户端、Redis或DBServer。
SyncData()
// AllDataSyncClient 将全量数据同步到客户端。
AllDataSyncClient()
// GetRedisTableDataAllDoMD 从Redis获取指定表的所有数据。
GetRedisTableDataAllDoMD(tnames []string) (result map[string][]IDataBaseModel, err error)
}
IServiceModel 定义了系统模块需要实现的接口,用于管理模块的数据加载、同步、初始化等操作。
type IServicePlayer ¶
type IServicePlayer interface {
IPlayer
entity.IEntityReal
IServiceModel
// CallDelay 支持延迟回调。
CallDelay(f func())
// OnLoadedAll 在所有系统都加载完成后调用。
OnLoadedAll()
// RegMsgProc 注册消息处理函数。
RegMsgProc(interface{})
}
IServicePlayer 定义了服务器上的PlayerNtt对象需要实现的接口,继承自IPlayer、IEntityReal和IServiceModel。
type MapModel ¶
type MapModel struct {
Data map[string]reflect.Value
Table string
DeletedAt gorm.DeletedAt `gorm:"index"`
// contains filtered or unexported fields
}
MapModel 用于部分字段更新的数据模型
func NewMapModel ¶
NewMapModel 创建一个新的MapModel实例
type ModuleBase ¶
type ModuleBase struct {
User entity.IEntityReal //用户对象
Redisutil *DataUtil //redis操作
IsLoad bool //是否加载过
Args *DataArgs //标脏收集器
CallBreakFunc GetMsgForFunc //用于ModuleBase在SyncData里对单个数据进行生成数据的回调函数
IsSyncClient bool //是否差量同步给客户端
IsSyncSpace bool //是否同步给Space
IsSyncRedis bool //是否同步给Redis
IsLoadRedis bool //是否从Redis加载数据
LoadType global.ServerTypeEnum //从哪里加载数据
ServiceName string //服务器名字
}
ModuleBase 实现了IServiceModel接口的基类,用于管理模块的基础功能。
func NewModuleBase ¶
func NewModuleBase(user entity.IEntityReal, Sname string) *ModuleBase
NewModuleBase 创建一个新的ModuleBase实例
func (*ModuleBase) AllDataSyncClient ¶
func (this *ModuleBase) AllDataSyncClient()
AllDataSyncClient 将全量数据同步到客户端
func (*ModuleBase) DelRedisDatas ¶
func (this *ModuleBase) DelRedisDatas(li map[string]IDataBaseModel, dbli []*protomsg.DBDataModel)
DelRedisDatas 删redis里的数据
func (*ModuleBase) GetDataArgs ¶
func (this *ModuleBase) GetDataArgs() *DataArgs
GetDataArgs 返回脏数据收集器
func (*ModuleBase) GetIsLoaded ¶
func (this *ModuleBase) GetIsLoaded() bool
GetIsLoaded 返回系统模块是否已经加载过数据
func (*ModuleBase) GetLoadServerType ¶
func (this *ModuleBase) GetLoadServerType() global.ServerTypeEnum
GetLoadServerType 返回从哪个服务器类型加载数据,ServerTypeDefault 表示同步从DB加载,其他结果都是延迟从其他服加载
func (*ModuleBase) GetRedisTableDataAllDoMD ¶
func (this *ModuleBase) GetRedisTableDataAllDoMD(tnames []string) (result map[string][]IDataBaseModel, err error)
GetRedisTableDataAllDoMD 从Redis获取指定表的所有数据
func (*ModuleBase) GetRedisTableDataDoMD ¶
func (this *ModuleBase) GetRedisTableDataDoMD(tname string) (result []IDataBaseModel, err error)
GetRedisTableDataDoMD 从Redis中读数据,支持分字段的结构
func (*ModuleBase) GetServiceName ¶
func (this *ModuleBase) GetServiceName() string
GetServiceName 返回系统模块的名称
func (*ModuleBase) GetTableNames ¶
func (this *ModuleBase) GetTableNames() []string
GetTableNames 返回系统模块需要的表名列表
func (*ModuleBase) InitLoaded ¶
func (this *ModuleBase) InitLoaded()
InitLoaded 在LoadDB和LoadData成功后调用,用于填充数据后的初始化
func (*ModuleBase) IsSingleTable ¶
func (this *ModuleBase) IsSingleTable() (result bool, limit int32)
IsSingleTable 判断是否为单一表加载,并返回是否有Limit,如果没有限制,Limit为-1
func (*ModuleBase) LoadDB ¶
func (this *ModuleBase) LoadDB(lis map[string][]IDataBaseModel)
LoadDB 从DB获取数据,或从别的服获取数据后的加载方法
func (*ModuleBase) LoadData ¶
func (this *ModuleBase) LoadData(lis map[string][]IDataBaseModel)
LoadData 从Redis加载数据的方法
func (*ModuleBase) OtherData ¶
func (this *ModuleBase) OtherData(msg *protomsg.DBUpUserDatasReq)
OtherData 处理其他服务器同步过来的差量数据
func (*ModuleBase) SaveRedis ¶
func (this *ModuleBase) SaveRedis(li map[string]IDataBaseModel, msg *protomsg.DBUpUserDatasReq)
SaveRedis 保存数据到redis
func (*ModuleBase) SaveRedisDatas ¶
func (this *ModuleBase) SaveRedisDatas(li map[string]IDataBaseModel, dbli []*protomsg.DBDataModel)
SaveRedisDatas Update 数据到redis
func (*ModuleBase) SetRedisTableDataDoByte ¶
func (this *ModuleBase) SetRedisTableDataDoByte(data *MapModel)
SetRedisTableDataDoByte 写入redis,支持分字段的结构
type OtherSrvMsgProc ¶
type OtherSrvMsgProc struct {
// contains filtered or unexported fields
}
OtherSrvMsgProc 结构体用于处理从DB服务器发送到其他服务器的消息。
func NewOtherSrvMsgProc ¶
func NewOtherSrvMsgProc(pmd IPlayer) *OtherSrvMsgProc
NewOtherSrvMsgProc 创建一个新的OtherSrvMsgProc实例。 pmd: 玩家接口,用于与玩家相关的操作。
func (*OtherSrvMsgProc) MsgProc_DBGetPlayerInfoAck ¶
func (this *OtherSrvMsgProc) MsgProc_DBGetPlayerInfoAck(msg *protomsg.DBGetPlayerInfoAck)
MsgProc_DBGetPlayerInfoAck 处理从DB服务器发送的玩家信息确认消息。 msg: 包含玩家信息的消息。
func (*OtherSrvMsgProc) MsgProc_DBGetPlayerInfoEndAck ¶
func (this *OtherSrvMsgProc) MsgProc_DBGetPlayerInfoEndAck(msg *protomsg.DBGetPlayerInfoEndAck)
MsgProc_DBGetPlayerInfoEndAck 处理从DB服务器发送的玩家信息结束确认消息。 msg: 包含结束确认信息的消息。
func (*OtherSrvMsgProc) MsgProc_OtherGetPlayerInfoReq ¶
func (this *OtherSrvMsgProc) MsgProc_OtherGetPlayerInfoReq(msg *protomsg.OtherGetPlayerInfoReq)
MsgProc_OtherGetPlayerInfoReq 处理从其他服务器发送的获取玩家信息请求。 msg: 包含请求信息的消息。
func (*OtherSrvMsgProc) MsgProc_OtherUpUserDatasRet ¶
func (this *OtherSrvMsgProc) MsgProc_OtherUpUserDatasRet(msg *protomsg.OtherUpUserDatasRet)
MsgProc_OtherUpUserDatasRet 处理从其他服务器发送的用户数据更新返回消息。 msg: 包含更新返回信息的消息。
type PlayerBase ¶
type PlayerBase struct {
PID uint64 `gorm:"primarykey;column:pid"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
PlayerBase 一个角色一行数据的表基类
func (*PlayerBase) GetCreateAt ¶
func (this *PlayerBase) GetCreateAt() time.Time
func (*PlayerBase) GetPID ¶
func (this *PlayerBase) GetPID() uint64
func (*PlayerBase) IsDeleted ¶
func (this *PlayerBase) IsDeleted() bool
func (*PlayerBase) SetDelete ¶
func (this *PlayerBase) SetDelete()
type PropsDirtySave ¶
type PropsDirtySave struct {
// contains filtered or unexported fields
}
重新实现IPropsDirtySorter接口 支持DataArgs标脏的属性分流器
func NewPropsDirtySave ¶
func NewPropsDirtySave(model IDataBaseModel, args *DataArgs) *PropsDirtySave
初始化 支持DataArgs标脏的属性分流器
func (*PropsDirtySave) GetSorterType ¶
func (this *PropsDirtySave) GetSorterType() props.EDPSorterType
func (*PropsDirtySave) HandlerAllList ¶
func (this *PropsDirtySave) HandlerAllList(consumeListFunc func(list []props.IProp) bool)
列表获取回调
func (*PropsDirtySave) HandlerForEach ¶
func (this *PropsDirtySave) HandlerForEach(consumeFunc func(p props.IProp))
成员遍历回调
func (*PropsDirtySave) ListCount ¶
func (this *PropsDirtySave) ListCount() int
本来是返回有多少字段发生变化,这里只需要返回有变化为非0
func (*PropsDirtySave) PopDirtyList ¶
func (this *PropsDirtySave) PopDirtyList() (result []props.IProp)
弹出脏数据 这里需要注意,返回的切片与分流器里的是同一份数组,需要确保拿到这个切片后, 只做遍历,不做保留处理;
type TypeMgr ¶
type TypeMgr struct {
// contains filtered or unexported fields
}
TypeMgr 管理数据库表的类型和实例
func (*TypeMgr) GetModelByKeyName ¶
func (mgr *TypeMgr) GetModelByKeyName(keyname string) IDataBaseModel
GetModelByKeyName 根据键名获取对应的表实例
func (*TypeMgr) GetTableList ¶
func (mgr *TypeMgr) GetTableList() map[string]NewTableFunc
GetTableList 获取所有注册的表类型
func (*TypeMgr) GetTableNames ¶
GetTableNames 获取所有注册的表名
func (*TypeMgr) GetTypeByTname ¶
func (mgr *TypeMgr) GetTypeByTname(tname string) IDataBaseModel
GetTypeByTname 根据表名获取对应的表实例
func (TypeMgr) GetValueByTname ¶
GetValueByTname 根据表名获取对应的表实例的反射值
func (*TypeMgr) RegisterType ¶
func (mgr *TypeMgr) RegisterType(f NewTableFunc)
RegisterType 注册一个新的表类型
type ValueMD ¶
type ValueMD struct {
Model IDataBaseModel
// contains filtered or unexported fields
}
ValueMD 用于缓存数据模型及其反射值