lib

package
v9.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2019 License: MIT Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Member

type Member struct {
	LeaderboardID string
	PublicID      string
	Score         int
	Rank          int
	PreviousRank  int
}

Member maps an member identified by their publicID to their score and rank

type MemberList

type MemberList struct {
	Members  []*Member
	Member   *Member
	NotFound []string
}

MemberList is a list of member

type Podium

type Podium struct {
	Config *viper.Viper
	URL    string
	User   string
	Pass   string
	// contains filtered or unexported fields
}

Podium is a struct that represents a podium API application

func (*Podium) DeleteLeaderboard

func (p *Podium) DeleteLeaderboard(ctx context.Context, leaderboard string) (*Response, error)

DeleteLeaderboard deletes the leaderboard from podium

func (*Podium) GetCount

func (p *Podium) GetCount(ctx context.Context, leaderboard string) (int, error)

GetCount gets the number of members in a leaderboard

func (*Podium) GetMember

func (p *Podium) GetMember(ctx context.Context, leaderboard, memberID string) (*Member, error)

GetMember shows score and rank of a particular member in a leaderboard

func (*Podium) GetMemberInLeaderboards

func (p *Podium) GetMemberInLeaderboards(ctx context.Context, leaderboards []string, memberID string, order ...string) (*ScoreList, error)

GetMemberInLeaderboards returns the ranking and score of a player in multiple leaderboards

func (*Podium) GetMembers

func (p *Podium) GetMembers(ctx context.Context, leaderboard string, memberIDs []string) (*MemberList, error)

GetMembers returns the members for this leaderboard. Page is 1-index

func (*Podium) GetMembersAroundMember

func (p *Podium) GetMembersAroundMember(ctx context.Context, leaderboard, memberID string, pageSize int, getLastIfNotFound bool, order ...string) (*MemberList, error)

GetMembersAroundMember returns the members around the given memberID

func (*Podium) GetTop

func (p *Podium) GetTop(ctx context.Context, leaderboard string, page, pageSize int) (*MemberList, error)

GetTop returns the top members for this leaderboard. Page is 1-index

func (*Podium) GetTopPercent

func (p *Podium) GetTopPercent(ctx context.Context, leaderboard string, percentage int) (*MemberList, error)

GetTopPercent returns the top x% of members in a leaderboard

func (*Podium) Healthcheck

func (p *Podium) Healthcheck(ctx context.Context) (string, error)

Healthcheck verifies if podium is still up

func (*Podium) IncrementScore

func (p *Podium) IncrementScore(ctx context.Context, leaderboard, memberID string, increment, scoreTTL int) (*MemberList, error)

IncrementScore increments the score of a particular member in a leaderboard

func (*Podium) RemoveMemberFromLeaderboard

func (p *Podium) RemoveMemberFromLeaderboard(ctx context.Context, leaderboard, member string) (*Response, error)

RemoveMemberFromLeaderboard removes a member from a leaderboard

func (*Podium) UpdateMembersScore

func (p *Podium) UpdateMembersScore(ctx context.Context, leaderboard string, members []*Member, scoreTTL int) (*MemberList, error)

UpdateMembersScore updates the score of a member in more than one leaderboard

func (*Podium) UpdateScore

func (p *Podium) UpdateScore(ctx context.Context, leaderboard, memberID string, score, scoreTTL int) (*Member, error)

UpdateScore updates the score of a particular member in a leaderboard

func (*Podium) UpdateScores

func (p *Podium) UpdateScores(ctx context.Context, leaderboards []string, memberID string, score, scoreTTL int) (*ScoreList, error)

UpdateScores updates the score of a member in more than one leaderboard

type PodiumInterface

type PodiumInterface interface {
	DeleteLeaderboard(ctx context.Context, leaderboard string) (*Response, error)
	GetCount(ctx context.Context, leaderboard string) (int, error)
	GetMember(ctx context.Context, leaderboard, memberID string) (*Member, error)
	GetMembers(ctx context.Context, leaderboard string, memberIDs []string) (*MemberList, error)
	GetMemberInLeaderboards(ctx context.Context, leaderboards []string, memberID string, order ...string) (*ScoreList, error)
	GetMembersAroundMember(ctx context.Context, leaderboard, memberID string, pageSize int, getLastIfNotFound bool, order ...string) (*MemberList, error)
	GetTop(ctx context.Context, leaderboard string, page, pageSize int) (*MemberList, error)
	GetTopPercent(ctx context.Context, leaderboard string, percentage int) (*MemberList, error)
	Healthcheck(ctx context.Context) (string, error)
	IncrementScore(ctx context.Context, leaderboard, memberID string, increment, scoreTTL int) (*MemberList, error)
	RemoveMemberFromLeaderboard(ctx context.Context, leaderboard, member string) (*Response, error)
	UpdateScore(ctx context.Context, leaderboard, memberID string, score, scoreTTL int) (*Member, error)
	UpdateScores(ctx context.Context, leaderboards []string, memberID string, score, scoreTTL int) (*ScoreList, error)
	UpdateMembersScore(ctx context.Context, leaderboard string, members []*Member, scoreTTL int) (*MemberList, error)
}

PodiumInterface defines the interface to be implemented

func NewPodium

func NewPodium(config *viper.Viper) PodiumInterface

NewPodium returns a new podium API application

type RequestError

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

RequestError contains code and body of a request that failed

func NewRequestError

func NewRequestError(statusCode int, body string) *RequestError

NewRequestError returns a request error

func (*RequestError) Error

func (r *RequestError) Error() string

func (*RequestError) Status

func (r *RequestError) Status() int

Status returns the status code of the error

type Response

type Response struct {
	Success bool
	Reason  string
}

Response will determine if a request has been succeeded

type Score

type Score struct {
	LeaderboardID string
	PublicID      string
	Score         int
	Rank          int
	PreviousRank  int
}

Score will represent a member Score in a Leaderboard

type ScoreList

type ScoreList struct {
	Scores []*Score
}

ScoreList is a list of Scores

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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