config

package
v0.0.0-...-03f3354 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2015 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package config is responsible for finding, parsing and verifying the application's JSON config.

Index

Constants

This section is empty.

Variables

View Source
var ConfigFile string

Path to the configuration file, initialized from flags

Functions

This section is empty.

Types

type BytesSize

type BytesSize uint64

BytesSize represents size written in string format. Examples: "1m", "20g" etc. Its main purpose is to be stored and loaded from json.

func BytesSizeFromString

func BytesSizeFromString(str string) (BytesSize, error)

Parses bytes size such as "1m", "15g" to BytesSize struct.

func (*BytesSize) Bytes

func (b *BytesSize) Bytes() uint64

Bytes returns bytes number as uint64

func (*BytesSize) UnmarshalJSON

func (b *BytesSize) UnmarshalJSON(buff []byte) error

type CacheZoneSection

type CacheZoneSection struct {
	ID             uint32    `json:"id"`
	Path           string    `json:"path"`
	StorageObjects uint64    `json:"storage_objects"`
	PartSize       BytesSize `json:"part_size"`
}

type Config

type Config struct {
	System     SystemSection       `json:"system"`
	Logging    LoggingSection      `json:"logging"`
	HTTP       HTTPSection         `json:"http"`
	CacheZones []*CacheZoneSection `json:"cache_zones"`
}

the configuration type. Should contain representation for everything in config.json

func Get

func Get() (*Config, error)

Finds and returns the config for the daemon. Any errors are returned as a second parameter.

func (*Config) Parse

func (cfg *Config) Parse(filename string) error

The config object parses an json file and populates its fields. The json file is specified by the filename argument.

func (*Config) Verify

func (cfg *Config) Verify() error

Checks all fields in the parsed configs for wrong values. If found, returns error explaining the problem.

type HTTPSection

type HTTPSection struct {
	Listen         string         `json:"listen"`
	Servers        []*VirtualHost `json:"virtual_hosts"`
	MaxHeadersSize int            `json:"max_headers_size"`
	ReadTimeout    uint32         `json:"read_timeout"`
	WriteTimeout   uint32         `json:"write_timeout"`
	StatusPage     string         `json:"status_page"`
}

All configurations conserning the HTTP

type LoggingSection

type LoggingSection struct {
	LogFile string `json:"log_file"`
	Debug   bool   `json:"debug"`
}

Logging options

type SystemSection

type SystemSection struct {
	Pidfile string `json:"pidfile"`
	Workdir string `json:"workdir"`
	User    string `json:"user"`
}

Contains system and environment configurations.

type VirtualHost

type VirtualHost struct {
	Name            string `json:"name"`
	UpstreamAddress string `json:"upstream_address"`
	CacheZone       uint32 `json:"cache_zone"`
	CacheKey        string `json:"cache_key"`
	// contains filtered or unexported fields
}

func (*VirtualHost) GetCacheZoneSection

func (vh *VirtualHost) GetCacheZoneSection() *CacheZoneSection

func (*VirtualHost) UpstreamUrl

func (vh *VirtualHost) UpstreamUrl() *url.URL

Jump to

Keyboard shortcuts

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