Documentation
¶
Index ¶
- Variables
- type PostgresStore
- func (s *PostgresStore) Close() error
- func (s *PostgresStore) CreateGame(ctx context.Context, adminToken, token, answer string, guessLimit int) (*wording.Game, error)
- func (s *PostgresStore) DeleteGame(ctx context.Context, adminToken string) error
- func (s *PostgresStore) Game(ctx context.Context, adminToken string) (*wording.Game, error)
- func (s *PostgresStore) GameByToken(ctx context.Context, token string) (*wording.Game, error)
- func (s *PostgresStore) GameStats(ctx context.Context, adminToken string) (wording.Stats, error)
- func (s *PostgresStore) IncrementStats(ctx context.Context, stats wording.IncrementStats) error
- func (s *PostgresStore) Plays(ctx context.Context, gameToken, playerToken string) (*wording.Plays, error)
- func (s *PostgresStore) PutPlays(ctx context.Context, gameToken, playerToken string, plays *wording.Plays) error
- func (s *PostgresStore) Stats(ctx context.Context) (wording.Stats, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotFound indicates the record could not be found. ErrNotFound = errors.New("not found") )
Functions ¶
This section is empty.
Types ¶
type PostgresStore ¶
type PostgresStore struct {
// contains filtered or unexported fields
}
PostgresStore is a PostgreSQL-backed persistence layer for the game.
func NewPostgresStore ¶
func NewPostgresStore(dsn string) (*PostgresStore, error)
NewPostgresStore opens a connection to the Postgres store.
func (*PostgresStore) Close ¶
func (s *PostgresStore) Close() error
Close closes the connection to the Postgres store.
func (*PostgresStore) CreateGame ¶
func (s *PostgresStore) CreateGame(ctx context.Context, adminToken, token, answer string, guessLimit int) (*wording.Game, error)
CreateGame creates a game.
func (*PostgresStore) DeleteGame ¶
func (s *PostgresStore) DeleteGame(ctx context.Context, adminToken string) error
DeleteGame deletes the game and all of the attempts recorded against it.
func (*PostgresStore) GameByToken ¶
GameByToken fetches a game by the the specified token.
func (*PostgresStore) IncrementStats ¶
func (s *PostgresStore) IncrementStats(ctx context.Context, stats wording.IncrementStats) error
IncrementStats adjusts overall stats for the application.
func (*PostgresStore) Plays ¶
func (s *PostgresStore) Plays(ctx context.Context, gameToken, playerToken string) (*wording.Plays, error)
Plays fetches a player's attempts against a given game.
Click to show internal directories.
Click to hide internal directories.