env

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package env contains common command line and initialization code for SCION Infrastructure services. If something is specific to one app, it should go into that app's code and not here.

During initialization, SIGHUPs are masked. To call a function on each SIGHUP, pass the function when calling Init.

TODO(scrye): Also common stuff like trustdb initialization, messenger initialization and handler registration can go here. Everything that can be shared by infra apps, to reduce duplicated code.

Index

Constants

View Source
const (
	DefaultLoggingLevel = "info"
	// Default max size of log files in MiB
	DefaultLoggingFileSize = 50
	// Default max age of log file in days
	DefaultLoggingFileMaxAge = 7
	// Default file name for topology file (only the last element of the path)
	DefaultTopologyPath = "topology.json"
)

Variables

This section is empty.

Functions

func InitGeneral

func InitGeneral(cfg *General) error

func InitInfra

func InitInfra(cfg *Infra, id string, warnings io.Writer, topo *topology.Topo) error

func InitLogging

func InitLogging(cfg *Logging) error

InitLogging initializes logging and sets the root logger Log.

Types

type Env

type Env struct {
	// AppShutdownSignal is closed when the process receives a signal to close
	// (e.g., SIGTERM).
	AppShutdownSignal chan struct{}
}

func SetupEnv

func SetupEnv(reloadF func()) *Env

type General

type General struct {
	// ID is the SCION element ID. This is used to choose the relevant
	// portion of the topology file for some services.
	ID string
	// ConfigDir for loading extra files (currently, only topology.json)
	ConfigDir string
	// TopologyPath is the file path for the local topology JSON file.
	TopologyPath string `toml:"Topology"`
	// Topology is the loaded topology file.
	Topology *topology.Topo `toml:"-"`
	// Seed for the PRNG. A value of 0 means use current UNIX time as seed.
	Seed int64
}

type Infra

type Infra struct {
	// Type must be one of BS, CS or PS.
	Type string
	// Public is the local address to listen on for SCION messages (if Bind is
	// not set), and to send out messages to other nodes.
	Public snet.Addr
	// If set, Bind is the preferred local address to listen on for SCION
	// messages.
	Bind snet.Addr
}

Infra contains information that is BS, CS, PS specific.

type Logging

type Logging struct {
	File struct {
		// Path is the location of the logging file. If unset, no file logging
		// is performed.
		Path string
		// Level of file logging (defaults to DefaultLoggingLevel).
		Level string
		// Size is the max size of log file in MiB (defaults to DefaultLoggingFileSize)
		Size uint
		// Max age of log file in days (defaults to DefaultLoggingFileMaxAge)
		MaxAge uint
		// FlushInterval specifies how frequently to flush to the log file,
		// in seconds
		FlushInterval int
	}

	Console struct {
		// Level of console logging. If unset, no console logging is
		// performed.
		Level string
	}
}

type Metrics

type Metrics struct {
	// Prometheus contains the address to export prometheus metrics on. If
	// not set, metrics are not exported.
	Prometheus string
}

type Trust

type Trust struct {
	// TrustDB is the database for trust information.
	TrustDB string
}

Trust contains information that is BS, CS, PS, SD specific.

Jump to

Keyboard shortcuts

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