Documentation ¶
Overview ¶
Package store includes all the methods for persisting rock paper scissors games
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UpdateGameFromItem ¶
GameFromItem updates a game struct populated with data from the Dynamo GameItem
func UpdateItemFromGame ¶
UpdateItemFromGame updates a dynamo game item from the game struct
Types ¶
type GameItem ¶
type GameItem struct { PK string SK string Type string Round int Plays int Players map[string]PlayerItem GameID string Expires int64 }
GameItem is for game status items
type GameStore ¶
type GameStore interface { Load(string) (*game.Game, error) StoreAll(*game.Game) error StoreRound(*game.Game) error StorePlay(*game.GameContext) error StorePlayer(*game.GameContext) error }
GameStore interface declares the
type PlayerItem ¶
PlayerItem represents a player in the game, and is for the "players" map on the game item
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store stores the dynamo client and other metadata needed, like the table
func (*Store) StoreAll ¶
StoreAll takes a Game and persists the entire thing Useful when creating a new game or large operations like round updates
func (*Store) StorePlay ¶
func (s *Store) StorePlay(gc *game.GameContext) error
StorePlay takes a GameContext and stores the bits needed if a play has been made It updates the Game with the current status as well
func (*Store) StorePlayer ¶
func (s *Store) StorePlayer(gc *game.GameContext) error
StorePlayer takes a GameContext and stores the bits needed for an added player
func (*Store) StoreRound ¶
StoreRound takes a Game and stores the next round For now takes a tiny risk of a race condition updating non-essential data, by uploading the whole item. (e.g. could blow out another player's connection if it changed at the exact wrong time.)