config

package
v0.0.0-...-3a65669 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2015 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package config allows for reading configuration from a JSON file

Index

Constants

This section is empty.

Variables

View Source
var ErrDBBadDriver = errors.New("missing or invalid database driver")

ErrDBBadDriver is for bad or missing database driver in the config

View Source
var ErrDBBadPort = errors.New("missing or invalid database port")

ErrDBBadPort is for a bad or missing database port in the config

View Source
var ErrDBNoDatabase = errors.New("missing database")

ErrDBNoDatabase is for missing a database in the config

View Source
var ErrDBNoHost = errors.New("missing database host")

ErrDBNoHost is for a missing database host in the config

View Source
var ErrDBNoUsername = errors.New("missing database username")

ErrDBNoUsername is for a missing username in the config

View Source
var ErrMetricsBadStatsdAddress = errors.New("invalid address for statsd")

ErrMetricsBadStatsdAddress is for a bad statsd address in the config

View Source
var ErrMetricsNoServiceName = errors.New("missing service name")

ErrMetricsNoServiceName is for a missing service name in the config

Functions

func Load

func Load(path string) error

Load parses a JSON config file

Types

type Config

type Config struct {
	DB      DB                           `json:"db"`
	Metrics Metrics                      `json:"metrics"`
	Mistify map[string]map[string]string `json:"mistify"`
}

Config struct holds data from a JSON config file

func Get

func Get() *Config

Get returns the configuration data and dies if the config is not loaded

type DB

type DB struct {
	Driver   string `json:"driver"`
	Database string `json:"database"`
	Username string `json:"username"`
	Password string `json:"password"`
	Host     string `json:"host"`
	Port     uint   `json:"port"`
}

DB is the JSON structure and validation for database configuration

func (*DB) DataSourceName

func (db *DB) DataSourceName() string

DataSourceName generates the dsn for connecting to the database from the configured values

func (*DB) Validate

func (db *DB) Validate() error

Validate ensures that the database configuration is reasonable

type Metrics

type Metrics struct {
	ServiceName   string `json:"service_name"`
	StatsdAddress string `json:"statsd_address"`
}

Metrics is the JSON structure and validation for metrics configuration

func (*Metrics) Validate

func (m *Metrics) Validate() error

Validate ensures that the metrics configuration is reasonable

Jump to

Keyboard shortcuts

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