Documentation ¶
Index ¶
- Constants
- Variables
- func ReleaseRankData(rankData *RankData)
- type DefaultRankModule
- func (dr *DefaultRankModule) OnChangeRankData(rankSkip IRankSkip, changeData []*RankData)
- func (dr *DefaultRankModule) OnEnterRank(rankSkip IRankSkip, enterData []*RankData)
- func (dr *DefaultRankModule) OnLeaveRank(rankSkip IRankSkip, leaveData []*RankData)
- func (dr *DefaultRankModule) OnStart(mapRankSkip map[uint64]*RankSkip) error
- func (dr *DefaultRankModule) OnStop(mapRankSkip map[uint64]*RankSkip)
- type ExpireData
- type IRankModule
- type IRankSkip
- type MongoPersist
- func (mp *MongoPersist) JudgeTimeoutSave() bool
- func (mp *MongoPersist) OnChangeRankData(rankSkip IRankSkip, changeData *RankData)
- func (mp *MongoPersist) OnEnterRank(rankSkip IRankSkip, enterData *RankData)
- func (mp *MongoPersist) OnInit() error
- func (mp *MongoPersist) OnLeaveRank(rankSkip IRankSkip, leaveData *RankData)
- func (mp *MongoPersist) OnSetupRank(manual bool, rankSkip *RankSkip) error
- func (mp *MongoPersist) OnStart()
- func (mp *MongoPersist) OnStop(mapRankSkip map[uint64]*RankSkip)
- func (mp *MongoPersist) ReadCfg() error
- type RankData
- type RankDataChangeType
- type RankDataDB
- type RankService
- func (rs *RankService) OnInit() error
- func (rs *RankService) OnRelease()
- func (rs *RankService) OnStart()
- func (rs *RankService) RPC_DeleteRankDataByKey(delInfo *rpc.DeleteByKey, delResult *rpc.RankResult) error
- func (rs *RankService) RPC_FindRankDataByKey(findInfo *rpc.FindRankDataByKey, findResult *rpc.RankPosData) error
- func (rs *RankService) RPC_FindRankDataByRank(findInfo *rpc.FindRankDataByRank, findResult *rpc.RankPosData) error
- func (rs *RankService) RPC_FindRankDataList(findInfo *rpc.FindRankDataList, findResult *rpc.RankDataList) error
- func (rs *RankService) RPC_IncreaseRankData(changeRankData *rpc.IncreaseRankData, ...) error
- func (rs *RankService) RPC_ManualAddRankSkip(addInfo *rpc.AddRankList, addResult *rpc.RankResult) error
- func (rs *RankService) RPC_UpdateRankData(updateRankData *rpc.UpdateRankData, updateRankDataRet *rpc.UpdateRankDataRet) error
- func (rs *RankService) RPC_UpsetRank(upsetInfo *rpc.UpsetRankData, upsetResult *rpc.RankResult) error
- func (rs *RankService) SetupRankModule(rankModule IRankModule)
- type RankSkip
- func (rs *RankSkip) ChangeExtendData(changeRankData *rpc.IncreaseRankData) bool
- func (rs *RankSkip) DeleteRankData(delKeys []uint64) int32
- func (rs *RankSkip) GetRankDataFromToLimit(startPos, count uint64, result *rpc.RankDataList) error
- func (rs *RankSkip) GetRankID() uint64
- func (rs *RankSkip) GetRankKeyNextToLimit(findKey, count uint64, result *rpc.RankDataList) error
- func (rs *RankSkip) GetRankKeyPrevToLimit(findKey, count uint64, result *rpc.RankDataList) error
- func (rs *RankSkip) GetRankLen() uint64
- func (rs *RankSkip) GetRankName() string
- func (rs *RankSkip) GetRankNodeData(findKey uint64) (*RankData, uint64)
- func (rs *RankSkip) GetRankNodeDataByRank(rank uint64) (*RankData, uint64)
- func (rs *RankSkip) InsertDataOnNonExistent(changeRankData *rpc.IncreaseRankData) bool
- func (rs *RankSkip) SetupRankModule(rankModule IRankModule)
- func (rs *RankSkip) UpdateRankData(updateRankData *rpc.UpdateRankData) bool
- func (rs *RankSkip) UpsetRank(upsetData *rpc.RankData, refreshTimestamp int64, fromLoad bool) RankDataChangeType
- func (rs *RankSkip) UpsetRankList(upsetRankData []*rpc.RankData) (addCount int32, modifyCount int32)
Constants ¶
View Source
const MaxPickExpireNum = 128
View Source
const PreMapRankSkipLen = 10
Variables ¶
Functions ¶
func ReleaseRankData ¶
func ReleaseRankData(rankData *RankData)
Types ¶
type DefaultRankModule ¶
func (*DefaultRankModule) OnChangeRankData ¶
func (dr *DefaultRankModule) OnChangeRankData(rankSkip IRankSkip, changeData []*RankData)
func (*DefaultRankModule) OnEnterRank ¶
func (dr *DefaultRankModule) OnEnterRank(rankSkip IRankSkip, enterData []*RankData)
func (*DefaultRankModule) OnLeaveRank ¶
func (dr *DefaultRankModule) OnLeaveRank(rankSkip IRankSkip, leaveData []*RankData)
func (*DefaultRankModule) OnStart ¶
func (dr *DefaultRankModule) OnStart(mapRankSkip map[uint64]*RankSkip) error
func (*DefaultRankModule) OnStop ¶
func (dr *DefaultRankModule) OnStop(mapRankSkip map[uint64]*RankSkip)
type ExpireData ¶
type ExpireData struct { Index int Key uint64 RefreshTimestamp int64 // contains filtered or unexported fields }
func (*ExpireData) IsRef ¶
func (ed *ExpireData) IsRef() bool
func (*ExpireData) Ref ¶
func (ed *ExpireData) Ref()
func (*ExpireData) Reset ¶
func (ed *ExpireData) Reset()
func (*ExpireData) UnRef ¶
func (ed *ExpireData) UnRef()
type IRankModule ¶
type IRankModule interface { service.IModule OnSetupRank(manual bool, rankSkip *RankSkip) error //当完成安装排行榜对象时 OnStart() //服务开启时回调 OnEnterRank(rankSkip IRankSkip, enterData *RankData) //进入排行 OnLeaveRank(rankSkip IRankSkip, leaveData *RankData) //离开排行 OnChangeRankData(rankSkip IRankSkip, changeData *RankData) //当排行数据变化时 OnStop(mapRankSkip map[uint64]*RankSkip) //服务结束时回调 }
type MongoPersist ¶
type MongoPersist struct { service.Module SaveInterval time.Duration //落地数据库时间间隔 sync.Mutex // contains filtered or unexported fields }
MongoPersist 持久化Module
func (*MongoPersist) JudgeTimeoutSave ¶
func (mp *MongoPersist) JudgeTimeoutSave() bool
func (*MongoPersist) OnChangeRankData ¶
func (mp *MongoPersist) OnChangeRankData(rankSkip IRankSkip, changeData *RankData)
func (*MongoPersist) OnEnterRank ¶
func (mp *MongoPersist) OnEnterRank(rankSkip IRankSkip, enterData *RankData)
func (*MongoPersist) OnInit ¶
func (mp *MongoPersist) OnInit() error
func (*MongoPersist) OnLeaveRank ¶
func (mp *MongoPersist) OnLeaveRank(rankSkip IRankSkip, leaveData *RankData)
func (*MongoPersist) OnSetupRank ¶
func (mp *MongoPersist) OnSetupRank(manual bool, rankSkip *RankSkip) error
func (*MongoPersist) OnStop ¶
func (mp *MongoPersist) OnStop(mapRankSkip map[uint64]*RankSkip)
OnStop 停存持久化到DB
func (*MongoPersist) ReadCfg ¶
func (mp *MongoPersist) ReadCfg() error
type RankData ¶
type RankData struct { Key uint64 SortData []int64 Data []byte ExData []int64 RefreshTimestamp int64 //刷新时间 // contains filtered or unexported fields }
func NewRankData ¶
type RankDataChangeType ¶
type RankDataChangeType int8
const ( RankDataNone RankDataChangeType = 0 RankDataAdd RankDataChangeType = 1 //数据插入 RankDataUpdate RankDataChangeType = 2 //数据更新 RankDataDelete RankDataChangeType = 3 //数据删除 )
type RankDataDB ¶
type RankDataDB struct { Id uint64 `bson:"_id"` RefreshTime int64 `bson:"RefreshTime"` SortData []int64 `bson:"SortData"` Data []byte `bson:"Data"` ExData []int64 `bson:"ExData"` }
RankDataDB 排行表数据
type RankService ¶
func (*RankService) OnInit ¶
func (rs *RankService) OnInit() error
func (*RankService) OnRelease ¶
func (rs *RankService) OnRelease()
func (*RankService) OnStart ¶
func (rs *RankService) OnStart()
func (*RankService) RPC_DeleteRankDataByKey ¶
func (rs *RankService) RPC_DeleteRankDataByKey(delInfo *rpc.DeleteByKey, delResult *rpc.RankResult) error
RPC_DeleteRankDataByKey 按key从排行榜中进行删除
func (*RankService) RPC_FindRankDataByKey ¶
func (rs *RankService) RPC_FindRankDataByKey(findInfo *rpc.FindRankDataByKey, findResult *rpc.RankPosData) error
RPC_FindRankDataByKey 按key查找,返回对应的排行名次信息
func (*RankService) RPC_FindRankDataByRank ¶
func (rs *RankService) RPC_FindRankDataByRank(findInfo *rpc.FindRankDataByRank, findResult *rpc.RankPosData) error
RPC_FindRankDataByRank 按pos查找
func (*RankService) RPC_FindRankDataList ¶
func (rs *RankService) RPC_FindRankDataList(findInfo *rpc.FindRankDataList, findResult *rpc.RankDataList) error
RPC_FindRankDataList 按StartRank查找,从StartRank开始count个排行数据
func (*RankService) RPC_IncreaseRankData ¶
func (rs *RankService) RPC_IncreaseRankData(changeRankData *rpc.IncreaseRankData, changeRankDataRet *rpc.IncreaseRankDataRet) error
RPC_IncreaseRankData 增量更新排行扩展数据
func (*RankService) RPC_ManualAddRankSkip ¶
func (rs *RankService) RPC_ManualAddRankSkip(addInfo *rpc.AddRankList, addResult *rpc.RankResult) error
RPC_ManualAddRankSkip 提供手动添加排行榜
func (*RankService) RPC_UpdateRankData ¶
func (rs *RankService) RPC_UpdateRankData(updateRankData *rpc.UpdateRankData, updateRankDataRet *rpc.UpdateRankDataRet) error
RPC_UpsetRank 更新排行榜
func (*RankService) RPC_UpsetRank ¶
func (rs *RankService) RPC_UpsetRank(upsetInfo *rpc.UpsetRankData, upsetResult *rpc.RankResult) error
RPC_UpsetRank 更新排行榜
func (*RankService) SetupRankModule ¶
func (rs *RankService) SetupRankModule(rankModule IRankModule)
SetupRankModule 安装排行模块
type RankSkip ¶
type RankSkip struct {
// contains filtered or unexported fields
}
func NewRankSkip ¶
func NewRankSkip(rankId uint64, rankName string, isDes bool, level interface{}, maxLen uint64, expireMs time.Duration) *RankSkip
NewRankSkip 创建排行榜
func (*RankSkip) ChangeExtendData ¶
func (rs *RankSkip) ChangeExtendData(changeRankData *rpc.IncreaseRankData) bool
func (*RankSkip) DeleteRankData ¶
DeleteRankData 删除排行数据
func (*RankSkip) GetRankDataFromToLimit ¶
func (rs *RankSkip) GetRankDataFromToLimit(startPos, count uint64, result *rpc.RankDataList) error
GetRankDataFromToLimit 获取排行榜数据,startPos开始的count个数据
func (*RankSkip) GetRankKeyNextToLimit ¶
func (rs *RankSkip) GetRankKeyNextToLimit(findKey, count uint64, result *rpc.RankDataList) error
GetRankKeyNextToLimit 获取key前count名的数据
func (*RankSkip) GetRankKeyPrevToLimit ¶
func (rs *RankSkip) GetRankKeyPrevToLimit(findKey, count uint64, result *rpc.RankDataList) error
GetRankKeyPrevToLimit 获取key前count名的数据
func (*RankSkip) GetRankNodeData ¶
GetRankNodeData 获取,返回排名节点与名次
func (*RankSkip) GetRankNodeDataByRank ¶
GetRankNodeDataByRank 获取,返回排名节点与名次
func (*RankSkip) InsertDataOnNonExistent ¶
func (rs *RankSkip) InsertDataOnNonExistent(changeRankData *rpc.IncreaseRankData) bool
func (*RankSkip) SetupRankModule ¶
func (rs *RankSkip) SetupRankModule(rankModule IRankModule)
func (*RankSkip) UpdateRankData ¶
func (rs *RankSkip) UpdateRankData(updateRankData *rpc.UpdateRankData) bool
Click to show internal directories.
Click to hide internal directories.