settings

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//Init happens before handshake
	AfterInit = After("init")

	//Core happens with core is up and running (also networking)
	AfterNet = After("net")

	//Default for startup commands that doesn't specify dependency
	AfterBoot = After("boot")

	ToTheEnd = After("----")
)
View Source
const (
	//ConfigSuffix config file ext
	ConfigSuffix = ".toml"
)

Variables

View Source
var (
	CyclicDependency = fmt.Errorf("cyclic dependency")

	Priority = map[After]int64{
		AfterInit: 1,
		AfterNet:  1000,
		AfterBoot: 1000000,

		ToTheEnd: -1,
	}
)
View Source
var (

	//EOL parser has reached end of expression
	EOL = fmt.Errorf("end of line")
)

Functions

func LoadSettings

func LoadSettings(filename string) error

GetSettings loads main settings from a filename

Types

type After

type After string

func (After) Weight

func (a After) Weight() int64

type AppSettings

type AppSettings struct {
	Main struct {
		MaxJobs  int      `json:"max_jobs"`
		Include  []string `json:"include"`
		Network  string   `json:"network"`
		LogLevel string   `json:"log_level"` //deprecated (not used)
	} `json:"main"`

	Globals   Globals              `json:"globals"`
	Extension map[string]Extension `json:"extension"`
	Logging   struct {
		File  Logger `json:"file"`
		Ledis struct {
			Logger `json:"ledis"`
			Size   int64 `json:"size"`
		}
	} `json:"logger"`

	Containers struct {
		MaxCount int `json:"max_count"`
	} `json:"containers"`
	Stats struct {
		Enabled bool `json:"enabled"`
	} `json:"stats"`
}

Settings main agent settings

var Settings AppSettings

func (*AppSettings) GetIncludedSettings

func (s *AppSettings) GetIncludedSettings() (partial *IncludedSettings, errors []error)

GetPartialSettings loads partial settings according to main configurations

func (*AppSettings) Validate

func (s *AppSettings) Validate() []error

type Expression added in v1.2.0

type Expression interface {
	Examine(input map[string]interface{}) bool
}

Expression represents a loaded expression

func GetExpression added in v1.2.0

func GetExpression(expression string) (Expression, error)

GetExpression gets an expression object from string, empty string always evaluates to a `true` expression.

type Extension

type Extension struct {
	//binary to execute
	Binary string `json:"binary"`
	//script search path
	Cwd string `json:"cwd"`
	//(optional) Env variables
	Env map[string]string `json:"env"`

	Args []string `json:"args"`
	// contains filtered or unexported fields
}

Extension cmd config

func (*Extension) Key

func (e *Extension) Key() string

type Globals added in v0.10.0

type Globals map[string]string

func (Globals) Get added in v0.10.0

func (g Globals) Get(key string, def ...string) string

type IncludedSettings

type IncludedSettings struct {
	Extension map[string]Extension
	Startup   map[string]Startup
	// contains filtered or unexported fields
}

func (*IncludedSettings) GetStartupTree

func (i *IncludedSettings) GetStartupTree() (StartupTree, []error)

type Logger

type Logger struct {
	Levels []uint16 `json:"levels"`
}

Logger settings

type Security

type Security struct {
	CertificateAuthority string
	ClientCertificate    string
	ClientCertificateKey string
}

Security certificate path

type Startup

type Startup struct {
	After           []string
	RunningDelay    int
	RunningMatch    string
	RecurringPeriod int
	MaxRestart      int
	Protected       bool
	Name            string
	Tags            []string
	Args            map[string]interface{}
	Condition       string
	// contains filtered or unexported fields
}

StartupCmd startup command config

func (Startup) Key

func (s Startup) Key() string

func (Startup) String

func (s Startup) String() string

func (Startup) Weight

func (s Startup) Weight(i *IncludedSettings, chain ...string) (int64, error)

type StartupSlice

type StartupSlice []Startup

type StartupTree

type StartupTree interface {
	//Services a list of sorted startup services based on service weights.
	Services() []Startup

	//Slice gets a slice of the sorted start up processes that are lying between a
	//certain weight range. e can be set to -1 which means (end of list)
	//[s, e[
	Slice(s, e int64) StartupSlice
}

Jump to

Keyboard shortcuts

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