controller

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2021 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstallDriver

func InstallDriver(ctx context.Context, conf *config.Config) error

InstallDriver installs necessary drivers based on user configuration.

Types

type Controller

type Controller interface {
	// Init initializes elements needed by controller. Returns a map of
	// taskname to driver
	Init(ctx context.Context) error

	// Run runs the controller by monitoring Consul and triggering the driver as needed
	Run(ctx context.Context) error

	// ServeAPI runs the API server for the controller
	ServeAPI(context.Context) error

	// Stop stops underlying clients and connections
	Stop()
}

Controller describes the interface for monitoring Consul for relevant changes and triggering the driver to update network infrastructure.

func NewReadOnly

func NewReadOnly(conf *config.Config) (Controller, error)

NewReadOnly configures and initializes a new ReadOnly controller

func NewReadWrite

func NewReadWrite(conf *config.Config) (Controller, error)

NewReadWrite configures and initializes a new ReadWrite controller

type Oncer

type Oncer interface {
	Once(ctx context.Context) error
}

Oncer describes the interface a controller that can run in once mode

type ReadOnly

type ReadOnly struct {
	// contains filtered or unexported fields
}

ReadOnly is the controller to run in read-only mode

func (*ReadOnly) Init

func (ctrl *ReadOnly) Init(ctx context.Context) error

Init initializes the controller before it can be run

func (*ReadOnly) Run

func (ctrl *ReadOnly) Run(ctx context.Context) error

Run runs the controller in read-only mode by checking Consul catalog once for latest and using the driver to plan network infrastructure changes

func (*ReadOnly) ServeAPI added in v0.1.3

func (ctrl *ReadOnly) ServeAPI(ctx context.Context) error

ServeAPI runs the API server for the controller

func (ReadOnly) Stop

func (ctrl ReadOnly) Stop()

type ReadWrite

type ReadWrite struct {
	// contains filtered or unexported fields
}

ReadWrite is the controller to run in read-write mode

func (*ReadWrite) EnableTestMode

func (rw *ReadWrite) EnableTestMode()

EnableTestMode is a helper for testing which tasks were triggered and executed. Callers of this method must consume from TaskNotifyChannel to prevent the buffered channel from filling and causing a dead lock.

func (*ReadWrite) Init

func (rw *ReadWrite) Init(ctx context.Context) error

Init initializes the controller before it can be run. Ensures that driver is initializes, works are created for each task.

func (*ReadWrite) Once

func (rw *ReadWrite) Once(ctx context.Context) error

Once runs the controller in read-write mode making sure each template has been fully rendered and the task run, then it returns.

func (*ReadWrite) Run

func (rw *ReadWrite) Run(ctx context.Context) error

Run runs the controller in read-write mode by continuously monitoring Consul catalog and using the driver to apply network infrastructure changes for any work that have been updated. Blocking call that runs main consul monitoring loop

func (*ReadWrite) ServeAPI added in v0.1.3

func (rw *ReadWrite) ServeAPI(ctx context.Context) error

ServeAPI runs the API server for the controller

func (ReadWrite) Stop

func (ctrl ReadWrite) Stop()

func (*ReadWrite) TaskNotifyChannel

func (rw *ReadWrite) TaskNotifyChannel() (<-chan string, error)

TaskNotifyChannel returns a read only channel. The channel should only be consumed by one reader.

Jump to

Keyboard shortcuts

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