loader

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2022 License: Apache-2.0 Imports: 11 Imported by: 7

Documentation

Index

Constants

View Source
const ControllerID = "controllerbus/loader/1"

ControllerID is the controller identifier

Variables

View Source
var Version = semver.MustParse("0.0.1")

Version is the controller version

Functions

func WaitExecControllerRunning

func WaitExecControllerRunning(
	ctx context.Context,
	b bus.Bus,
	dir directive.Directive,
	disposeCb func(),
) (controller.Controller, directive.Instance, directive.Reference, error)

WaitExecControllerRunning executes any directive which yields ExecControllerValue and waits for either a error or success state before returning. Disposed is called if the state leaves RUNNING.

Types

type Controller

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

Controller implements the loader controller. It responds to ExecController directives and attaches to a bus.

func NewController

func NewController(le *logrus.Entry, bus bus.Bus, execBackoff backoff.BackOff) (*Controller, error)

NewController builds a new loader controller given a bus. If the given backoff is nil, uses the defaults.

func (*Controller) Close

func (c *Controller) Close() error

Close closes the controller.

func (*Controller) Execute

func (c *Controller) Execute(ctx context.Context) error

Execute executes the loader controller.

func (*Controller) GetControllerInfo

func (c *Controller) GetControllerInfo() controller.Info

GetControllerInfo returns information about the controller.

func (*Controller) HandleDirective

func (c *Controller) HandleDirective(
	ctx context.Context,
	di directive.Instance,
) (directive.Resolver, error)

HandleDirective asks if the handler can resolve the directive. If it can, it returns a resolver. If not, returns nil. Any exceptional errors are returned for logging. It is safe to add a reference to the directive during this call. The context passed is canceled when the directive instance expires.

type ExecController

type ExecController interface {
	// Directive indicates this is a directive.
	directive.Directive

	// GetExecControllerFactory returns the factory desired to load.
	GetExecControllerFactory() controller.Factory

	// GetExecControllerConfig returns the config to load the controller with.
	GetExecControllerConfig() config.Config
}

ExecController is a directive indicating a controller instance should be constructed and executed given a factory and a configuration. If/when the controller exits, the directive is canceled with the error.

func NewExecControllerSingleton

func NewExecControllerSingleton(
	factory controller.Factory,
	config config.Config,
) ExecController

NewExecControllerSingleton constructs a new ExecController directive.

type ExecControllerSingleton

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

ExecControllerSingleton is an ExecController directive. Will override or yield to exiting directives for the controller.

func (*ExecControllerSingleton) GetDebugVals

func (d *ExecControllerSingleton) GetDebugVals() directive.DebugValues

GetDebugVals returns the directive arguments as k/v pairs. This is not necessarily unique, and is primarily intended for display.

func (*ExecControllerSingleton) GetExecControllerConfig

func (d *ExecControllerSingleton) GetExecControllerConfig() config.Config

GetExecControllerConfig returns the config to load the controller with.

func (*ExecControllerSingleton) GetExecControllerFactory

func (d *ExecControllerSingleton) GetExecControllerFactory() controller.Factory

GetExecControllerFactory returns the factory desired to load.

func (*ExecControllerSingleton) GetName

func (d *ExecControllerSingleton) GetName() string

GetName returns the directive's type name. This is not necessarily unique, and is primarily intended for display.

func (*ExecControllerSingleton) GetValueOptions

func (d *ExecControllerSingleton) GetValueOptions() directive.ValueOptions

GetValueOptions returns options relating to value handling.

func (*ExecControllerSingleton) IsEquivalent

func (d *ExecControllerSingleton) IsEquivalent(other directive.Directive) bool

IsEquivalent checks if the other directive is equivalent. Ex: check if version range is inclusive of "other" version range.

func (*ExecControllerSingleton) Superceeds

func (d *ExecControllerSingleton) Superceeds(other directive.Directive) bool

Superceeds checks if the directive overrides another. The other directive will be canceled if superceded.

func (*ExecControllerSingleton) Validate

func (d *ExecControllerSingleton) Validate() error

Validate validates the directive. This is a cursory validation to see if the values "look correct."

type ExecControllerValue

type ExecControllerValue interface {
	// GetUpdatedTimestamp returns the last time this info changed.
	GetUpdatedTimestamp() time.Time
	// GetNextRetryTimestamp returns the next time this controller will be attempted.
	GetNextRetryTimestamp() time.Time
	// GetController returns the current controller object.
	GetController() controller.Controller
	// GetError returns the error running the controller.
	// Controller may still be set in this case.
	GetError() error
}

ExecControllerValue is the value emitted to satisfy the ExecController directive.

func NewExecControllerValue

func NewExecControllerValue(
	updatedTimestamp time.Time,
	retryTimestamp time.Time,
	ctrl controller.Controller,
	err error,
) ExecControllerValue

NewExecControllerValue builds a new ExecControllerValue

Jump to

Keyboard shortcuts

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