Documentation
¶
Index ¶
- Variables
- type AccountStatus
- type DatabaseStore
- type GameRow
- type GameStore
- type PostgresStore
- func (s *PostgresStore) AddUser(ctx context.Context, user *User) error
- func (s *PostgresStore) Close() error
- func (s *PostgresStore) DeleteUser(ctx context.Context, email string) error
- func (s *PostgresStore) FindUser(ctx context.Context, email string) (*User, error)
- func (s *PostgresStore) InsertHistory(ctx context.Context, entryType string, gameId string, gs *pb.GameState, ...) error
- func (s *PostgresStore) InsertStats(ctx context.Context, stats *api.WASMStatsRequest) error
- func (s *PostgresStore) ListRecentGames(ctx context.Context, offset int, limit int) ([]*GameRow, error)
- func (s *PostgresStore) LoadGame(ctx context.Context, gameId string) (*pb.GameState, error)
- func (s *PostgresStore) StoreGame(ctx context.Context, hostId string, gs *pb.GameState) error
- func (s *PostgresStore) UpdateUser(ctx context.Context, user *User) error
- func (s *PostgresStore) VerifyUser(ctx context.Context, verificationToken string) error
- type User
- type UserStore
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type AccountStatus ¶
type AccountStatus int
const ( AccountStatusNew AccountStatus = 0 AccountStatusActive AccountStatus = 1 AccountStatusBlocked AccountStatus = 2 AccountStatusDeleted AccountStatus = 3 )
type DatabaseStore ¶
type GameStore ¶
type GameStore interface {
// Stores a game state in the database.
StoreGame(ctx context.Context, hostId string, state *pb.GameState) error
// Adds an entry to the game history.
// If boardStatus is not nil, the game table will get updated with the status information.
InsertHistory(ctx context.Context, entryType string, gameId string, state *pb.GameState, boardStatus *api.BoardStatus) error
// Adds stats for a CPU move.
InsertStats(ctx context.Context, stats *api.WASMStatsRequest) error
// Loads the latest game state.
LoadGame(ctx context.Context, gameId string) (*pb.GameState, error)
// Lists the `limit` most recent games, skipping `offset` many (for paging).
// Games without a single move are not included in the result.
ListRecentGames(ctx context.Context, offset int, limit int) ([]*GameRow, error)
}
type PostgresStore ¶
type PostgresStore struct {
// contains filtered or unexported fields
}
func NewPostgresStore ¶
func NewPostgresStore(ctx context.Context, database_url string) (*PostgresStore, error)
func (*PostgresStore) AddUser ¶
func (s *PostgresStore) AddUser(ctx context.Context, user *User) error
func (*PostgresStore) Close ¶
func (s *PostgresStore) Close() error
func (*PostgresStore) DeleteUser ¶
func (s *PostgresStore) DeleteUser(ctx context.Context, email string) error
func (*PostgresStore) InsertHistory ¶
func (s *PostgresStore) InsertHistory(ctx context.Context, entryType string, gameId string, gs *pb.GameState, boardStatus *api.BoardStatus) error
func (*PostgresStore) InsertStats ¶
func (s *PostgresStore) InsertStats(ctx context.Context, stats *api.WASMStatsRequest) error
func (*PostgresStore) ListRecentGames ¶
func (*PostgresStore) UpdateUser ¶
func (s *PostgresStore) UpdateUser(ctx context.Context, user *User) error
Updates an existing user in the database. The ID field must be set to the user to be updated. An error is returned if the ID is empty. UpdatedAt may be empty, in which case it will be set to "now" in the database.
func (*PostgresStore) VerifyUser ¶
func (s *PostgresStore) VerifyUser(ctx context.Context, verificationToken string) error
type UserStore ¶
type UserStore interface {
// Looks up a single user by email address.
// Returns ErrUserNotFound if no user with the given email exists.
FindUser(ctx context.Context, email string) (*User, error)
// Adds a new user to the database.
// The ID field will be populated. An error is returned if
// it is not empty.
// CreatedAt and UpdatedAt may be empty, in which case they
// will be set to "now" in the database.
AddUser(ctx context.Context, user *User) error
// DeleteUser deletes a user from the users database.
DeleteUser(ctx context.Context, email string) error
// Locates a user that has the given verification token.
// If the token is not expired, the user's account status
// is set to `active`.
VerifyUser(ctx context.Context, verificationToken string) error
}
Click to show internal directories.
Click to hide internal directories.