config

package
v0.0.0-...-6b2a69b Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2020 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	Server            *Server  `environment:"SERVER"`
	AccountsStore     *Storage `environment:"ACCOUNTS_STORE"`
	ArgumentsStore    *Storage `environment:"ARGUMENTS_STORE"`
	Hash              *Hash    `environment:"HASH"`
	JwtPrivateKeyPath string   `environment:"JWT_PRIVATE_KEY_PATH"`
}

Configuration stores all the application config.

func Defaults

func Defaults() Configuration

Defaults returns a Configuration with all the default options. This ignores environment variable values.

func MustParse

func MustParse() Configuration

MustParse wraps Parse, but prints the errors and exits rather than returning them.

func Parse

func Parse() (Configuration, error)

Parse loads the app config using Viper. It logs all the values before returning, and panics on validation errors.

func (*Configuration) JwtPrivateKey

func (cfg *Configuration) JwtPrivateKey() *ecdsa.PrivateKey

JwtPrivateKey returns the PrivateKey object from the file at the given path. This is used to sign JWTs. Panic if the file doesn't exist, can't be read, or didn't have a valid private key.

type Hash

type Hash struct {
	Time        uint32 `environment:"ITERATIONS"`
	Memory      uint32 `environment:"MEMORY_BYTES"`
	Parallelism uint8  `environment:"PARALLELISM"`
	SaltLength  uint8  `environment:"SALT_LENGTH"`
	KeyLength   uint32 `environment:"KEY_LENGTH"`
}

Hash configures the hashing algorithm used to store passwords. This project hashes with Argon2: https://www.alexedwards.net/blog/how-to-hash-and-verify-passwords-with-argon2-in-go

type Postgres

type Postgres struct {
	Database string `environment:"DBNAME"`
	Host     string `environment:"HOST"`
	Port     uint16 `environment:"PORT"`
	User     string `environment:"USER"`
	Password string `environment:"PASSWORD"`
}

Postgres configures the Postgres connection

type Server

type Server struct {
	Addr                    string   `environment:"ADDR"`
	ReadHeaderTimeoutMillis int      `environment:"READ_HEADER_TIMEOUT_MILLIS"`
	CorsAllowedOrigins      []string `environment:"CORS_ALLOWED_ORIGINS"`
	UseSSL                  bool     `environment:"USE_SSL"`
	CertPath                string   `environment:"CERT_PATH"`
	KeyPath                 string   `environment:"KEY_PATH"`
}

Server has all the config values which affect the http.Server which responds to requests.

func (*Server) ReadHeaderTimeout

func (cfg *Server) ReadHeaderTimeout() time.Duration

ReadHeaderTimeout returns the time the server will wait for the client to send the HTTP headers before it just times out the request.

type Storage

type Storage struct {
	Type     StorageType `environment:"TYPE"`
	Postgres *Postgres   `environment:"POSTGRES"`
}

Storage has all the config values related to the backend which is used to save arguments.

type StorageType

type StorageType string

StorageType determines how the service stores its arguments.

const (
	// StorageTypeMemory is used to save arguments unbounded, in-memory data store.
	// This is mainly intended to make development simpler, so that programmers
	// don't need to set up an actual postgres instance locally.
	StorageTypeMemory StorageType = "memory"
	// StorageTypePostgres is used to save arguments in a postgres instance.
	// If this is used, you'll need a working postgres instance to save arguments.
	StorageTypePostgres StorageType = "postgres"
)

Jump to

Keyboard shortcuts

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