config

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2016 License: MPL-2.0 Imports: 10 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cnf = &Config{
	Database: DatabaseConfig{
		Type:         "postgres",
		Host:         "localhost",
		Port:         5432,
		User:         "example_api",
		Password:     "",
		DatabaseName: "example_api",
		MaxIdleConns: 5,
		MaxOpenConns: 5,
	},
	Oauth: OauthConfig{
		AccessTokenLifetime:  3600,
		RefreshTokenLifetime: 1209600,
		AuthCodeLifetime:     3600,
	},
	Facebook: FacebookConfig{
		AppID:     "facebook_app_id",
		AppSecret: "facebook_app_secret",
	},
	Sendgrid: SendgridConfig{
		APIKey: "sendgrid_api_key",
	},
	Web: WebConfig{
		Scheme:    "http",
		Host:      "localhost:8080",
		AppScheme: "http",
		AppHost:   "localhost:8000",
	},
	AppSpecific: AppSpecificConfig{
		PasswordResetLifetime: 604800,
		CompanyName:           "Your Company",
		CompanyNoreplyEmail:   "noreply@example.com",
	},
	IsDevelopment: true,
}

Cnf ... Let's start with some sensible defaults

Functions

func RefreshConfig

func RefreshConfig(newCnf *Config)

RefreshConfig sets config through the pointer so config actually gets refreshed

Types

type AppSpecificConfig

type AppSpecificConfig struct {
	PasswordResetLifetime int
	CompanyName           string
	CompanyNoreplyEmail   string
}

AppSpecificConfig stores app specific config

type Config

type Config struct {
	Database      DatabaseConfig
	Oauth         OauthConfig
	Facebook      FacebookConfig
	Sendgrid      SendgridConfig
	Web           WebConfig
	AppSpecific   AppSpecificConfig
	IsDevelopment bool
}

Config stores all configuration options

func LoadConfig

func LoadConfig(kapi client.KeysAPI) (*Config, error)

LoadConfig gets the JSON from ETCD and unmarshals it to the config object

func NewConfig

func NewConfig(mustLoadOnce bool, keepReloading bool) *Config

NewConfig loads configuration from etcd and returns *Config struct It also starts a goroutine in the background to keep config up-to-date

type DatabaseConfig

type DatabaseConfig struct {
	Type         string
	Host         string
	Port         int
	User         string
	Password     string
	DatabaseName string
	MaxIdleConns int
	MaxOpenConns int
}

DatabaseConfig stores database connection options

type FacebookConfig

type FacebookConfig struct {
	AppID     string
	AppSecret string
}

FacebookConfig stores Facebook app config

type OauthConfig

type OauthConfig struct {
	AccessTokenLifetime  int
	RefreshTokenLifetime int
	AuthCodeLifetime     int
}

OauthConfig stores oauth service configuration options

type SendgridConfig

type SendgridConfig struct {
	APIKey string
}

SendgridConfig stores sengrid configuration options

type WebConfig

type WebConfig struct {
	Scheme    string
	Host      string
	AppScheme string
	AppHost   string
}

WebConfig stores web related config like scheme and host

Jump to

Keyboard shortcuts

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