Documentation ¶
Index ¶
- Constants
- type Client
- func (c *Client) AddGameHostForGame(gameID string, host string) error
- func (c *Client) AddGamePlayerForGame(gameID string, player string) error
- func (c *Client) AddGameServerHostingGamesForDispatcher(dispatcherID string, gameID string) error
- func (c *Client) ExistsGame(gameID string) (bool, error)
- func (c *Client) GetGameHostsForGame(gameID string) ([]string, error)
- func (c *Client) GetGamePlayersForGame(gameID string) ([]string, error)
- func (c *Client) GetGameServerHostingGamesForDispatcher(dispatcherID string) ([]string, error)
- func (c *Client) GetGameServerWithLeastActiveGames() (string, error)
- func (c *Client) GetGameStateForGame(gameID string) (map[string]string, error)
- func (c *Client) GetGameTokenForUserInGameID(userID string, gameID string) (string, error)
- func (c *Client) IncrementActiveGamesForGameServerByAmount(dispatcherID string, incrementBy float64) (float64, error)
- func (c *Client) InitActiveGamesForGameServer(dispatcherID string) error
- func (c *Client) RemoveAllGameHostsForGame(gameID string) error
- func (c *Client) RemoveAllGamePlayersForGame(gameID string) error
- func (c *Client) RemoveAllGameTokensForGameID(gameID string) error
- func (c *Client) RemoveGameHostForGame(gameID string, host string) error
- func (c *Client) RemoveGamePlayerForGame(gameID string, player string) error
- func (c *Client) RemoveGameServerHostingGamesForDispatcher(dispatcherID string, gameID string) error
- func (c *Client) RemoveGameStateForGame(gameID string) error
- func (c *Client) RemoveGameTokenForUserInGameID(userID string, gameID string) error
- func (c *Client) SetGameStateForGame(gameID string, state map[string]interface{}) error
- func (c *Client) SetNXGameTokenForUserInGameID(userID string, gameID string, token string) (bool, error)
- type ErrNoActiveGameServer
Constants ¶
const ( // KeyGameServerActiveGames is the hashset containing the gameserverID with a score of current active games KeyGameServerActiveGames = "GameServer.ActiveGames" // FormatKeySetGameServerHostingGamesForDispatcher is the set of gameIDs a server is responsible for FormatKeySetGameServerHostingGamesForDispatcher = "GameServer.HostingGames:%s" // FormatKeySetGameStateForGameID contains the flat game state of a game FormatKeySetGameStateForGameID = "Game.State:%s" // FormatKeySetGamePlayersForGameID contains the set of all players of a game FormatKeySetGamePlayersForGameID = "Game.Players:%s" // FormatKeySetGameHostsForGameID contains the set of all hosts of a game FormatKeySetGameHostsForGameID = "Game.Hosts:%s" // FormatKeyHashGameTokensForGameID contains the user tokens for a game FormatKeyHashGameTokensForGameID = "Game.Tokens:%s" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
Universal redis.UniversalClient
}
Client represents a redis client
func (*Client) AddGameHostForGame ¶
AddGameHostForGame persists a host of a game
func (*Client) AddGamePlayerForGame ¶
AddGamePlayerForGame persists a player of a game
func (*Client) AddGameServerHostingGamesForDispatcher ¶
AddGameServerHostingGamesForDispatcher persists a game which a dispatcher is responsible for
func (*Client) ExistsGame ¶
ExistsGame checks whether a game with the given gameID exists
func (*Client) GetGameHostsForGame ¶
GetGameHostsForGame returns the players of a game
func (*Client) GetGamePlayersForGame ¶
GetGamePlayersForGame returns the players of a game
func (*Client) GetGameServerHostingGamesForDispatcher ¶
GetGameServerHostingGamesForDispatcher gets all games which a dispatcher is responsible for
func (*Client) GetGameServerWithLeastActiveGames ¶
GetGameServerWithLeastActiveGames returns the game server with the least amount of active games
func (*Client) GetGameStateForGame ¶
GetGameStateForGame returns the flat game state from redis
func (*Client) GetGameTokenForUserInGameID ¶
GetGameTokenForUserInGameID gets the token for a user in a specific game
func (*Client) IncrementActiveGamesForGameServerByAmount ¶
func (c *Client) IncrementActiveGamesForGameServerByAmount(dispatcherID string, incrementBy float64) (float64, error)
IncrementActiveGamesForGameServerByAmount increases the active games for the prprovided gameserver by amount and returns the new score
func (*Client) InitActiveGamesForGameServer ¶
InitActiveGamesForGameServer adds the dispatcher to the set of activeGames and initializes it with score 0 if it does not exist yet
func (*Client) RemoveAllGameHostsForGame ¶
RemoveAllGameHostsForGame removes all host of a game from persistence
func (*Client) RemoveAllGamePlayersForGame ¶
RemoveAllGamePlayersForGame removes all players of a game
func (*Client) RemoveAllGameTokensForGameID ¶
RemoveAllGameTokensForGameID removes all tokens for a game
func (*Client) RemoveGameHostForGame ¶
RemoveGameHostForGame removes a host of a game from persistence
func (*Client) RemoveGamePlayerForGame ¶
RemoveGamePlayerForGame removes the player from a game
func (*Client) RemoveGameServerHostingGamesForDispatcher ¶
func (c *Client) RemoveGameServerHostingGamesForDispatcher(dispatcherID string, gameID string) error
RemoveGameServerHostingGamesForDispatcher removes a game which a dispatcher is responsible for
func (*Client) RemoveGameStateForGame ¶
RemoveGameStateForGame removes the game state from redis
func (*Client) RemoveGameTokenForUserInGameID ¶
RemoveGameTokenForUserInGameID removes a token of a user in a game
func (*Client) SetGameStateForGame ¶
SetGameStateForGame persists the flat game state to redis
type ErrNoActiveGameServer ¶
type ErrNoActiveGameServer struct{}
ErrNoActiveGameServer represents an error when no game serer is currently active
func (*ErrNoActiveGameServer) Error ¶
func (e *ErrNoActiveGameServer) Error() string