Documentation ¶
Overview ¶
Package memory is a storage manager that just keeps the games and storage in memory, which means that when the program exits the storage evaporates. Useful in cases where you don't want a persistent store (e.g. testing or fast iteration). Implements both boardgame.StorageManager and boardgame/server.StorageManager.
Index ¶
- type StorageManager
- func (s *StorageManager) AllGames() []*boardgame.GameStorageRecord
- func (s *StorageManager) Game(id string) (*boardgame.GameStorageRecord, error)
- func (s *StorageManager) ListGames(max int, list listing.Type, userID string, gameType string) []*extendedgame.CombinedStorageRecord
- func (s *StorageManager) Move(gameID string, version int) (*boardgame.MoveStorageRecord, error)
- func (s *StorageManager) Moves(gameID string, fromVersion, toVersion int) ([]*boardgame.MoveStorageRecord, error)
- func (s *StorageManager) Name() string
- func (s *StorageManager) SaveGameAndCurrentState(game *boardgame.GameStorageRecord, state boardgame.StateStorageRecord, ...) error
- func (s *StorageManager) State(gameID string, version int) (boardgame.StateStorageRecord, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type StorageManager ¶
type StorageManager struct { *helpers.ExtendedMemoryStorageManager // contains filtered or unexported fields }
StorageManager is the primary type of this package. Get a new one with NewStorageManager.
func NewStorageManager ¶
func NewStorageManager() *StorageManager
NewStorageManager is the way to get a new StorageManager.
func (*StorageManager) AllGames ¶
func (s *StorageManager) AllGames() []*boardgame.GameStorageRecord
AllGames implements the extra method that storage/internal/helpers needs.
func (*StorageManager) Game ¶
func (s *StorageManager) Game(id string) (*boardgame.GameStorageRecord, error)
Game implements that part of the core storage interface
func (*StorageManager) ListGames ¶
func (s *StorageManager) ListGames(max int, list listing.Type, userID string, gameType string) []*extendedgame.CombinedStorageRecord
ListGames will return game objects for up to max number of games
func (*StorageManager) Move ¶
func (s *StorageManager) Move(gameID string, version int) (*boardgame.MoveStorageRecord, error)
Move implements that part of the core storage interface
func (*StorageManager) Moves ¶
func (s *StorageManager) Moves(gameID string, fromVersion, toVersion int) ([]*boardgame.MoveStorageRecord, error)
Moves implements that part of the core storage interface
func (*StorageManager) SaveGameAndCurrentState ¶
func (s *StorageManager) SaveGameAndCurrentState(game *boardgame.GameStorageRecord, state boardgame.StateStorageRecord, move *boardgame.MoveStorageRecord) error
SaveGameAndCurrentState implements that part of the core storage interface
func (*StorageManager) State ¶
func (s *StorageManager) State(gameID string, version int) (boardgame.StateStorageRecord, error)
State implements that part of the core storage interface