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, returnIfIdle bool, ...) (directive.AttachedValue, directive.Reference, error)
- func ExecOneOffWatchCh(b Bus, dir directive.Directive) (<-chan 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.
Returns err if the directive is idle and a resolver returned an error. 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, returnIfIdle bool, valDisposeCallback func(), ) (directive.AttachedValue, directive.Reference, error)
ExecOneOff executes a one-off directive. If returnIfIdle is set, returns nil, nil, nil if idle.
func ExecOneOffWatchCh ¶ added in v0.8.7
func ExecOneOffWatchCh( b Bus, dir directive.Directive, ) (<-chan directive.AttachedValue, directive.Reference, error)
ExecOneOffWatchCh executes a one-off directive and watches for changes. Returns a channel with size 1 which will hold the latest value. Continues to watch for changes until the directive is released.
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. // If the controller returns nil, call RemoveController to remove the controller. 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(controller.Controller) }
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.