config

package
v0.0.0-...-02e5558 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2017 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrEmptyDBUserOrPassword represents the 'user' or 'password' empty error
	ErrEmptyDBUserOrPassword = errors.New("database 'User' or 'Password' should not be empty")
	// ErrEmptyDBName represents the 'name' empty error
	ErrEmptyDBName = errors.New("database 'Name' should not be empty")
	// ErrEmptyDBServer represents the 'database server' empty error
	ErrEmptyDBServer = errors.New("database 'Server' should not be empty")

	// ErrNonStorageBackend represents the 'storage backend' empty error
	ErrNonStorageBackend = errors.New("at least one storage backend required")
	// ErrNonSessionBackend represents the 'session backend' empty error
	ErrNonSessionBackend = errors.New("at least one session backend required")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// Port is the server listen port
	Port int64 `yaml:"port"`
	// Log defines the log config group
	// The log validation will be checked in the log init part.
	Log LogConfig `yaml:"log,omitempty"`
	// StorageLoad
	// 'dynamic' or 'static'
	// static: load at the first time
	// dynamic: load every time, most time because of multiple tenant using their own token/ak-sk
	// TODO: should have 'default' value
	StorageLoad string `yaml:"storageload,omitempty"`
	// Storage defines the storage config group
	Storage StorageConfig `yaml:"storage"`
	// DB defines the db config group
	DB DBConfig `yaml:"db"`
	// Session defines the session config group
	Session SessionConfig `yaml:"session"`
}

Config defines the config items

func GetConfig

func GetConfig() Config

GetConfig returns the current system config setting

func InitConfigFromFile

func InitConfigFromFile(path string) (Config, error)

InitConfigFromFile loads the config from a file

func (*Config) Valid

func (cfg *Config) Valid() error

Valid checks if a config is logical

type DBConfig

type DBConfig struct {
	Driver   string `yaml:"driver"`
	User     string `yaml:"user"`
	Password string `yaml:"password"`
	Server   string `yaml:"server"`
	Name     string `yaml:"name"`
}

DBConfig defines the db configs

func (*DBConfig) GetConnection

func (cfg *DBConfig) GetConnection() (string, error)

GetConnection returns the sql recognizable connection string

func (*DBConfig) Valid

func (cfg *DBConfig) Valid() error

Valid checks the db config validation

type LogConfig

type LogConfig map[string](map[string]interface{})

LogConfig stores the log config item group

type SessionConfig

type SessionConfig map[string](map[string]interface{})

SessionConfig stores the session config item group

func (*SessionConfig) Valid

func (cfg *SessionConfig) Valid() error

Valid checks the session config validation

type StorageConfig

type StorageConfig map[string](map[string]interface{})

StorageConfig stores the storage config item group

func (*StorageConfig) Valid

func (cfg *StorageConfig) Valid() error

Valid checks the storage config validation

Jump to

Keyboard shortcuts

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