rankservice

package
v0.0.0-...-1905027 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const MaxPickExpireNum = 128
View Source
const PreMapRankSkipLen = 10

Variables

View Source
var RankDataPool = sync.NewPoolEx(make(chan sync.IPoolData, 10240), func() sync.IPoolData {
	var newRankData RankData
	return &newRankData
})

Functions

func ReleaseRankData

func ReleaseRankData(rankData *RankData)

Types

type DefaultRankModule

type DefaultRankModule struct {
	service.Module
}

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 IRankSkip

type IRankSkip interface {
	GetRankID() uint64
	GetRankName() string
	GetRankLen() uint64
	UpsetRank(upsetData *rpc.RankData, refreshTimestamp int64, fromLoad bool) RankDataChangeType
}

type MongoPersist

type MongoPersist struct {
	service.Module

	SaveInterval time.Duration //落地数据库时间间隔

	sync.Mutex
	// contains filtered or unexported fields
}

MongoPersist持久化Module

func (*MongoPersist) JugeTimeoutSave

func (mp *MongoPersist) JugeTimeoutSave() 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) OnStart

func (mp *MongoPersist) OnStart()

启服从数据库加载

func (*MongoPersist) OnStop

func (mp *MongoPersist) OnStop(mapRankSkip map[uint64]*RankSkip)

停存持久化到DB

func (*MongoPersist) ReadCfg

func (mp *MongoPersist) ReadCfg() error

type RankData

type RankData struct {
	Key      uint64
	SortData []int64
	Data     []byte
	ExData   []int64
	// contains filtered or unexported fields
}

func NewRankData

func NewRankData(isDec bool, data *rpc.RankData, refreshTimestamp int64) *RankData

func (*RankData) Compare

func (p *RankData) Compare(other skip.Comparator) int

func (*RankData) GetKey

func (p *RankData) GetKey() uint64

func (*RankData) IsRef

func (p *RankData) IsRef() bool

func (*RankData) Ref

func (p *RankData) Ref()

func (*RankData) Reset

func (p *RankData) Reset()

func (*RankData) UnRef

func (p *RankData) UnRef()

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

type RankService struct {
	service.Service
	// contains filtered or unexported fields
}

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)

安装排行模块

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

func (rs *RankSkip) DeleteRankData(delKeys []uint64) int32

DeleteRankData 删除排行数据

func (*RankSkip) GetRankDataFromToLimit

func (rs *RankSkip) GetRankDataFromToLimit(startPos, count uint64, result *rpc.RankDataList) error

GetRankList 获取排行榜数据,startPos开始的count个数据

func (*RankSkip) GetRankID

func (rs *RankSkip) GetRankID() uint64

GetRankID 获取排行榜Id

func (*RankSkip) GetRankKeyNextToLimit

func (rs *RankSkip) GetRankKeyNextToLimit(findKey, count uint64, result *rpc.RankDataList) error

GetRankKeyPrevToLimit 获取key前count名的数据

func (*RankSkip) GetRankKeyPrevToLimit

func (rs *RankSkip) GetRankKeyPrevToLimit(findKey, count uint64, result *rpc.RankDataList) error

GetRankKeyPrevToLimit 获取key前count名的数据

func (*RankSkip) GetRankLen

func (rs *RankSkip) GetRankLen() uint64

GetRankLen 获取排行榜长度

func (*RankSkip) GetRankName

func (rs *RankSkip) GetRankName() string

GetRankName 获取排行榜名称

func (*RankSkip) GetRankNodeData

func (rs *RankSkip) GetRankNodeData(findKey uint64) (*RankData, uint64)

GetRankNodeData 获取,返回排名节点与名次

func (*RankSkip) GetRankNodeDataByRank

func (rs *RankSkip) GetRankNodeDataByRank(rank uint64) (*RankData, uint64)

GetRankNodeDataByPos 获取,返回排名节点与名次

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

func (*RankSkip) UpsetRank

func (rs *RankSkip) UpsetRank(upsetData *rpc.RankData, refreshTimestamp int64, fromLoad bool) RankDataChangeType

UpsetRank 更新玩家排行数据,返回变化后的数据及变化类型

func (*RankSkip) UpsetRankList

func (rs *RankSkip) UpsetRankList(upsetRankData []*rpc.RankData) (addCount int32, modifyCount int32)

Jump to

Keyboard shortcuts

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