config

package
v0.0.0-...-bd03ed3 Latest Latest
Warning

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

Go to latest
Published: May 7, 2016 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package config implements shared configuration-related routines.

Index

Constants

This section is empty.

Variables

View Source
var Debug *log.Logger

Functions

func Load

func Load(config Struct, filePath, serverPath string)

Load loads the config struct with values stored in the given file. The file's encoding is JSON.

In addition, depending on environment details, a second file is loaded over network. The remote file overrides those settings of the local file which have been marked as dynamic in the corresponding struct field. To mark field as dynamic, tag it with config=dynamic, for example:

RelayHost string `config:"dynamic"`

The server path must be a valid HTTP path except the order of query parameters is significant. The path may include the template action {{.Hostname}} which expands to local host name, for example:

"/tsp/forwarder?host={{.Hostname}}"

The test for config=dynamic tag is not performed recursively.

At least one path must be provided. If a path is empty, it is ignored.

func Next

func Next(config Struct)

Next blocks until new configuration values arrive over network. Once they do, the config struct is rewritten to contain the new settings.

If called before Load, Next will panic. In some environments, Next may block forever.

func WaitSIGHUP

func WaitSIGHUP()

WaitSIGHUP blocks until a SIGHUP signal is received.

Types

type Directory

type Directory struct {
	C <-chan DirectoryEvent
	// contains filtered or unexported fields
}

Directory is a watcher of directory changes.

func WatchDirectory

func WatchDirectory(path string) *Directory

WatchDirectory watches the given directory for updates. The scan is not recursive.

func (*Directory) Stop

func (dir *Directory) Stop()

type DirectoryEvent

type DirectoryEvent struct {
	Target   string
	IsCreate bool
	IsRemove bool
	IsModify bool
}

DirectoryEvent represents addition/removal event of the given file.

func (DirectoryEvent) String

func (event DirectoryEvent) String() string

type Struct

type Struct interface {
	Reset()
	Validate() error
}

Struct is an interface satisfied by every configuration struct. Reset resets struct by setting default values and zeroing others. Validate returns nil if the configuration is valid for processing by the client.

Jump to

Keyboard shortcuts

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