Documentation
¶
Overview ¶
Package bolt provides a bolt-backed database that implements both boardgame.StorageManager and boardgame/server.StorageManager.
Index ¶
- type StorageManager
- func (s *StorageManager) AgentState(gameID string, player boardgame.PlayerIndex) ([]byte, error)
- func (s *StorageManager) AllGames() []*boardgame.GameStorageRecord
- func (s *StorageManager) ChatMessages(gameID string, channel string, sinceID string, limit int) ([]*boardgame.ChatMessage, error)
- func (s *StorageManager) CleanUp()
- func (s *StorageManager) ClearSeatPresentation(gameID string, playerIndex boardgame.PlayerIndex) error
- func (s *StorageManager) Close()
- func (s *StorageManager) CombinedGame(id string) (*extendedgame.CombinedStorageRecord, error)
- func (s *StorageManager) CompanionTableLease(gameID string) (*tablelease.StorageRecord, error)
- func (s *StorageManager) CompareAndSwapCompanionTableLease(gameID string, expectedGeneration uint64, ...) (*tablelease.StorageRecord, bool, error)
- func (s *StorageManager) Connect(config string) error
- func (s *StorageManager) ConnectCookieToUser(cookie string, user *users.StorageRecord) error
- func (s *StorageManager) ExtendedGame(id string) (*extendedgame.StorageRecord, error)
- func (s *StorageManager) FetchInjectedDataForGame(gameID string, dataType string) interface{}
- func (s *StorageManager) Game(id string) (*boardgame.GameStorageRecord, error)
- func (s *StorageManager) GameByRoomCode(code string) (string, error)
- func (s *StorageManager) GetUserByCookie(cookie string) *users.StorageRecord
- func (s *StorageManager) GetUserByID(uid string) *users.StorageRecord
- 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) PlayerMoveApplied(game *boardgame.GameStorageRecord) error
- func (s *StorageManager) SaveAgentState(gameID string, player boardgame.PlayerIndex, state []byte) error
- func (s *StorageManager) SaveChatMessage(msg *boardgame.ChatMessage) error
- func (s *StorageManager) SaveGameAndCurrentState(game *boardgame.GameStorageRecord, state boardgame.StateStorageRecord, ...) error
- func (s *StorageManager) SaveProposalFrontier(gameID string, stateVersion, frontierVersion int) error
- func (s *StorageManager) SeatPresentation(gameID string, playerIndex boardgame.PlayerIndex) (*seatpresentation.StorageRecord, error)
- func (s *StorageManager) SetPlayerForGame(gameID string, playerIndex boardgame.PlayerIndex, userID string) error
- func (s *StorageManager) SetSeatPresentation(rec *seatpresentation.StorageRecord) error
- func (s *StorageManager) State(gameID string, version int) (boardgame.StateStorageRecord, error)
- func (s *StorageManager) TimerWakeups(gameName string) ([]boardgame.TimerWakeup, error)
- func (s *StorageManager) UpdateExtendedGame(id string, eGame *extendedgame.StorageRecord) error
- func (s *StorageManager) UpdateUser(user *users.StorageRecord) error
- func (s *StorageManager) UserIDsForGame(gameID string) []string
- func (s *StorageManager) WithManagers(managers []*boardgame.GameManager)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type StorageManager ¶
type StorageManager struct {
// contains filtered or unexported fields
}
StorageManager is the main object that implements StorageManager and api.StorageManager. Get a new one from NewStorageManager.
func NewStorageManager ¶
func NewStorageManager(fileName string) *StorageManager
NewStorageManager returns a new StorageManager ready for use, backed by the boltDB that exists at that filename, relative to current directory. Will create that file if it doesn't exist.
func (*StorageManager) AgentState ¶
func (s *StorageManager) AgentState(gameID string, player boardgame.PlayerIndex) ([]byte, error)
AgentState implements that method from the main storagemanager interface
func (*StorageManager) AllGames ¶
func (s *StorageManager) AllGames() []*boardgame.GameStorageRecord
AllGames implements the extra method necessary for storage/internal/helpers
func (*StorageManager) ChatMessages ¶
func (s *StorageManager) ChatMessages(gameID string, channel string, sinceID string, limit int) ([]*boardgame.ChatMessage, error)
ChatMessages implements boardgame.ChatStorageManager.
func (*StorageManager) CleanUp ¶
func (s *StorageManager) CleanUp()
CleanUp removes the backing file
func (*StorageManager) ClearSeatPresentation ¶
func (s *StorageManager) ClearSeatPresentation(gameID string, playerIndex boardgame.PlayerIndex) error
ClearSeatPresentation implements that method from the server api storagemanager interface.
func (*StorageManager) Close ¶
func (s *StorageManager) Close()
Close closes the handle to the bolt db
func (*StorageManager) CombinedGame ¶
func (s *StorageManager) CombinedGame(id string) (*extendedgame.CombinedStorageRecord, error)
CombinedGame implements that method from the server api storagemanager interface
func (*StorageManager) CompanionTableLease ¶
func (s *StorageManager) CompanionTableLease(gameID string) (*tablelease.StorageRecord, error)
CompanionTableLease implements the server storage interface.
func (*StorageManager) CompareAndSwapCompanionTableLease ¶
func (s *StorageManager) CompareAndSwapCompanionTableLease(gameID string, expectedGeneration uint64, replacement *tablelease.StorageRecord) (*tablelease.StorageRecord, bool, error)
CompareAndSwapCompanionTableLease implements the server storage interface.
func (*StorageManager) Connect ¶
func (s *StorageManager) Connect(config string) error
Connect is a no op
func (*StorageManager) ConnectCookieToUser ¶
func (s *StorageManager) ConnectCookieToUser(cookie string, user *users.StorageRecord) error
ConnectCookieToUser implements that method from the server api storagemanager interface
func (*StorageManager) ExtendedGame ¶
func (s *StorageManager) ExtendedGame(id string) (*extendedgame.StorageRecord, error)
ExtendedGame implements that method from the server api storagemanager interface
func (*StorageManager) FetchInjectedDataForGame ¶
func (s *StorageManager) FetchInjectedDataForGame(gameID string, dataType string) interface{}
FetchInjectedDataForGame can just return nil
func (*StorageManager) Game ¶
func (s *StorageManager) Game(id string) (*boardgame.GameStorageRecord, error)
Game implements that method from the main storagemanager interface
func (*StorageManager) GameByRoomCode ¶
func (s *StorageManager) GameByRoomCode(code string) (string, error)
GameByRoomCode implements that method from the server api storagemanager interface. Scans extended-game records for a CompanionRoomCode match. Returns "" and a nil error if not found. Bolt doesn't have an index, so this is O(N) over extendedGames — acceptable for the small N expected of a single-server bolt deployment.
func (*StorageManager) GetUserByCookie ¶
func (s *StorageManager) GetUserByCookie(cookie string) *users.StorageRecord
GetUserByCookie implements that method from the server api storagemanager interface
func (*StorageManager) GetUserByID ¶
func (s *StorageManager) GetUserByID(uid string) *users.StorageRecord
GetUserByID implements that method from the server api storagemanager interface
func (*StorageManager) ListGames ¶
func (s *StorageManager) ListGames(max int, list listing.Type, userID string, gameType string) []*extendedgame.CombinedStorageRecord
ListGames implements that method from the server api storagemanager interface
func (*StorageManager) Move ¶
func (s *StorageManager) Move(gameID string, version int) (*boardgame.MoveStorageRecord, error)
Move implements that method from the main storagemanager interface
func (*StorageManager) Moves ¶
func (s *StorageManager) Moves(gameID string, fromVersion, toVersion int) ([]*boardgame.MoveStorageRecord, error)
Moves implements that method from the main storagemanager interface
func (*StorageManager) PlayerMoveApplied ¶
func (s *StorageManager) PlayerMoveApplied(game *boardgame.GameStorageRecord) error
PlayerMoveApplied is a noop
func (*StorageManager) SaveAgentState ¶
func (s *StorageManager) SaveAgentState(gameID string, player boardgame.PlayerIndex, state []byte) error
SaveAgentState implements that method from the main storagemanager interface
func (*StorageManager) SaveChatMessage ¶
func (s *StorageManager) SaveChatMessage(msg *boardgame.ChatMessage) error
SaveChatMessage implements boardgame.ChatStorageManager.
func (*StorageManager) SaveGameAndCurrentState ¶
func (s *StorageManager) SaveGameAndCurrentState(game *boardgame.GameStorageRecord, state boardgame.StateStorageRecord, move *boardgame.MoveStorageRecord) error
SaveGameAndCurrentState implements that method from the main storagemanager interface
func (*StorageManager) SaveProposalFrontier ¶
func (s *StorageManager) SaveProposalFrontier(gameID string, stateVersion, frontierVersion int) error
SaveProposalFrontier persists proposal-boundary evidence with a durable-head compare inside the same Bolt write transaction.
func (*StorageManager) SeatPresentation ¶
func (s *StorageManager) SeatPresentation(gameID string, playerIndex boardgame.PlayerIndex) (*seatpresentation.StorageRecord, error)
SeatPresentation implements that method from the server api storagemanager interface.
func (*StorageManager) SetPlayerForGame ¶
func (s *StorageManager) SetPlayerForGame(gameID string, playerIndex boardgame.PlayerIndex, userID string) error
SetPlayerForGame implements that method from the server api storagemanager interface
func (*StorageManager) SetSeatPresentation ¶
func (s *StorageManager) SetSeatPresentation(rec *seatpresentation.StorageRecord) error
SetSeatPresentation implements that method from the server api storagemanager interface.
func (*StorageManager) State ¶
func (s *StorageManager) State(gameID string, version int) (boardgame.StateStorageRecord, error)
State implements that method from the main storagemanager interface
func (*StorageManager) TimerWakeups ¶
func (s *StorageManager) TimerWakeups(gameName string) ([]boardgame.TimerWakeup, error)
TimerWakeups discovers active durable timers without inflating games.
func (*StorageManager) UpdateExtendedGame ¶
func (s *StorageManager) UpdateExtendedGame(id string, eGame *extendedgame.StorageRecord) error
UpdateExtendedGame implements that method from the server api storagemanager interface
func (*StorageManager) UpdateUser ¶
func (s *StorageManager) UpdateUser(user *users.StorageRecord) error
UpdateUser implements that method from the server api storagemanager interface
func (*StorageManager) UserIDsForGame ¶
func (s *StorageManager) UserIDsForGame(gameID string) []string
UserIDsForGame implements that method from the server api storagemanager interface
func (*StorageManager) WithManagers ¶
func (s *StorageManager) WithManagers(managers []*boardgame.GameManager)
WithManagers does nothing.