config

package
v0.0.0-...-942df37 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FileStorage is the static configuration string for file storage
	FileStorage string = "file"

	// DBStorage is the static configuration string for database storage
	DBStorage string = "db"

	// DefaultPort is the default server port
	DefaultPort string = "8080"

	// DefaultEvalString is the default evaluation time as a string
	DefaultEvalString string = "5m"

	// DefaultEvalDuration is the default evaulation time as a Duration
	DefaultEvalDuration time.Duration = time.Minute * 5
)

Variables

View Source
var DefaultConfig = Config{
	FileConfig: FileConfig{
		Directory: os.TempDir() + "/deadline",
	},
	Server: ServerConfig{
		Port: DefaultPort,
	},
	EvalTime: DefaultEvalString,
	Storage:  FileStorage,

	Logconfig: make(map[string]string),
	// contains filtered or unexported fields
}

DefaultConfig is the default configuration

Functions

This section is empty.

Types

type Config

type Config struct {
	FileConfig  FileConfig        `yaml:"file_config"`
	DBConfig    DBConfig          `yaml:"db_config"`
	Storage     string            `yaml:"storage"`
	EvalTime    string            `yaml:"eval_timing"`
	Server      ServerConfig      `yaml:"server_config"`
	EmailConfig EmailConfig       `yaml:"email_config"`
	Logconfig   map[string]string `yaml:"logs"`
	// contains filtered or unexported fields
}

Config represents the configuration struct for the entire deadline application

func GetConfig

func GetConfig() *Config

GetConfig will return a global instance of the configuration if it has ever been loaded through LoadConfig. It can also return the default config if LoadConfig has never been called.

func LoadConfig

func LoadConfig(filename string) (*Config, error)

LoadConfig loads the configuration based on the input file. Errors can occur for various i/o or marshalling related reasons. Defaults will be returned for primitive types, like strings.

func (*Config) GetEvalTime

func (c *Config) GetEvalTime() time.Duration

GetEvalTime is a simple facade for getting the configuration's EvalTime while parsing and checking for errors.

func (*Config) GetLogger

func (c *Config) GetLogger(name string) *logrus.Logger

GetLogger gets a logger for a particular package or sub-component. Thread safe, but currently locks pretty aggressively, so one should only call at the package/sub-component level, not like, per function call.

type DBConfig

type DBConfig struct {
	ConnectionString string `yaml:"connection_string"`
}

DBConfig is the configuration type for relational database storage

type EmailConfig

type EmailConfig struct {
	From      string `yaml:"from"`
	RelayHost string `yaml:"relay_host"`
	RelayPort int    `yaml:"relay_port"`
}

EmailConfig is the configuration type for handlers that email

func GetEmailConfig

func GetEmailConfig() *EmailConfig

GetEmailConfig will the EmailConfig portion of the global config object.

type FileConfig

type FileConfig struct {
	Directory string `yaml:"directory"`
}

FileConfig is the configuration type for file storage

type HandlerConfig

type HandlerConfig struct {
	EmailConfig EmailConfig `yaml:"emailconfig"`
}

HandlerConfig is the configuration type for handlers

type ServerConfig

type ServerConfig struct {
	Port string `yaml:"port"`
}

ServerConfig is the configuration type for the deadline server

Jump to

Keyboard shortcuts

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