Documentation ¶
Index ¶
- Variables
- type APIKeyRepository
- func (repo *APIKeyRepository) Create(ctx context.Context, create *apikey.Create) (*apikey.Key, string, error)
- func (repo *APIKeyRepository) Delete(ctx context.Context, id uuid.UUID) error
- func (repo *APIKeyRepository) Get(ctx context.Context, offset, limit uint64) ([]*apikey.Key, uint64, error)
- func (repo *APIKeyRepository) GetByID(ctx context.Context, id uuid.UUID) (*apikey.Key, error)
- func (repo *APIKeyRepository) GetByRawKey(ctx context.Context, key string) (*apikey.Key, error)
- func (repo *APIKeyRepository) GetByUserID(ctx context.Context, userID string, offset, limit uint64) ([]*apikey.Key, uint64, error)
- func (repo *APIKeyRepository) Update(ctx context.Context, id uuid.UUID, update *apikey.Update) (*apikey.Key, error)
- func (repo *APIKeyRepository) UpdateManyQuotas(ctx context.Context, updates map[uuid.UUID]int64) error
- type Driver
- type METARRepository
- func (repo *METARRepository) Create(ctx context.Context, raw []string) ([]*metar.METAR, []uint, error)
- func (repo *METARRepository) Delete(ctx context.Context, id uuid.UUID) error
- func (repo *METARRepository) GetByFilter(ctx context.Context, filter *metar.Filter, limit uint64) ([]*metar.METAR, uint64, error)
- func (repo *METARRepository) GetByID(ctx context.Context, id uuid.UUID) (*metar.METAR, error)
- type UserRepository
- func (repo *UserRepository) Create(ctx context.Context, create *user.Create) (*user.User, error)
- func (repo *UserRepository) Delete(ctx context.Context, id string) error
- func (repo *UserRepository) Get(ctx context.Context, offset, limit uint64) ([]*user.User, uint64, error)
- func (repo *UserRepository) GetByID(ctx context.Context, id string) (*user.User, error)
- func (repo *UserRepository) Update(ctx context.Context, id string, update *user.Update) (*user.User, error)
Constants ¶
This section is empty.
Variables ¶
var (
ErrMissingAPIKeyPolicy = errors.New("an initial API key policy is required")
)
Functions ¶
This section is empty.
Types ¶
type APIKeyRepository ¶
type APIKeyRepository struct {
// contains filtered or unexported fields
}
APIKeyRepository implements the apikey.Repository interface using PostgreSQL
func (*APIKeyRepository) Create ¶
func (repo *APIKeyRepository) Create(ctx context.Context, create *apikey.Create) (*apikey.Key, string, error)
Create creates a new API key
func (*APIKeyRepository) Get ¶
func (repo *APIKeyRepository) Get(ctx context.Context, offset, limit uint64) ([]*apikey.Key, uint64, error)
Get retrieves multiple API keys
func (*APIKeyRepository) GetByRawKey ¶
GetByRawKey retrieves an API key by the raw bearer token
func (*APIKeyRepository) GetByUserID ¶
func (repo *APIKeyRepository) GetByUserID(ctx context.Context, userID string, offset, limit uint64) ([]*apikey.Key, uint64, error)
GetByUserID retrieves multiple API keys of a specific user
func (*APIKeyRepository) Update ¶
func (repo *APIKeyRepository) Update(ctx context.Context, id uuid.UUID, update *apikey.Update) (*apikey.Key, error)
Update updates an API key
func (*APIKeyRepository) UpdateManyQuotas ¶
func (repo *APIKeyRepository) UpdateManyQuotas(ctx context.Context, updates map[uuid.UUID]int64) error
UpdateManyQuotas updates many used API quotas at once
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver represents the PostgreSQL storage driver implementation
func New ¶
New creates a new empty PostgreSQL storage driver. User Initialize to open the database connection and initialize the repository implementations.
func (*Driver) APIKeys ¶
func (driver *Driver) APIKeys() apikey.Repository
APIKeys provides the PostgreSQL API key repository implementation
func (*Driver) Close ¶
func (driver *Driver) Close()
Close discards the repository implementations and closes the database connection
func (*Driver) Initialize ¶
Initialize opens the database connection, migrates the database and initializes the repository implementations
func (*Driver) METARs ¶
func (driver *Driver) METARs() metar.Repository
METARs provides the PostgreSQL METAR repository implementation
func (*Driver) Users ¶
func (driver *Driver) Users() user.Repository
Users provides the PostgreSQL user repository implementation
type METARRepository ¶
type METARRepository struct {
// contains filtered or unexported fields
}
METARRepository implements the metar.Repository interface using PostgreSQL
func (*METARRepository) Create ¶
func (repo *METARRepository) Create(ctx context.Context, raw []string) ([]*metar.METAR, []uint, error)
Create creates new METARs based on their raw text representation. All raw strings are sanitized (leading and trailing spaces are trimmed). This method also returns the indexes of the METARs that already exist in the database and thus were not inserted.
func (*METARRepository) GetByFilter ¶
func (repo *METARRepository) GetByFilter(ctx context.Context, filter *metar.Filter, limit uint64) ([]*metar.METAR, uint64, error)
GetByFilter retrieves multiple METARs following a filter, ordered by their issuing date (descending). If limit <= 0, a default limit value of 10 is used.
type UserRepository ¶
type UserRepository struct {
// contains filtered or unexported fields
}
UserRepository implements the user.Repository interface using PostgreSQL
func (*UserRepository) Delete ¶
func (repo *UserRepository) Delete(ctx context.Context, id string) error
Delete deletes a user by their ID
func (*UserRepository) Get ¶
func (repo *UserRepository) Get(ctx context.Context, offset, limit uint64) ([]*user.User, uint64, error)
Get retrieves multiple users