dbmanager

package
v0.0.0-...-3e11984 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2025 License: BSD-4-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const DataList_Count = 50

一次收发消息的数据量

Variables

View Source
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")     // 缓存数据不存在时的错误
)
View Source
var (
	Err_Player_Load = common.NewError(-1, "玩家数据加载失败 %s")
)

Functions

func CheckModel

func CheckModel(md IDataBaseModel) error

CheckModel 检查数据模型的有效性

func DBResolveModel

func DBResolveModel(md IDataBaseModel) (result map[string]reflect.Value)

DBResolveModel 将数据模型分解为字段数据

func GetDBServer

func GetDBServer(dbsutil *dbsessionUtil, nttid uint64) (result uint64, reserr error)

GetDBServer 获取玩家所在的DB服务器ID

func GetKeyNameResolve

func GetKeyNameResolve(keyname string) (table string, uid uint64)

GetKeyNameResolve 解析键名,返回表名和用户ID

func GetRowKeyName

func GetRowKeyName(data IDataBaseModel) string

GetRowKeyName 根据数据模型生成键名,支持单行和多行数据

func GetRowKeyNameByPID

func GetRowKeyNameByPID(tname string) string

GetRowKeyNameByPID 根据表名生成单行数据的键名

func GetRowKeyNameByUID

func GetRowKeyNameByUID(tname string, uid uint64) string

GetRowKeyNameByUID 根据表名和用户ID生成多行数据的键名

func NewEntityUtilDBData

func NewEntityUtilDBData(pid uint64) (result *dbsessionUtil)

NewEntityUtilDBData 创建一个新的dbsessionUtil实例

func PackMsgData

func PackMsgData(v reflect.Value) (result []byte)

PackMsgData 打包字段数据

func PostDBPlayer

func PostDBPlayer(pid, nttid uint64, reqMsg msgdef.IMsg)

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

func UnPackMsgDataToField(f reflect.Value, msgdata []byte)

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) AllDataSync

func (this *DBPlayer) AllDataSync()

AllDataSync 同步所有数据给客户端

func (*DBPlayer) AllDelayDataSync

func (this *DBPlayer) AllDelayDataSync()

AllDelayDataSync 同步延时加载的数据

func (*DBPlayer) CheckLoaded

func (this *DBPlayer) CheckLoaded() bool

CheckLoaded 检查是否所有模块都已加载完成

func (*DBPlayer) DelayLoads

func (this *DBPlayer) DelayLoads()

DelayLoads 启动延时加载逻辑

func (*DBPlayer) GetIsPanic

func (this *DBPlayer) GetIsPanic() bool

GetIsPanic 获取是否处于异常状态

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) OnLoadedAll

func (this *DBPlayer) OnLoadedAll()

OnLoadedAll 所有系统加载完成后的调用

func (*DBPlayer) PopBackFunc

func (this *DBPlayer) PopBackFunc(key uint64) GetData

PopBackFunc 获取并移除回调函数

func (*DBPlayer) Save

func (this *DBPlayer) Save()

Save 保存脏数据到数据库

func (*DBPlayer) SetBackFunc

func (this *DBPlayer) SetBackFunc(key uint64, f GetData)

SetBackFunc 设置回调函数

func (*DBPlayer) SetOnLoaded

func (this *DBPlayer) SetOnLoaded(f func())

SetOnLoaded 设置加载完成后的回调函数

func (*DBPlayer) SetPanic

func (this *DBPlayer) SetPanic()

SetPanic 标记为异常状态

type DataArgs

type DataArgs struct {
	// contains filtered or unexported fields
}

DataArgs 用于管理数据更新和保存的上下文

func NewDataArgs

func NewDataArgs(pid uint64) *DataArgs

NewDataArgs 创建一个新的DataArgs实例

func (*DataArgs) Clear

func (args *DataArgs) Clear()

Clear 清空数据并重置状态

func (*DataArgs) Delete

func (args *DataArgs) Delete(md IDataBaseModel)

Delete 标记数据模型为已删除

func (*DataArgs) GetDirtyData

func (args *DataArgs) GetDirtyData() map[string]IDataBaseModel

GetDirtyData 获取所有脏数据

func (*DataArgs) GetIsDirty

func (args *DataArgs) GetIsDirty() bool

GetIsDirty 判断是否有脏数据

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) GetPID

func (args *DataArgs) GetPID() uint64

GetPID 获取玩家ID

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) SetSaveF

func (args *DataArgs) SetSaveF(f func())

SetSaveF 设置委托保存函数

func (*DataArgs) SetUpdate

func (args *DataArgs) SetUpdate(md IDataBaseModel, k string, v interface{}) error

SetUpdate 设置脏字段,进行部分Field更新

func (*DataArgs) String

func (args *DataArgs) String() string

String 返回DataArgs的字符串表示(当前为空)

func (*DataArgs) Update

func (args *DataArgs) Update(md IDataBaseModel) error

Update 全量更新数据模型

func (*DataArgs) UpdateField

func (args *DataArgs) UpdateField(keyname, field string) error

UpdateField 使用字段名更新数据

type DataUtil

type DataUtil struct {
	// contains filtered or unexported fields
}

DataUtil 用于管理玩家在Redis中的数据操作

func NewRedisUtilDBData

func NewRedisUtilDBData(pid uint64) (result *DataUtil)

NewRedisUtilDBData 创建一个新的DataUtil实例,用于管理指定玩家的Redis数据

func (*DataUtil) DelDataArray

func (utilmd *DataUtil) DelDataArray(mli []*protomsg.DBDataModel)

DelDataArray 删除标记为需要删的数据行,根据DBDataModel列表删除Redis中的数据

func (*DataUtil) DelDatas

func (utilmd *DataUtil) DelDatas(tname string, keynames []string)

DelDatas 删除指定表的一些行,根据表名和键名列表删除Redis中的数据

func (*DataUtil) GetFieldKey

func (utilmd *DataUtil) GetFieldKey(id uint64, modname string) (key string)

GetFieldKey 获取字段Key,根据ID和字段名生成

func (*DataUtil) GetKeySplitToFieldName

func (utilmd *DataUtil) GetKeySplitToFieldName(key string) (id uint64, field string)

GetKeySplitToFieldName 获取字段名字和主键ID,将键名拆分为ID和字段名

func (*DataUtil) Key

func (utilmd *DataUtil) Key(tname string) string

Key 获取Redis中的Key,根据玩家ID和表名生成

func (*DataUtil) RowsSingleDels

func (utilmd *DataUtil) RowsSingleDels(table string, uid uint64, li map[string]reflect.Value)

RowsSingleDels 删除多行数据,根据指定表和字段列表删除Redis中的数据

func (*DataUtil) RowsSingleGet

func (utilmd *DataUtil) RowsSingleGet(table string) (result map[string][]byte, err error)

RowsSingleGet 获取指定表的所有行数据,返回一个键值对的映射

func (*DataUtil) RowsSingleSet

func (utilmd *DataUtil) RowsSingleSet(table string, uid uint64, li map[string]reflect.Value) (err error)

RowsSingleSet 写入多行数据,将指定表的数据写入Redis

func (*DataUtil) SetDatas

func (utilmd *DataUtil) SetDatas(pmsgs []*protomsg.DBDataModel) error

SetDatas 批量设置行数据,将多个DBDataModel对象的数据批量写入Redis

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

type IRedisValuer interface {
	// RedisValue 返回Redis保存的数据
	RedisValue() (driver.Value, error)
}

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 ISetArgs

type ISetArgs interface {
	// SetArgs 设置标脏
	SetArgs(args msgdef.IArgs)
}

ISetArgs 支持设置标脏的接口

type ITable

type ITable interface {
	// KeyName 数据的唯一名字
	KeyName() string
	// TableName 拿到表名
	TableName() string
	// Marshal 序列化
	Marshal() ([]byte, error)
	// Unmarshal 反序列化
	Unmarshal(data []byte) error
}

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

func NewMapModel(keyname, table string) (result *MapModel)

NewMapModel 创建一个新的MapModel实例

func (*MapModel) GetID

func (this *MapModel) GetID() uint64

GetID 获取主键ID

func (*MapModel) GetIsPartial

func (this *MapModel) GetIsPartial() bool

GetIsPartial 判断是否支持部分更新

func (*MapModel) GetPID

func (this *MapModel) GetPID() uint64

GetPID 获取用户主键

func (*MapModel) IsDeleted

func (this *MapModel) IsDeleted() bool

IsDeleted 判断数据是否被删除

func (*MapModel) KeyName

func (this *MapModel) KeyName() string

KeyName 返回数据的唯一名字

func (*MapModel) Marshal

func (this *MapModel) Marshal() ([]byte, error)

Marshal 序列化数据

func (*MapModel) RevokeDelete

func (this *MapModel) RevokeDelete()

RevokeDelete 撤销删除标记

func (*MapModel) SetData

func (this *MapModel) SetData(k string, v reflect.Value)

SetData 设置字段数据

func (*MapModel) SetDelete

func (this *MapModel) SetDelete()

SetDelete 标记数据为已删除

func (*MapModel) SetID

func (this *MapModel) SetID(id uint64)

SetID 设置主键ID

func (*MapModel) SetPlayerID

func (this *MapModel) SetPlayerID(v uint64)

SetPlayerID 设置用户主键

func (*MapModel) TableName

func (this *MapModel) TableName() string

TableName 返回表名

func (*MapModel) Unmarshal

func (this *MapModel) Unmarshal(data []byte) error

Unmarshal 反序列化数据

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,支持分字段的结构

func (*ModuleBase) SyncData

func (this *ModuleBase) SyncData()

SyncData 同步数据到客户端、Redis或DBServer

type NewTableFunc

type NewTableFunc func() IDataBaseModel

NewTableFunc 定义了一个函数类型,用于创建新的数据库表实例

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) GetIsPartial

func (this *PlayerBase) GetIsPartial() bool

是否支持部分更新

func (*PlayerBase) GetPID

func (this *PlayerBase) GetPID() uint64

func (*PlayerBase) IsDeleted

func (this *PlayerBase) IsDeleted() bool

func (*PlayerBase) RevokeDelete

func (this *PlayerBase) RevokeDelete()

撤销删除

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) FlagDirty

func (this *PropsDirtySave) FlagDirty(p props.IProp)

标记脏数据

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 GetDBSingleton

func GetDBSingleton() *TypeMgr

GetDBSingleton 获取数据库管理器的单例实例

func (*TypeMgr) GetModelByKeyName

func (mgr *TypeMgr) GetModelByKeyName(keyname string) IDataBaseModel

GetModelByKeyName 根据键名获取对应的表实例

func (*TypeMgr) GetOtherTableList

func (mgr *TypeMgr) GetOtherTableList() map[string]ITable

其他所有表

func (*TypeMgr) GetTableList

func (mgr *TypeMgr) GetTableList() map[string]NewTableFunc

GetTableList 获取所有注册的表类型

func (*TypeMgr) GetTableNames

func (mgr *TypeMgr) GetTableNames() []string

GetTableNames 获取所有注册的表名

func (*TypeMgr) GetTypeByTname

func (mgr *TypeMgr) GetTypeByTname(tname string) IDataBaseModel

GetTypeByTname 根据表名获取对应的表实例

func (TypeMgr) GetValueByTname

func (mgr TypeMgr) GetValueByTname(tname string) reflect.Value

GetValueByTname 根据表名获取对应的表实例的反射值

func (*TypeMgr) RegisterOtherTable

func (mgr *TypeMgr) RegisterOtherTable(md ITable)

注册其他表

func (*TypeMgr) RegisterType

func (mgr *TypeMgr) RegisterType(f NewTableFunc)

RegisterType 注册一个新的表类型

type ValueMD

type ValueMD struct {
	Model IDataBaseModel
	// contains filtered or unexported fields
}

ValueMD 用于缓存数据模型及其反射值

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL