config

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ConfigPath is "config.toml" by default
	ConfigPath = "config.toml"
)

Functions

func CreateDefault

func CreateDefault() (err error)

CreateDefault -> create default config

func FromEnv

func FromEnv(cfg *Config) (err []error)

FromEnv -> Please correct this function taken from r/programminghorror

Types

type BBoltConfig

type BBoltConfig struct {
	Path                  string      `env:"BBOLT_PATH"`
	FileMode              os.FileMode `env:"BBOLT_FILE_MODE"`
	ShortedURLsBucketName string      `env:"BBOLT_BUCKET_SHORT_URLS"`
}

BBoltConfig -> Config for BBolt implementation

type BackendConfig

type BackendConfig struct {
	PersistentBackend string `env:"PERSISTENT_BACKEND"`
	StatsBackend      string `env:"STATS_BACKEND"`
	PubSubBackend     string `env:"PUBSUB_BACKEND"`
	CacheBackend      string `env:"CACHE_BACKEND"`
}

type BlockedHosts

type BlockedHosts struct {
	Hosts []string
}

BlockedHosts ...

func (*BlockedHosts) Set

func (b *BlockedHosts) Set(val string) error

Set -> Set BlockedHosts.Hosts from a string

type Config

type Config struct {
	DryRedirect             bool          `env:"DRY_REDIRECT"`
	BlockedHosts            *BlockedHosts `env:"BLOCKED_HOSTS"`
	ExpirationCheckInterval duration      `env:"EXPIRATION_CHECK_INTERVAL"`
	ExpirationDryRun        bool          `env:"EXPIRATION_DRY_RUN"`
	Backends                *BackendConfig
	Database                *DatabaseConfig
	WebServer               *WebServerConfig
}

Config -> Config for Database implementations

func LoadConfig

func LoadConfig() *Config

LoadConfig loads a config if the config exists, otherwise creates a default config

type DatabaseConfig

type DatabaseConfig struct {
	Mongo *MongoConfig
	Redis *RedisConfig
	BBolt *BBoltConfig
	Maria *MariaConfig
}

DatabaseConfig -> Config for PersistentDatabase implementations

type MariaConfig

type MariaConfig struct {
	Addr        string `env:"MARIA_ADDR"`
	User        string `env:"MARIA_USER"`
	Password    string `env:"MARIA_PASS"`
	DBName      string `env:"MARIA_DATABASE"`
	TablePrefix string `env:"MARIA_TABLE_PREFIX"`
}

MariaConfig -> Config for Maria Imlementation

type MongoConfig

type MongoConfig struct {
	ApplyURI           string `env:"MDB_APPLY_URI"`
	Database           string `env:"MDB_DATABASE"`
	ShortURLCollection string `env:"MDB_COLLECTION_SHORT_URLS"`
	MetaCollection     string `env:"MDB_COLLECTION_META"`
}

MongoConfig -> Config for MongoDB implementation

type RedisConfig

type RedisConfig struct {
	Addr     string `env:"REDIS_ADDR"`
	Password string `env:"REDIS_PASS"`
	DB       int    `env:"REDIS_DATABASE"`
}

RedisConfig -> Config for Redis implementation

type WebServerConfig

type WebServerConfig struct {
	Addr string `env:"WEB_ADDR"`
}

WebServerConfig -> Config for web.WebServer

Jump to

Keyboard shortcuts

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