Documentation ¶
Index ¶
- func ExecCollectValues(ctx context.Context, bus Bus, dir directive.Directive, ...) ([]directive.Value, directive.Reference, error)
- func ExecOneOff(ctx context.Context, bus Bus, dir directive.Directive, ...) (directive.AttachedValue, directive.Reference, error)
- func NewCallbackHandler(valCb func(directive.AttachedValue), removedCb func(directive.AttachedValue), ...) directive.ReferenceHandler
- func NewPassThruHandler(passthru directive.ResolverHandler, disposeCb func()) directive.ReferenceHandler
- type Bus
- type CallbackHandler
- type PassThruHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecCollectValues ¶
func ExecCollectValues( ctx context.Context, bus Bus, dir directive.Directive, valDisposeCallback func(), ) ([]directive.Value, directive.Reference, error)
ExecCollectValues collects one or more values while ctx is active and directive is not idle.
Does not return an error if ctx was canceled. Does not release ref if err == nil.
func ExecOneOff ¶
func ExecOneOff( ctx context.Context, bus Bus, dir directive.Directive, valDisposeCallback func(), ) (directive.AttachedValue, directive.Reference, error)
ExecOneOff executes a one-off directive. Returns nil if the directive is canceled for some reason during the execution.
func NewCallbackHandler ¶
func NewCallbackHandler( valCb func(directive.AttachedValue), removedCb func(directive.AttachedValue), disposeCb func(), ) directive.ReferenceHandler
NewCallbackHandler wraps callback functions into a handler object.
func NewPassThruHandler ¶
func NewPassThruHandler( passthru directive.ResolverHandler, disposeCb func(), ) directive.ReferenceHandler
NewPassThruHandler builds a new pass-through handler.
Types ¶
type Bus ¶
type Bus interface { // Controller is the directive controller. directive.Controller // GetControllers returns a list of all currently active controllers. GetControllers() []controller.Controller // ExecuteController adds a controller to the bus and calls Execute(). // Any fatal error in the controller is returned. // The controller will receive directive callbacks until this returns. // If the controller execute returns nil, waits until context is canceled to return. ExecuteController(context.Context, controller.Controller) error // RemoveController removes the controller from the bus. // The controller will no longer receive callbacks. // Note: this might not cancel the Execute() context automatically. RemoveController(context.Context, controller.Controller) error }
Bus manages running controllers. It has an attached directive controller, which is used to build declarative state requests between controllers.
type CallbackHandler ¶
type CallbackHandler struct {
// contains filtered or unexported fields
}
CallbackHandler is a reference handler that uses function callbacks.
func (*CallbackHandler) HandleInstanceDisposed ¶
func (h *CallbackHandler) HandleInstanceDisposed(directive.Instance)
HandleInstanceDisposed is called when a directive instance is disposed. This will occur if Close() is called on the directive instance.
func (*CallbackHandler) HandleValueAdded ¶
func (h *CallbackHandler) HandleValueAdded( _ directive.Instance, v directive.AttachedValue, )
HandleValueAdded is called when a value is added to the directive.
func (*CallbackHandler) HandleValueRemoved ¶
func (h *CallbackHandler) HandleValueRemoved( _ directive.Instance, v directive.AttachedValue, )
HandleValueRemoved is called when a value is removed from the directive.
type PassThruHandler ¶
type PassThruHandler struct {
// contains filtered or unexported fields
}
PassThruHandler is a reference handler that passes through to a resolver handler.
func (*PassThruHandler) HandleInstanceDisposed ¶
func (h *PassThruHandler) HandleInstanceDisposed(di directive.Instance)
HandleInstanceDisposed is called when a directive instance is disposed. This will occur if Close() is called on the directive instance.
func (*PassThruHandler) HandleValueAdded ¶
func (h *PassThruHandler) HandleValueAdded( _ directive.Instance, v directive.AttachedValue, )
HandleValueAdded is called when a value is added to the directive.
func (*PassThruHandler) HandleValueRemoved ¶
func (h *PassThruHandler) HandleValueRemoved( _ directive.Instance, v directive.AttachedValue, )
HandleValueRemoved is called when a value is removed from the directive.