daemon

package
v0.6.0-beta1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 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 ClientV3Shim added in v0.6.0

type ClientV3Shim struct {
	C RealClientV3
}

ClientV3Shim adapts the real v3 client interface to our mockable interface.

func (ClientV3Shim) EnsureInitialized

func (s ClientV3Shim) EnsureInitialized(ctx context.Context, calicoVersion, clusterType string) error

func (ClientV3Shim) Syncer

func (s ClientV3Shim) Syncer(callbacks bapi.SyncerCallbacks) bapi.Syncer

type DatastoreClient added in v0.6.0

type DatastoreClient interface {
	EnsureInitialized(ctx context.Context, calicoVersion, clusterType string) error
	Syncer(callbacks bapi.SyncerCallbacks) bapi.Syncer
}

DatastoreClient is our interface to the datastore, used for mocking in the UTs.

type RealClientV3 added in v0.6.0

type RealClientV3 interface {
	EnsureInitialized(ctx context.Context, calicoVersion, clusterType string) error
	Backend() bapi.Client
}

RealClientV3 is the subset of the clientv3.Interface that we care about.

type TyphaDaemon

type TyphaDaemon struct {
	BuildInfoLogCxt *log.Entry
	ConfigFilePath  string
	DatastoreClient DatastoreClient
	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.
	NewClientV3           func(config apiconfig.CalicoAPIConfig) (DatastoreClient, 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