conf

package
v0.0.0-...-b5a4b96 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2016 License: LGPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package conf implements configuration read methods.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContext

func NewContext(c *Config) context.Context

NewContext returns a new Context carrying Config.

Types

type Config

type Config struct {
	Domain   domain   `json:"domain"`
	Listener listener `json:"listener"`
	Settings settings `json:"settings"`
	Db       MongoCfg `json:"database"`
	Cache    cache    `json:"cache"`
	Debug    bool     `json:"debug"`
	Conn     *Conn
	GeoDB    *geoip2.Reader
	L        Logger
}

Config is main configuration storage.

func FromContext

func FromContext(ctx context.Context) (*Config, error)

FromContext extracts the Config from Context.

func Parse

func Parse(name string) (*Config, error)

Parse reads a configuration file and returns a pointer to prepared Config structure.

func (*Config) Address

func (c *Config) Address(uri string) string

Address returns a full URL address.

func (*Config) CacheTpl

func (c *Config) CacheTpl(key string, tpls ...string) (*template.Template, error)

CacheTpl return HTML template from file, but first tries to find it in the LRU cache.

func (*Config) Close

func (c *Config) Close()

Close releases configuration resources.

func (*Config) StaticDir

func (c *Config) StaticDir() (string, error)

StaticDir returns a path of static files

func (*Config) Validate

func (c *Config) Validate() error

Validate validates configuration settings.

type Conn

type Conn struct {
	S   *mgo.Session
	M   sync.Mutex
	Cfg *MongoCfg
}

Conn is database connection structure.

func (*Conn) Close

func (c *Conn) Close()

Close closes main database connection.

type Logger

type Logger struct {
	Debug *log.Logger
	Info  *log.Logger
	Error *log.Logger
}

Logger is common logger structure.

type MongoCfg

type MongoCfg struct {
	Hosts      []string `json:"hosts"`
	Port       uint     `json:"port"`
	Timeout    uint     `json:"timeout"`
	Username   string   `json:"username"`
	Password   string   `json:"password"`
	Database   string   `json:"database"`
	AuthDB     string   `json:"authdb"`
	ReplicaSet string   `json:"replica"`
	Ssl        bool     `json:"ssl"`
	SslKeyFile string   `json:"sslkeyfile"`
	Reconnects int      `json:"reconnects"`
	RcnTime    int64    `json:"rcntime"`
	PoolLimit  int      `json:"poollimit"`
	Debug      bool     `json:"debug"`
	MongoCred  *mgo.DialInfo
	Logger     *log.Logger
}

MongoCfg is database configuration settings

func (*MongoCfg) Addrs

func (cfg *MongoCfg) Addrs() []string

Addrs return an array of available MongoDB connections addresses.

Jump to

Keyboard shortcuts

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