Documentation ¶
Index ¶
- Variables
- func DecodeAES256Base64(aes256KeyBase64 string) ([32]byte, error)
- func New(ctx context.Context, config Config) (storage.Storage, *pgxpool.Pool, error)
- func NewWithSetup(ctx context.Context, config Config, setupLogger *slog.Logger) (storage.Storage, *pgxpool.Pool, error)
- type Config
- type Migrator
- type MigratorOptions
- type Setup
- type Transaction
Constants ¶
This section is empty.
Variables ¶
var ( // ErrPostgresSetupCheck is the error returned when the Postgres setup check fails. ErrPostgresSetupCheck = errors.New("failed to perform Postgres setup check") )
var ( // ErrSemVer indicates a semver is invalid. ErrSemVer = errors.New("invalid semver") )
Functions ¶
func DecodeAES256Base64 ¶
DecodeAES256Base64 decodes a Base64 encoded AES256 key.
Types ¶
type Config ¶
type Config struct { AES256KeyBase64 string `json:"aes256KeyBase64"` AutoMigrate bool `json:"autoMigrate"` DSN string `json:"dsn"` Health *jt.JSONType[time.Duration] `json:"health"` InitialTimeout *jt.JSONType[time.Duration] `json:"initialTimeout"` MaxIdle *jt.JSONType[time.Duration] `json:"maxIdle"` MinConns int32 `json:"minConns"` PlaintextClaims bool `json:"plaintextClaims"` PlaintextJWK bool `json:"plaintextJWK"` }
Config is the configuration for Postgres storage.
func (Config) DefaultsAndValidate ¶
DefaultsAndValidate implements the jsontype.Config interface.
type Migrator ¶
type Migrator interface { // Migrate applies all migrations in order. It will automatically skip migrations that have . Migrate(ctx context.Context) error }
Migrator is the interface for applying migrations.
Migrator only migrates in the forward direction. It does not support rolling back migrations. Ensure you have quick and robust database backup and restore procedure before running migrations.
No other program should interact with the database while the Migrator is running.
No Migrator implementation should depend on code elsewhere in this project.
func NewMigrator ¶
func NewMigrator(pool *pgxpool.Pool, options MigratorOptions) (Migrator, error)
NewMigrator returns a new Migrator for a Postgres storage implementation.
type MigratorOptions ¶
MigratorOptions are options for creating a Migrator.
type Setup ¶
type Setup struct { PlaintextClaims bool `json:"plaintextClaims,omitempty"` PlaintextJWK bool `json:"plaintextJWK,omitempty"` SemVer string `json:"semver,omitempty"` // https://pkg.go.dev/golang.org/x/mod/semver }
Setup is the JSON data that sits in the setup table.
type Transaction ¶
type Transaction struct {
Tx pgx.Tx
}
Transaction is a storage.Tx implementation for Postgres.