daemon

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2017 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackendClient

type BackendClient interface {
	// Syncer creates an object that generates a series of KVPair updates,
	// which paint an eventually-consistent picture of the full state of
	// the datastore and then generates subsequent KVPair updates for
	// changes to the datastore.
	Syncer(callbacks bapi.SyncerCallbacks) bapi.Syncer

	// EnsureInitialized ensures that the backend is initialized
	// any ready to be used.
	EnsureInitialized() error
}

BackendClient captures the sub-interface of the backend client that we actually use.

type TyphaDaemon

type TyphaDaemon struct {
	BuildInfoLogCxt *log.Entry
	ConfigFilePath  string
	DatastoreClient BackendClient
	ConfigParams    *config.Config

	// The components of the server, created in CreateServer() below.
	Syncer            bapi.Syncer
	SyncerToValidator *calc.SyncerCallbacksDecoupler
	Validator         *calc.ValidationFilter
	ValidatorToCache  *calc.SyncerCallbacksDecoupler
	Cache             *snapcache.Cache
	Server            *syncserver.Server

	// The functions below default to real library functions but they can be overridden for testing.
	NewBackendClient      func(config api.CalicoAPIConfig) (BackendClient, error)
	ConfigureEarlyLogging func()
	ConfigureLogging      func(configParams *config.Config)
	// contains filtered or unexported fields
}

TyphaDaemon handles the lifecycle of the Typha process. The main() function of the Typha executable should simply call InitializeAndServeForever() to start the Typha server. The lifecycle is broken out into several individual methods for ease of testing.

func New

func New() *TyphaDaemon

func (*TyphaDaemon) CreateServer

func (t *TyphaDaemon) CreateServer()

CreateServer creates and configures (but does not start) the server components.

func (*TyphaDaemon) DoEarlyRuntimeSetup

func (t *TyphaDaemon) DoEarlyRuntimeSetup()

DoEarlyRuntimeSetup does early runtime/logging configuration that needs to happen before we do any work.

func (*TyphaDaemon) InitializeAndServeForever

func (t *TyphaDaemon) InitializeAndServeForever(cxt context.Context)

func (*TyphaDaemon) LoadConfiguration

func (t *TyphaDaemon) LoadConfiguration()

LoadConfiguration uses the command-line configuration and environment variables to load our configuration. It initializes the datastore connection.

func (*TyphaDaemon) ParseCommandLineArgs

func (t *TyphaDaemon) ParseCommandLineArgs(argv []string)

ParseCommandLineArgs parses the command line args and either exits with a usage warning or stores the parsed arguments on fields of the struct.

func (*TyphaDaemon) Start

func (t *TyphaDaemon) Start(cxt context.Context)

Start starts all the server components in background goroutines.

func (*TyphaDaemon) WaitAndShutDown

func (t *TyphaDaemon) WaitAndShutDown(cxt context.Context)

WaitAndShutDown waits for OS signals or context.Done() and exits as appropriate.

Jump to

Keyboard shortcuts

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