Documentation
¶
Index ¶
- Constants
- Variables
- func WaitExecControllerRunning(ctx context.Context, b bus.Bus, dir directive.Directive, disposeCb func()) (controller.Controller, directive.Instance, directive.Reference, error)
- func WaitExecControllerRunningTyped[T controller.Controller](ctx context.Context, b bus.Bus, dir directive.Directive, disposeCb func()) (T, directive.Instance, directive.Reference, error)
- type Controller
- type ExecController
- type ExecControllerValue
Constants ¶
const ControllerID = "controllerbus/loader"
ControllerID is the controller identifier
Variables ¶
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.
func WaitExecControllerRunningTyped ¶ added in v0.46.2
func WaitExecControllerRunningTyped[T controller.Controller]( ctx context.Context, b bus.Bus, dir directive.Directive, disposeCb func(), ) (T, directive.Instance, directive.Reference, error)
WaitExecControllerRunningTyped 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.
If the controller is not of type T an error will be returned and the reference will be released immediately.
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 ¶
NewController builds a new loader controller given a bus. If the given backoff is nil, uses the defaults.
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