redis

package
v0.0.0-...-d64fcf2 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
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 NewClient

func NewClient(masterAddr string, password string) (*Client, error)

NewClient creates a new redis client

func (*Client) AddGameHostForGame

func (c *Client) AddGameHostForGame(gameID string, host string) error

AddGameHostForGame persists a host of a game

func (*Client) AddGamePlayerForGame

func (c *Client) AddGamePlayerForGame(gameID string, player string) error

AddGamePlayerForGame persists a player of a game

func (*Client) AddGameServerHostingGamesForDispatcher

func (c *Client) AddGameServerHostingGamesForDispatcher(dispatcherID string, gameID string) error

AddGameServerHostingGamesForDispatcher persists a game which a dispatcher is responsible for

func (*Client) ExistsGame

func (c *Client) ExistsGame(gameID string) (bool, error)

ExistsGame checks whether a game with the given gameID exists

func (*Client) GetGameHostsForGame

func (c *Client) GetGameHostsForGame(gameID string) ([]string, error)

GetGameHostsForGame returns the players of a game

func (*Client) GetGamePlayersForGame

func (c *Client) GetGamePlayersForGame(gameID string) ([]string, error)

GetGamePlayersForGame returns the players of a game

func (*Client) GetGameServerHostingGamesForDispatcher

func (c *Client) GetGameServerHostingGamesForDispatcher(dispatcherID string) ([]string, error)

GetGameServerHostingGamesForDispatcher gets all games which a dispatcher is responsible for

func (*Client) GetGameServerWithLeastActiveGames

func (c *Client) GetGameServerWithLeastActiveGames() (string, error)

GetGameServerWithLeastActiveGames returns the game server with the least amount of active games

func (*Client) GetGameStateForGame

func (c *Client) GetGameStateForGame(gameID string) (map[string]string, error)

GetGameStateForGame returns the flat game state from redis

func (*Client) GetGameTokenForUserInGameID

func (c *Client) GetGameTokenForUserInGameID(userID string, gameID string) (string, error)

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

func (c *Client) InitActiveGamesForGameServer(dispatcherID string) error

InitActiveGamesForGameServer adds the dispatcher to the set of activeGames and initializes it with score 0 if it does not exist yet

func (*Client) RemoveAllGameHostsForGame

func (c *Client) RemoveAllGameHostsForGame(gameID string) error

RemoveAllGameHostsForGame removes all host of a game from persistence

func (*Client) RemoveAllGamePlayersForGame

func (c *Client) RemoveAllGamePlayersForGame(gameID string) error

RemoveAllGamePlayersForGame removes all players of a game

func (*Client) RemoveAllGameTokensForGameID

func (c *Client) RemoveAllGameTokensForGameID(gameID string) error

RemoveAllGameTokensForGameID removes all tokens for a game

func (*Client) RemoveGameHostForGame

func (c *Client) RemoveGameHostForGame(gameID string, host string) error

RemoveGameHostForGame removes a host of a game from persistence

func (*Client) RemoveGamePlayerForGame

func (c *Client) RemoveGamePlayerForGame(gameID string, player string) error

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

func (c *Client) RemoveGameStateForGame(gameID string) error

RemoveGameStateForGame removes the game state from redis

func (*Client) RemoveGameTokenForUserInGameID

func (c *Client) RemoveGameTokenForUserInGameID(userID string, gameID string) error

RemoveGameTokenForUserInGameID removes a token of a user in a game

func (*Client) SetGameStateForGame

func (c *Client) SetGameStateForGame(gameID string, state map[string]interface{}) error

SetGameStateForGame persists the flat game state to redis

func (*Client) SetNXGameTokenForUserInGameID

func (c *Client) SetNXGameTokenForUserInGameID(userID string, gameID string, token string) (bool, error)

SetNXGameTokenForUserInGameID sets a token of a user in a game if a token does not already exist for the user

type ErrNoActiveGameServer

type ErrNoActiveGameServer struct{}

ErrNoActiveGameServer represents an error when no game serer is currently active

func (*ErrNoActiveGameServer) Error

func (e *ErrNoActiveGameServer) Error() string

Jump to

Keyboard shortcuts

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