Documentation
¶
Index ¶
- Variables
- func NewIntervalTriggerCapsule(t *IntervalTrigger) cty.Value
- type IntervalTrigger
- func (t *IntervalTrigger) Count(_ context.Context) (int64, error)
- func (t *IntervalTrigger) Get(_ context.Context, _ []cty.Value) (cty.Value, error)
- func (t *IntervalTrigger) PostStart() error
- func (t *IntervalTrigger) Reset(_ context.Context) error
- func (t *IntervalTrigger) Set(_ context.Context, args []cty.Value) (cty.Value, error)
- func (t *IntervalTrigger) Start() error
- func (t *IntervalTrigger) Stop() error
Constants ¶
This section is empty.
Variables ¶
var IntervalCapsuleType = cty.CapsuleWithOps("interval_trigger", reflect.TypeOf((*IntervalTrigger)(nil)).Elem(), &cty.CapsuleOps{ GoString: func(val interface{}) string { return fmt.Sprintf("interval_trigger(%p)", val) }, TypeGoString: func(_ reflect.Type) string { return "IntervalTrigger" }, })
Functions ¶
func NewIntervalTriggerCapsule ¶
func NewIntervalTriggerCapsule(t *IntervalTrigger) cty.Value
Types ¶
type IntervalTrigger ¶
type IntervalTrigger struct {
// contains filtered or unexported fields
}
IntervalTrigger repeatedly evaluates its action expression, sleeping for a dynamically computed delay between each run. Both the delay and the action are re-evaluated each iteration against a context that exposes ctx.run_count, ctx.last_result, and ctx.last_error, enabling adaptive schedules (e.g. "poll more often when the object is moving fast").
get(trigger.<name>) returns the most recent action result, null before the first run, or an error if the most recent run failed.
set(trigger.<name>, duration) restarts the trigger with the given delay, resetting the run count. If the trigger has stopped (via stop_when or repeat=false), set() revives it.
set(trigger.<name>) with no duration restarts using the configured delay expression; returns an error if no delay was configured.
reset(trigger.<name>) cancels any pending timer and puts the trigger into a dormant state, waiting for the next set() call.
If delay is omitted from the configuration, the trigger starts dormant and waits for the first set() call before firing.
func GetIntervalTriggerFromCapsule ¶
func GetIntervalTriggerFromCapsule(val cty.Value) (*IntervalTrigger, error)
func (*IntervalTrigger) Count ¶ added in v0.27.0
func (t *IntervalTrigger) Count(_ context.Context) (int64, error)
Count returns the number of completed action evaluations. Implements richcty.Countable so count(trigger.<name>) is callable from any expression.
func (*IntervalTrigger) Get ¶
Get returns the most recent action result, null if the action has not yet run, or an error if the most recent evaluation failed. Implements Gettable.
func (*IntervalTrigger) PostStart ¶ added in v0.21.0
func (t *IntervalTrigger) PostStart() error
PostStart launches the background interval loop. Called after all Startable components have completed, so buses and clients are ready on first invocation. Implements PostStartable.
func (*IntervalTrigger) Reset ¶ added in v0.33.0
func (t *IntervalTrigger) Reset(_ context.Context) error
Reset cancels any pending timer and puts the trigger into a dormant state, waiting for the next set() call. Clears the delay override, run count, and last result/error. Implements Resettable.
func (*IntervalTrigger) Set ¶ added in v0.33.0
Set restarts the interval trigger, optionally with a new delay duration. If called with a duration argument, that duration overrides the configured delay expression until cleared by Reset(). If called with no arguments, the configured delay expression is used (returns an error if no delay was configured). Resets the run count so stop_when / repeat=false cycles work again. Implements Settable.
func (*IntervalTrigger) Start ¶
func (t *IntervalTrigger) Start() error
Start initialises the control channels. Implements Startable.
func (*IntervalTrigger) Stop ¶
func (t *IntervalTrigger) Stop() error
Stop signals the interval loop to exit and waits for it to finish. Implements Stoppable.