controller

package
v0.0.0-...-a355528 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Enforce represents create, update, reconcile operations
	Enforce = iota

	// Destroy is the destroy operation. Destroy also implies Free.
	Destroy
)

Variables

View Source
var (
	// InterfaceSpec is the current name and version of the Instance API.
	InterfaceSpec = spi.InterfaceSpec{
		Name:    "Controller",
		Version: "0.1.0",
	}
)

Functions

func CancelWait

func CancelWait(p Controller)

CancelWait stops the plugin from waiting / retrying to connect

Types

type Controller

type Controller interface {

	// Plan is a commit without actually making the changes.  The controller returns a proposed object state
	// after commit, with a Plan, or error.
	Plan(Operation, types.Spec) (types.Object, Plan, error)

	// Commit commits the spec to the controller for management or destruction.  The controller's job is to ensure reality
	// matches the operation and the specification.  The spec can be composed and references other controllers or plugins.
	// When a spec is committed to a controller, the controller returns the object state corresponding to
	// the spec.  When operation is Destroy, only Metadata portion of the spec is needed to identify
	// the object to be destroyed.
	Commit(Operation, types.Spec) (types.Object, error)

	// Describe returns a list of objects matching the metadata provided. A list of objects are possible because
	// metadata can be a tags search.  An object has state, and its original spec can be accessed as well.
	// A nil Metadata will instruct the controller to return all objects under management.
	Describe(*types.Metadata) ([]types.Object, error)

	// Free tells the controller to pause management of objects matching.  To resume, commit again.
	Free(*types.Metadata) ([]types.Object, error)
}

Controller is the interface that all controllers implement. Controllers are managed by pkg/manager/Manager

func LazyConnect

func LazyConnect(finder func() (Controller, error), retry time.Duration) Controller

LazyConnect returns a Controller that defers connection to actual method invocation and can optionally block until the connection is made.

type Operation

type Operation int

Operation is the action to be taken for a commit

type Plan

type Plan struct {
	// Message contains human-friendly message
	Message []string
}

Plan models the steps the controller will take to fulfill specification when committed.

type Poller

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

Poller is the entity that executes a unit of work at a predefined interval

func Poll

func Poll(shouldRun func() bool, work func() error, ticker <-chan time.Time) *Poller

Poll creates a poller

func (*Poller) Err

func (p *Poller) Err() error

Err returns the errors encountered by the poller

func (*Poller) Run

func (p *Poller) Run(ctx context.Context)

Run will start all the matchers and query the services at defined polling interval. It blocks until stop is called.

func (*Poller) Stop

func (p *Poller) Stop()

Stop stops the Poller

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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