Documentation
¶
Index ¶
- func IsNameExists(err error) bool
- func IsNotFound(err error) bool
- type ErrNameExists
- type ErrNotFound
- type PostgresRepository
- func (r *PostgresRepository) Close(ctx context.Context) error
- func (r *PostgresRepository) CountCharacters(ctx context.Context, userID string) (int, error)
- func (r *PostgresRepository) CreateCharacter(ctx context.Context, userID string, name string) (*models.Character, error)
- func (r *PostgresRepository) CreateUser(ctx context.Context, userID string) (*models.User, error)
- func (r *PostgresRepository) DeleteCharacter(ctx context.Context, userID string, characterID int32) error
- func (r *PostgresRepository) GetCharacter(ctx context.Context, userID string, characterID int32) (*models.Character, error)
- func (r *PostgresRepository) ListCharacters(ctx context.Context, userID string) ([]*models.Character, error)
- func (r *PostgresRepository) LoadPlayerState(ctx context.Context, characterID int32) (*gametypes.PlayerState, error)
- func (r *PostgresRepository) NameExists(ctx context.Context, name string) (bool, error)
- func (r *PostgresRepository) SaveGameState(ctx context.Context, gameState *gametypes.GameState) error
- func (r *PostgresRepository) SavePlayerState(ctx context.Context, timestamp int64, characterID int32, ...) error
- type Repository
- type SQLiteRepository
- func (r *SQLiteRepository) Close(ctx context.Context) error
- func (r *SQLiteRepository) CountCharacters(ctx context.Context, userID string) (int, error)
- func (r *SQLiteRepository) CreateCharacter(ctx context.Context, userID string, name string) (*models.Character, error)
- func (r *SQLiteRepository) CreateUser(ctx context.Context, userID string) (*models.User, error)
- func (r *SQLiteRepository) DeleteCharacter(ctx context.Context, userID string, characterID int32) error
- func (r *SQLiteRepository) GetCharacter(ctx context.Context, userID string, characterID int32) (*models.Character, error)
- func (r *SQLiteRepository) ListCharacters(ctx context.Context, userID string) ([]*models.Character, error)
- func (r *SQLiteRepository) LoadPlayerState(ctx context.Context, characterID int32) (*gametypes.PlayerState, error)
- func (r *SQLiteRepository) NameExists(ctx context.Context, name string) (bool, error)
- func (r *SQLiteRepository) SaveGameState(ctx context.Context, gameState *gametypes.GameState) error
- func (r *SQLiteRepository) SavePlayerState(ctx context.Context, timestamp int64, characterID int32, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsNameExists ¶
func IsNotFound ¶
Types ¶
type ErrNameExists ¶
type ErrNameExists struct { }
func (*ErrNameExists) Error ¶
func (e *ErrNameExists) Error() string
type ErrNotFound ¶
type ErrNotFound struct { }
func (*ErrNotFound) Error ¶
func (e *ErrNotFound) Error() string
type PostgresRepository ¶
type PostgresRepository struct {
// contains filtered or unexported fields
}
func (*PostgresRepository) CountCharacters ¶
func (*PostgresRepository) CreateCharacter ¶
func (*PostgresRepository) CreateUser ¶
func (*PostgresRepository) DeleteCharacter ¶
func (*PostgresRepository) GetCharacter ¶
func (*PostgresRepository) ListCharacters ¶
func (*PostgresRepository) LoadPlayerState ¶
func (r *PostgresRepository) LoadPlayerState(ctx context.Context, characterID int32) (*gametypes.PlayerState, error)
func (*PostgresRepository) NameExists ¶
func (*PostgresRepository) SaveGameState ¶
func (*PostgresRepository) SavePlayerState ¶
func (r *PostgresRepository) SavePlayerState(ctx context.Context, timestamp int64, characterID int32, playerState *gametypes.PlayerState) error
type Repository ¶
type Repository interface { Close(ctx context.Context) error CreateUser(ctx context.Context, userID string) (*models.User, error) ListCharacters(ctx context.Context, userID string) ([]*models.Character, error) CountCharacters(ctx context.Context, userID string) (int, error) GetCharacter(ctx context.Context, userID string, characterID int32) (*models.Character, error) CreateCharacter(ctx context.Context, userID string, name string) (*models.Character, error) DeleteCharacter(ctx context.Context, userID string, characterID int32) error NameExists(ctx context.Context, name string) (bool, error) SaveGameState(ctx context.Context, gameState *gametypes.GameState) error SavePlayerState(ctx context.Context, timestamp int64, characterID int32, playerState *gametypes.PlayerState) error LoadPlayerState(ctx context.Context, characterID int32) (*gametypes.PlayerState, error) }
func NewPostgresRepository ¶
func NewPostgresRepository(ctx context.Context, connStr string) (Repository, error)
NewPostgresRepository creates a new PSQLRepository. It panics if it is unable to connect to the database after 2 minutes. The caller is responsible for calling Close() on the repository.
func NewSQLiteRepository ¶
type SQLiteRepository ¶
type SQLiteRepository struct {
// contains filtered or unexported fields
}
func (*SQLiteRepository) CountCharacters ¶
func (*SQLiteRepository) CreateCharacter ¶
func (*SQLiteRepository) CreateUser ¶
func (*SQLiteRepository) DeleteCharacter ¶
func (*SQLiteRepository) GetCharacter ¶
func (*SQLiteRepository) ListCharacters ¶
func (*SQLiteRepository) LoadPlayerState ¶
func (r *SQLiteRepository) LoadPlayerState(ctx context.Context, characterID int32) (*gametypes.PlayerState, error)
func (*SQLiteRepository) NameExists ¶
func (*SQLiteRepository) SaveGameState ¶
func (*SQLiteRepository) SavePlayerState ¶
func (r *SQLiteRepository) SavePlayerState(ctx context.Context, timestamp int64, characterID int32, playerState *gametypes.PlayerState) error
Click to show internal directories.
Click to hide internal directories.