Documentation
¶
Index ¶
- Constants
- Variables
- func PackProps(e *PropDirtyMgr, packType uint8) (result []*protomsg.SyncProp)
- func PackPropsToProtobuf(props []IProp) (result []*protomsg.SyncProp)
- type Def
- type EDPSorterType
- type FieldDef
- type IDef
- type IProp
- type IProps
- type IPropsDirtySorter
- type PropDirtyMgr
- func (e *PropDirtyMgr) AddSorter(sorterType EDPSorterType)
- func (e *PropDirtyMgr) DelSorter(sorterType EDPSorterType)
- func (this *PropDirtyMgr) ForEachProp(callBack func(p IProp))
- func (e *PropDirtyMgr) GetDirtyPropSorter(sorterType EDPSorterType) IPropsDirtySorter
- func (this *PropDirtyMgr) GetProp(index uint32) interface{}
- func (this *PropDirtyMgr) GetPropRaw(index uint32) IProp
- func (this *PropDirtyMgr) GetPropRawByName(name string) IProp
- func (e *PropDirtyMgr) HandlerSorterResult(sorterType EDPSorterType, consumeFunc func([]IProp) bool) bool
- func (e *PropDirtyMgr) HandlerSorterResultForeach(sorterType EDPSorterType, consumeFunc func(p IProp)) bool
- func (this *PropDirtyMgr) InitProp(def *Def)
- func (this *PropDirtyMgr) IsDirty(index uint32, dType EDPSorterType) bool
- func (this *PropDirtyMgr) PropDirty(index uint32)
- func (this *PropDirtyMgr) PropDirty2(index uint32, dType EDPSorterType)
- func (this *PropDirtyMgr) SetProp(index uint32, value interface{})
- func (e *PropDirtyMgr) SetSorter(stype EDPSorterType, sorternew IPropsDirtySorter)
- func (this *PropDirtyMgr) SetSrvType(srvType uint32)
- func (this *PropDirtyMgr) SetSubType(subType string)
- func (this *PropDirtyMgr) TryGetProp(index uint32) (interface{}, error)
- type PropInfo
- func (this *PropInfo[T]) GetField() *FieldDef
- func (this *PropInfo[T]) GetIndex() uint32
- func (this *PropInfo[T]) GetName() string
- func (this *PropInfo[T]) GetValue() interface{}
- func (this *PropInfo[T]) GetValueT() T
- func (this *PropInfo[T]) IsDirty(dType EDPSorterType) bool
- func (this *PropInfo[T]) IsSaveDirty() bool
- func (this *PropInfo[T]) IsSyncDirty() bool
- func (this *PropInfo[T]) LoadValue(v interface{})
- func (this *PropInfo[T]) LoadValueT(v T)
- func (this *PropInfo[T]) ReadSyncProp(msg *protomsg.SyncProp)
- func (this *PropInfo[T]) SetDirty()
- func (this *PropInfo[T]) SetDirty2(dType EDPSorterType)
- func (this *PropInfo[T]) SetValue(v interface{})
- func (this *PropInfo[T]) SetValueT(v T)
- type PropsDirtySorter
- func (this *PropsDirtySorter) FlagDirty(p IProp)
- func (this *PropsDirtySorter) GetSorterType() EDPSorterType
- func (this *PropsDirtySorter) HandlerAllList(consumeListFunc func(list []IProp) bool)
- func (this *PropsDirtySorter) HandlerForEach(consumeFunc func(p IProp))
- func (this *PropsDirtySorter) ListCount() int
- func (this *PropsDirtySorter) PopDirtyList() (result []IProp)
- type PropsSyncContainer
- func (this *PropsSyncContainer) ForEachSrvDirty(f func(uint32, []IProp))
- func (c *PropsSyncContainer) GetDirtyAOIMsg() []*protomsg.SyncProp
- func (c *PropsSyncContainer) GetDirtyMRoleMsg() []*protomsg.SyncProp
- func (this *PropsSyncContainer) PackMRloeProps() []*protomsg.SyncProp
- func (c *PropsSyncContainer) PackPropsSyncProps()
- func (c *PropsSyncContainer) ProsSyncInit()
- func (this *PropsSyncContainer) ReadSyncProps(li []*protomsg.SyncProp)
Constants ¶
View Source
const ( PackProp_Role uint8 = 1 PackProp_AOI uint8 = 2 )
Variables ¶
View Source
var ( ErrDef_FileNotFound = common.NewError(-1, "read entity def file error") ErrDef_JsonUnmarshal = common.NewError(-1, "read entity def json unmarshal error") ErrDef_Fill = common.NewError(-1, "read entity def fill error") //属性不存在 ErrProp_NotExist = errors.New("prop index not exist") )
Functions ¶
func PackProps ¶
func PackProps(e *PropDirtyMgr, packType uint8) (result []*protomsg.SyncProp)
PackProps 打包属性
func PackPropsToProtobuf ¶
PackPropsToProtobuf 把属列表打包成proto
Types ¶
type Def ¶
type Def struct {
Name string //主类型名字
FieldsByID map[uint32]*FieldDef //key是Index的字段map
FieldsByName map[string]*FieldDef //key是Name的字段map
}
Def 独立的实体定义
type EDPSorterType ¶
type EDPSorterType int8
分流器类型
const ( //同步分流器 EDPSorterTypeSync EDPSorterType = 1 //保存分流器 EDPSorterTypeSave EDPSorterType = 2 )
type FieldDef ¶
type FieldDef struct {
Name string //字段名字
Index uint32 //字段的唯一ID
Desc string //字段说明
TypeName string //类型名字
SubTypes map[string]struct{} //哪些子类型有这个字段
WatchSrvs []uint32 //关心的服务器类型
IsClient bool //是否其他客户端需要
IsMRole bool //是否自己客户端需要
SaveSrv uint32 //做数据落地的服务器类型
MainSrv uint32 // 主管理的服务器类型
IsSync bool //当这个字段值发生变化时,是否需要同步给别的服务器
RefType reflect.Type //实例类型
}
单个字段
type IProp ¶
type IProp interface {
// 获取字段Index
GetIndex() uint32
// 获取字段名字
GetName() string
GetField() *FieldDef
// 设置属性值(标脏)
SetValue(v interface{})
// 设置属性值(不标脏)
LoadValue(v interface{})
// 获取属性值
GetValue() interface{}
// 是否同步脏数据
IsSyncDirty() bool
// 是否保存脏数据
IsSaveDirty() bool
// 是否标脏了
IsDirty(dType EDPSorterType) bool
// 设置标脏
SetDirty()
// 设置指定分流器标脏
SetDirty2(dType EDPSorterType)
// 从同步消息里读数据
ReadSyncProp(msg *protomsg.SyncProp)
// contains filtered or unexported methods
}
单个属性更新器
type IProps ¶
type IProps interface {
SetProp(index uint32, value interface{})
PropDirty(index uint32)
IsDirty(index uint32, dType EDPSorterType) bool
PropDirty2(index uint32, dType EDPSorterType)
GetProp(index uint32) interface{}
//尝试获取属性,如果没有拿到就返回错误
TryGetProp(index uint32) (interface{}, error)
GetPropRawByName(name string) IProp
GetPropRaw(index uint32) IProp
// 从同步消息中获取数据
ReadSyncProps(li []*protomsg.SyncProp)
}
IProps Entity属性相关的操作
type IPropsDirtySorter ¶
type IPropsDirtySorter interface {
// 标记脏数据
FlagDirty(p IProp)
//分流器类型
GetSorterType() EDPSorterType
// 列表获取回调
HandlerAllList(consumeListFunc func(list []IProp) bool)
// 成员遍历回调
HandlerForEach(consumeFunc func(p IProp))
//获取脏数据
ListCount() int
//弹出所有脏数据
PopDirtyList() (result []IProp)
}
分流器接口
type PropDirtyMgr ¶
type PropDirtyMgr struct {
PropList map[uint32]IProp //所有字段按ID查
PropByName map[string]IProp //所有字段按名字查
// contains filtered or unexported fields
}
属性管理器 可以管理属性的脏字段
func NewPropDirtyMgr ¶
func NewPropDirtyMgr() (result *PropDirtyMgr)
func (*PropDirtyMgr) ForEachProp ¶
func (this *PropDirtyMgr) ForEachProp(callBack func(p IProp))
func (*PropDirtyMgr) GetDirtyPropSorter ¶
func (e *PropDirtyMgr) GetDirtyPropSorter(sorterType EDPSorterType) IPropsDirtySorter
////////////////////////////// 属性脏分流器操作
func (*PropDirtyMgr) GetProp ¶
func (this *PropDirtyMgr) GetProp(index uint32) interface{}
func (*PropDirtyMgr) GetPropRaw ¶
func (this *PropDirtyMgr) GetPropRaw(index uint32) IProp
func (*PropDirtyMgr) GetPropRawByName ¶
func (this *PropDirtyMgr) GetPropRawByName(name string) IProp
func (*PropDirtyMgr) HandlerSorterResult ¶
func (e *PropDirtyMgr) HandlerSorterResult(sorterType EDPSorterType, consumeFunc func([]IProp) bool) bool
按类型获取脏数据列表回调
func (*PropDirtyMgr) HandlerSorterResultForeach ¶
func (e *PropDirtyMgr) HandlerSorterResultForeach(sorterType EDPSorterType, consumeFunc func(p IProp)) bool
按类型遍历脏数据
func (*PropDirtyMgr) InitProp ¶
func (this *PropDirtyMgr) InitProp(def *Def)
func (*PropDirtyMgr) IsDirty ¶
func (this *PropDirtyMgr) IsDirty(index uint32, dType EDPSorterType) bool
func (*PropDirtyMgr) PropDirty ¶
func (this *PropDirtyMgr) PropDirty(index uint32)
func (*PropDirtyMgr) PropDirty2 ¶
func (this *PropDirtyMgr) PropDirty2(index uint32, dType EDPSorterType)
func (*PropDirtyMgr) SetProp ¶
func (this *PropDirtyMgr) SetProp(index uint32, value interface{})
func (*PropDirtyMgr) SetSorter ¶
func (e *PropDirtyMgr) SetSorter(stype EDPSorterType, sorternew IPropsDirtySorter)
设置或替换分流器
func (*PropDirtyMgr) TryGetProp ¶
func (this *PropDirtyMgr) TryGetProp(index uint32) (interface{}, error)
尝试获取属性,如果没有拿到就返回错误
type PropInfo ¶
type PropInfo[T any] struct { // contains filtered or unexported fields }
单个属性更新器
func NewProp ¶
func NewProp[T any](pmgr *PropDirtyMgr, index uint32) (result *PropInfo[T])
新建属性到管理器中
func (*PropInfo[T]) ReadSyncProp ¶
从同步消息里读数据
type PropsDirtySorter ¶
type PropsDirtySorter struct {
// contains filtered or unexported fields
}
func NewPropsDirtySorter ¶
func NewPropsDirtySorter(sorter EDPSorterType) *PropsDirtySorter
func (*PropsDirtySorter) GetSorterType ¶
func (this *PropsDirtySorter) GetSorterType() EDPSorterType
func (*PropsDirtySorter) HandlerAllList ¶
func (this *PropsDirtySorter) HandlerAllList(consumeListFunc func(list []IProp) bool)
列表获取回调
func (*PropsDirtySorter) HandlerForEach ¶
func (this *PropsDirtySorter) HandlerForEach(consumeFunc func(p IProp))
成员遍历回调
func (*PropsDirtySorter) ListCount ¶
func (this *PropsDirtySorter) ListCount() int
func (*PropsDirtySorter) PopDirtyList ¶
func (this *PropsDirtySorter) PopDirtyList() (result []IProp)
弹出脏数据 这里需要注意,返回的切片与分流器里的是同一份数组,需要确保拿到这个切片后, 只做遍历,不做保留处理;
type PropsSyncContainer ¶
type PropsSyncContainer struct {
*PropDirtyMgr
//需要同步给其他服务器的数据
DirtySrvProps map[uint32][]IProp
DirtyAOIMsg []*protomsg.SyncProp
DirtyMRoleMsg []*protomsg.SyncProp
}
PropsSyncContainer 需要进行属性同步的部分
func NewPropsSyncContainer ¶
func NewPropsSyncContainer() *PropsSyncContainer
func (*PropsSyncContainer) ForEachSrvDirty ¶
func (this *PropsSyncContainer) ForEachSrvDirty(f func(uint32, []IProp))
遍历服务器脏数据,会清空脏数据
func (*PropsSyncContainer) GetDirtyAOIMsg ¶
func (c *PropsSyncContainer) GetDirtyAOIMsg() []*protomsg.SyncProp
获取AOI需要的差量属性更新
func (*PropsSyncContainer) GetDirtyMRoleMsg ¶
func (c *PropsSyncContainer) GetDirtyMRoleMsg() []*protomsg.SyncProp
获取自身需要的差量属性更新
func (*PropsSyncContainer) PackMRloeProps ¶
func (this *PropsSyncContainer) PackMRloeProps() []*protomsg.SyncProp
打包主客户端关心的属性
func (*PropsSyncContainer) PackPropsSyncProps ¶
func (c *PropsSyncContainer) PackPropsSyncProps()
打包同步数据:给自己的,给AOI的,给其他服务器的
func (*PropsSyncContainer) ReadSyncProps ¶
func (this *PropsSyncContainer) ReadSyncProps(li []*protomsg.SyncProp)
从同步消息中获取数据
Click to show internal directories.
Click to hide internal directories.