store

package
v0.0.0-...-1ee3c8e Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

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) Game

func (s *PostgresStore) Game(ctx context.Context, adminToken string) (*wording.Game, error)

Game fetches a game.

func (*PostgresStore) GameByToken

func (s *PostgresStore) GameByToken(ctx context.Context, token string) (*wording.Game, error)

GameByToken fetches a game by the the specified token.

func (*PostgresStore) GameStats

func (s *PostgresStore) GameStats(ctx context.Context, adminToken string) (wording.Stats, error)

GameStats fetches stats for an individual game.

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.

func (*PostgresStore) PutPlays

func (s *PostgresStore) PutPlays(ctx context.Context, gameToken, playerToken string, plays *wording.Plays) error

PutPlays updates a player's attempts against a game.

func (*PostgresStore) Stats

func (s *PostgresStore) Stats(ctx context.Context) (wording.Stats, error)

Stats fetches the overall lifetime stats.

Jump to

Keyboard shortcuts

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