config

package
v0.0.0-...-7c1bd43 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Production bool         `envconfig:"SCIMFE_PRODUCTION" default:"false" yaml:"production"`
	Server     ServerConfig `yaml:"server"`
	DB         Database     `yaml:"db"`
	Redis      Redis        `yaml:"redis"`
}

func FromEnv

func FromEnv() (*Config, error)

func FromFile

func FromFile(cfgPath string) (*Config, error)

type Database

type Database struct {
	Address             string `envconfig:"SCIMFE_DB_ADDRESS" default:"postgres://localhost:5432/scimfe" yaml:"address"`
	MigrationsDirectory string `envconfig:"SCIMFE_MIGRATIONS_DIR" default:"deployments/db/migrations" yaml:"migrations_dir"`
	VersionTable        string `envconfig:"SCIMFE_VERSION_TABLE" default:"schema_migrations" yaml:"version_table"`
	SchemaVersion       uint   `envconfig:"SCIMFE_SCHEMA_VERSION" yaml:"schema_version"`
	SkipMigration       bool   `envconfig:"SCIMFE_NO_MIGRATION" yaml:"skip_migration"`
}

func (Database) PoolConfig

func (dbs Database) PoolConfig() (*pgxpool.Config, error)

type Duration

type Duration struct {
	time.Duration
}

Duration is deserializable wrapper around time.Duration

func NewDuration

func NewDuration(d time.Duration) Duration

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(src []byte) (err error)

UnmarshalText implements encoding.TextUnmarshaler

type Redis

type Redis struct {
	DB       int    `envconfig:"SCIMFE_REDIS_DB" yaml:"db"`
	Address  string `envconfig:"SCIMFE_REDIS_ADDRESS" yaml:"address" default:"localhost:6379"`
	Username string `envconfig:"SCIMFE_REDIS_USER" yaml:"username"`
	Password string `envconfig:"SCIMFE_REDIS_PASSWORD" yaml:"password"`
}

func (Redis) RedisOptions

func (r Redis) RedisOptions() *redis.Options

RedisOptions returns redis connection options

type ServerConfig

type ServerConfig struct {
	ListenAddress              string   `envconfig:"SCIMFE_LISTEN_ADDR" default:":8080" yaml:"listen"`
	ReadTimeout                Duration `envconfig:"SCIMFE_READ_TIMEOUT" yaml:"read_timeout"`
	WriteTimeout               Duration `envconfig:"SCIMFE_WRITE_TIMEOUT" yaml:"write_timeout"`
	TokenBucketTTL             Duration `envconfig:"SCIMFE_TOKEN_BUCKET_TTL" yaml:"token_bucket_ttl"`
	UserRequestsPerSecondLimit float64  `envconfig:"SCIMFE_USER_RPS_LIMIT" yaml:"user_rps_limit"`
}

func (ServerConfig) ListenParams

func (cfg ServerConfig) ListenParams() web.ListenParams

Jump to

Keyboard shortcuts

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