loader

package
v0.44.5 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: MIT Imports: 11 Imported by: 7

Documentation

Index

Constants

View Source
const ControllerID = "controllerbus/loader"

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) (*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 unexpected 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
	// GetExecControllerRetryBackoff returns the backoff to use for retries.
	// If empty / nil, uses the default.
	GetExecControllerRetryBackoff() func() backoff.BackOff
}

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 NewExecController added in v0.15.2

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

NewExecController constructs a new ExecController directive.

func NewExecControllerWithOpts added in v0.15.3

func NewExecControllerWithOpts(
	factory controller.Factory,
	config config.Config,
	retryBackoff func() backoff.BackOff,
	valueOpts directive.ValueOptions,
) ExecController

NewExecControllerWithOpts constructs a new ExecController directive.

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