launcher

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package launcher includes the shared application execution boilerplate of all SCION servers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WaitForNetworkReady

func WaitForNetworkReady(ctx context.Context, ips []net.IP)

WaitForNetworkReady checks that all IPs listed in the argument can be bound to. This function blocks until all IPs can be bound. Nil IPs in the input list are ignored.

Note in general this function is called directly by the application launcher, and therefore doesn't need to be used. It is public for applications that have custom constraints when the call should happen.

Types

type Application

type Application struct {
	// TOMLConfig holds the Go data structure for the application-specific
	// TOML configuration. The Application launcher will check if the TOMLConfig
	// supports additional methods (e.g., custom logging or instance ID) and
	// extract them from the config if that is the case. See the XxxConfig interfaces
	// in this package for more information.
	TOMLConfig libconfig.Config

	// Samplers contains additional configuration samplers to be included
	// under the sample subcommand. If empty, no additional samplers are
	// listed.
	//
	// DEPRECATED. This field will be removed once Anapaya/scion#5000 is implemented.
	Samplers []func(command.Pather) *cobra.Command

	// ShortName is the short name of the application. If empty, the executable name is used.
	// The ShortName could be, for example, "SCION Daemon" for the SCION Daemon.
	ShortName string

	// RequiredIPs should return the IPs that this application wants to listen
	// on. The launcher will wait until those IPs can be listened on. The
	// function is called after the configuration has been  initialized. If this
	// function is not set the launcher will immediately start the application
	// without waiting for any IPs.
	RequiredIPs func() ([]net.IP, error)

	// Main is the custom logic of the application. If nil, no custom logic is executed
	// (and only the setup/teardown harness runs). If Main returns an error, the
	// Run method will return a non-zero exit code.
	Main func(ctx context.Context) error

	// ErrorWriter specifies where error output should be printed. If nil, os.Stderr is used.
	ErrorWriter io.Writer
	// contains filtered or unexported fields
}

Application models a SCION server application.

func (*Application) Run

func (a *Application) Run()

Run sets up the common SCION server harness, and then passes control to the Main function (if one exists).

Run uses the following globals:

os.Args

Run will exit the application if it encounters a fatal error.

type IDConfig

type IDConfig interface {
	// ID returns the SCION instance ID of the application. The Get prefix is
	// used to avoid collisions with data members named ID.
	GetID() string
}

IDConfig is implemented by configurations that define a SCION instance ID. If an application configuration does not implement this interface, then the SCION instance ID is equal to the application binary name.

type LoggingConfig

type LoggingConfig interface {
	// Logging returns the logging configuration. The Get prefix is used to
	// avoid collisions with data members named Logging.
	GetLogging() log.Config
}

LoggingConfig is implemented by configurations that define logging behavior. If a application configuration does not implement this interface, then a default logging configuration is used.

Jump to

Keyboard shortcuts

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