conf

package
v0.0.0-...-646d846 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2022 License: Unlicense Imports: 8 Imported by: 0

Documentation

Overview

Package conf holds all of the configuration for the application: e.g. database connection strings, port to listen on, external credentials, environment. By locating all configuration in one place, it's easy to see all parameters at a glance. This approach implies that no other packages should access environment variables directly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Addr                string        `env:"ADDR" envDefault:":4000"`                       // Server listen address
	DatabaseConnTimeout time.Duration `env:"DATABASE_CONN_TIMEOUT" envDefault:"10s"`        // Postgres connection timeout
	DatabaseMaxConn     int32         `env:"DATABASE_MAX_CONN" envDefault:"10"`             // Postgres connection pool limit
	DatabaseURL         string        `env:"DATABASE_URL"`                                  // Postgres connection string
	Debug               bool          `env:"DEBUG"`                                         // Enable debug mode
	MaxSessionDuration  time.Duration `env:"MAX_SESSION_DURATION" envDefault:"24h"`         // The maximum duration of a login session.
	RedisMaxActive      int           `env:"REDIS_MAX_ACTIVE" envDefault:"5"`               // Max active redis pool connections
	RedisMaxIdle        int           `env:"REDIS_MAX_IDLE" envDefault:"5"`                 // Maximum idle redis pool connections
	RedisURL            string        `env:"REDIS_URL" envDefault:"redis://127.0.0.1:6379"` // Redis connection string
	SuppressLogging     bool          `env:"SUPPRESS_LOGGING"`                              // Suppress logging, useful for testing
}

Config is the configuration needed to bootstrap the application's dependencies.

func Load

func Load() (*Config, error)

Load loads the application configuration from command line flags and environment variables.

type Dependencies

type Dependencies struct {
	Database  *pgxpool.Pool
	RedisPool *redis.Pool
	Sessions  *session.Service
}

Dependencies are the resolved dependencies.

func Resolve

func Resolve(ctx context.Context, c *Config) (*Dependencies, error)

Resolve resolves the application dependencies using its config.

Jump to

Keyboard shortcuts

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