Documentation ¶
Index ¶
- Constants
- Variables
- type CreateFunc
- type GetByIDAndGameIDFunc
- type Leaderboard
- type NewLeaderboardData
- type Rank
- type RankingFunc
- type SoftDeleteFunc
- type StorageCreateLeaderboardFunc
- type StorageGetLeaderboardByIDAndGameIDFunc
- type StorageGetRankingFunc
- type StorageSoftDeleteLeaderboardFunc
- type StorageUpsertPlayerRankValueFunc
- type UpsertPlayerRankFunc
Constants ¶
View Source
const ( AggregationModeInc = "INC" AggregationModeMax = "MAX" AggregationModeMin = "MIN" OrderingAsc = "ASC" OrderingDesc = "DESC" )
View Source
const ( MaxLimitNumber = 500 MinLimitNumber = 1 MinPageNumber = 0 )
Variables ¶
View Source
var ( ErrValidationError = errors.New("validation error") ErrInvalidName = errors.New("invalid name") ErrInvalidGameID = errors.New("invalid game id") ErrInvalidStartDate = errors.New("invalid start date") ErrInvalidAggregationMode = errors.New("invalid aggregation mode") ErrInvalidOrdering = errors.New("invalid ordering") ErrEndDateBeforeStartDate = errors.New("end date must be after the start date") ErrInvalidLeaderboardID = errors.New("invalid leaderboard id") ErrLeaderboardNotFound = errors.New("leaderboard not found") )
View Source
var ( AggregationModes = []string{ AggregationModeInc, AggregationModeMax, AggregationModeMin, } OrderingModes = []string{ OrderingAsc, OrderingDesc, } )
Functions ¶
This section is empty.
Types ¶
type CreateFunc ¶
type CreateFunc func(ctx context.Context, data NewLeaderboardData) (Leaderboard, error)
Create a leaderboard and return it's id
func BuildCreateFunc ¶
func BuildCreateFunc(storageCreateFunc StorageCreateLeaderboardFunc) CreateFunc
type GetByIDAndGameIDFunc ¶
type GetByIDAndGameIDFunc func(ctx context.Context, id, gameID string) (Leaderboard, error)
Get a leaderboard by it's id and game id
func BuildGetByIDAndGameIDFunc ¶
func BuildGetByIDAndGameIDFunc(storageGetFunc StorageGetLeaderboardByIDAndGameIDFunc) GetByIDAndGameIDFunc
type Leaderboard ¶
type Leaderboard struct { CreatedAt time.Time // Time that the leaderboard was created UpdatedAt time.Time // Last time that the leaderboard info was updated DeletedAt time.Time // Time that the leaderboard was deleted ID string // Leaderboard's ID GameID string // The ID from the game that is responsible for the leaderboard Name string // Leaderboard's name Description string // Leaderboard's description StartAt time.Time // Time that the leaderboard should start working EndAt time.Time // Time that the leaderboard will be closed for new updates AggregationMode string // Data aggregation mode Ordering string // Leaderboard ranking order }
func (Leaderboard) Closed ¶
func (l Leaderboard) Closed() bool
type NewLeaderboardData ¶
type NewLeaderboardData struct { GameID string // The ID from the game that is responsible for the leaderboard Name string // Leaderboard's name Description string // Leaderboard's description StartAt time.Time // Time that the leaderboard should start working EndAt time.Time // Time that the leaderboard will be closed for new updates AggregationMode string // Data aggregation mode Ordering string // Leaderboard ranking order }
type RankingFunc ¶
type RankingFunc func(ctx context.Context, leaderboard Leaderboard, page, limit int64) ([]Rank, error)
Leaderboard ranking paginated
func BuildRankingFunc ¶
func BuildRankingFunc(getRankingFunc StorageGetRankingFunc) RankingFunc
type SoftDeleteFunc ¶
Soft Delete a leaderboard
func BuildSoftDeleteFunc ¶
func BuildSoftDeleteFunc(storageSoftDeleteFunc StorageSoftDeleteLeaderboardFunc) SoftDeleteFunc
type StorageCreateLeaderboardFunc ¶
type StorageCreateLeaderboardFunc func(ctx context.Context, data NewLeaderboardData) (Leaderboard, error)
Storage function that is responsible for creating the leaderboard
type StorageGetLeaderboardByIDAndGameIDFunc ¶
type StorageGetLeaderboardByIDAndGameIDFunc func(ctx context.Context, id, gameID string) (Leaderboard, error)
Storage function that returns a leaderboard by it's id and game id
type StorageGetRankingFunc ¶
type StorageGetRankingFunc func(ctx context.Context, leaderboardID, ordering string, page, limit int64) ([]Rank, error)
Get the leaderboard ranking paginated
type StorageSoftDeleteLeaderboardFunc ¶
Storage function that soft delete a leaderboard
type StorageUpsertPlayerRankValueFunc ¶
type StorageUpsertPlayerRankValueFunc func(ctx context.Context, leaderboard Leaderboard, playerID string, value float64) error
Updates the player's rank value using the value provided
type UpsertPlayerRankFunc ¶
type UpsertPlayerRankFunc func(ctx context.Context, leaderboard Leaderboard, playerID string, value float64) error
Set or update the player's rank
func BuildUpsertPlayerRankFunc ¶
func BuildUpsertPlayerRankFunc(upsertPlayerRankValueFunc StorageUpsertPlayerRankValueFunc) UpsertPlayerRankFunc
Click to show internal directories.
Click to hide internal directories.