scion: github.com/scionproto/scion/go/lib/env Index | Files | Directories

package env

import "github.com/scionproto/scion/go/lib/env"

Package env contains common command line and initialization code for SCION 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.

Index

Package Files

env.go features.go flags.go logging.go sample.go

Constants

const (
    // TopologyFile is the file name for the topology file.
    TopologyFile = "topology.json"

    // SciondInitConnectPeriod is the default total amount of time spent
    // attempting to connect to sciond on start.
    SciondInitConnectPeriod = 20 * time.Second

    // ShutdownGraceInterval is the time applications wait after issuing a
    // clean shutdown signal, before forcerfully tearing down the application.
    ShutdownGraceInterval = 5 * time.Second
)

Variables

var (
    // The value is generated by tools/git-version.
    StartupVersion string
)

Startup* variables are set during link time.

func AddFlags Uses

func AddFlags()

AddFlags adds the config and sample flags.

func CheckFlags Uses

func CheckFlags(sampler config.Sampler) (int, bool)

CheckFlags checks whether the config or help-config flags have been set. In case the help-config flag is set, the config flag is ignored and a commented sample config is written to stdout.

The first return value is the return code of the program. The second value indicates whether the program can continue with its execution or should exit.

func ConfigFile Uses

func ConfigFile() string

ConfigFile returns the config file path passed through the flag.

func InfoHandler Uses

func InfoHandler(w http.ResponseWriter, r *http.Request)

func LogAppStarted Uses

func LogAppStarted(svcType, elemID string) error

LogAppStarted should be called by applications as soon as logging is initialized.

func LogAppStopped Uses

func LogAppStopped(svcType, elemID string)

func ReloadTopology Uses

func ReloadTopology(topologyPath string)

func SetupEnv Uses

func SetupEnv(reloadF func())

SetupEnv initializes a basic environment for applications. If reloadF is not nil, the application will call reloadF whenever it receives a SIGHUP signal.

func Usage Uses

func Usage()

Usage outputs run-time help to stdout.

func VersionInfo Uses

func VersionInfo() string

VersionInfo returns build version information (build date, build version, build chain).

type Features Uses

type Features struct {
    AllowRunAsRoot bool `toml:"allow_run_as_root,omitempty"`
    UseSIGEgress2  bool `toml:"sig_egress_v2,omitempty"`
}

Features contains all feautre flags. Add feature flags to this structure as needed. Feature flags are always boolean. Don't use any other types here!

func (*Features) ConfigName Uses

func (cfg *Features) ConfigName() string

func (*Features) InitDefaults Uses

func (cfg *Features) InitDefaults()

func (*Features) Sample Uses

func (cfg *Features) Sample(dst io.Writer, path config.Path, ctx config.CtxMap)

func (*Features) Validate Uses

func (cfg *Features) Validate() error

type General Uses

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 `toml:"id,omitempty"`
    // ConfigDir for loading extra files (currently, only topology.json)
    ConfigDir string `toml:"config_dir,omitempty"`
    // ReconnectToDispatcher can be set to true to enable transparent dispatcher
    // reconnects.
    ReconnectToDispatcher bool `toml:"reconnect_to_dispatcher,omitempty"`
}

func (*General) ConfigName Uses

func (cfg *General) ConfigName() string

func (*General) InitDefaults Uses

func (cfg *General) InitDefaults()

InitDefaults sets the default value for Topology if not already set.

func (*General) Sample Uses

func (cfg *General) Sample(dst io.Writer, path config.Path, ctx config.CtxMap)

func (*General) Topology Uses

func (cfg *General) Topology() string

Topology returns the path to the topology file

func (*General) Validate Uses

func (cfg *General) Validate() error

type Metrics Uses

type Metrics struct {
    config.NoDefaulter
    config.NoValidator
    // Prometheus contains the address to export prometheus metrics on. If
    // not set, metrics are not exported.
    Prometheus string `toml:"prometheus,omitempty"`
}

func (*Metrics) ConfigName Uses

func (cfg *Metrics) ConfigName() string

func (*Metrics) Sample Uses

func (cfg *Metrics) Sample(dst io.Writer, path config.Path, _ config.CtxMap)

func (*Metrics) StartPrometheus Uses

func (cfg *Metrics) StartPrometheus()

type QUIC Uses

type QUIC struct {
    ResolutionFraction float64 `toml:"resolution_fraction,omitempty"`
    Address            string  `toml:"address,omitempty"`
    CertFile           string  `toml:"cert_file,omitempty"`
    KeyFile            string  `toml:"key_file,omitempty"`
}

QUIC contains configuration for control-plane speakers.

func (*QUIC) ConfigName Uses

func (cfg *QUIC) ConfigName() string

func (*QUIC) Sample Uses

func (cfg *QUIC) Sample(dst io.Writer, path config.Path, _ config.CtxMap)

type SCIONDClient Uses

type SCIONDClient struct {
    // Address of the SCIOND server the client should connect to. Defaults to
    // 127.0.0.1:30255.
    Address string `toml:"address,omitempty"`
    // InitialConnectPeriod is the maximum amount of time spent attempting to
    // connect to sciond on start.
    InitialConnectPeriod util.DurWrap `toml:"initial_connect_period,omitempty"`
    // FakeData can be used to replace the local SCIOND with a fake data source.
    // It must point to a fake SCIOND configuration file.
    FakeData string `toml:"fake_data,omitempty"`
    // PathCount is the maximum number of paths returned to the user.
    PathCount uint16 `toml:"path_count,omitempty"`
}

SCIONDClient contains information for running snet with sciond.

func (*SCIONDClient) ConfigName Uses

func (cfg *SCIONDClient) ConfigName() string

func (*SCIONDClient) InitDefaults Uses

func (cfg *SCIONDClient) InitDefaults()

func (*SCIONDClient) Sample Uses

func (cfg *SCIONDClient) Sample(dst io.Writer, path config.Path, _ config.CtxMap)

func (*SCIONDClient) Validate Uses

func (cfg *SCIONDClient) Validate() error

type Tracing Uses

type Tracing struct {
    // Enabled enables tracing for this service.
    Enabled bool `toml:"enabled,omitempty"`
    // Enable debug mode.
    Debug bool `toml:"debug,omitempty"`
    // Agent is the address of the local agent that handles the reported
    // traces. (default: localhost:6831)
    Agent string `toml:"agent,omitempty"`
}

Tracing contains configuration for tracing.

func (*Tracing) ConfigName Uses

func (cfg *Tracing) ConfigName() string

func (*Tracing) InitDefaults Uses

func (cfg *Tracing) InitDefaults()

func (*Tracing) NewTracer Uses

func (cfg *Tracing) NewTracer(id string) (opentracing.Tracer, io.Closer, error)

NewTracer creates a new Tracer for the given configuration. In case tracing is disabled this still returns noop-objects for convenience of the caller.

func (*Tracing) Sample Uses

func (cfg *Tracing) Sample(dst io.Writer, path config.Path, _ config.CtxMap)

Directories

PathSynopsis
envtest

Package env imports 23 packages (graph) and is imported by 38 packages. Updated 2020-04-07. Refresh now. Tools for package owners.