Expand description
Matching and running rules against events, with loop protection.
- Events of kind
rule.*(the engine’s own bookkeeping) never trigger rules. - A rule already running in the current chain is not started again.
- Chains stop at
MAX_DEPTHrules; one outermost event starts at mostMAX_RUNSruns. - Blocked runs are reported to
Host::blockedwith the reason.
The application supplies the rules, the events’ fields, what “related” means, and what
a then-action does, through Host. Whether someone may create, change or run a rule
is decided by the application before it gets here.
Structs§
- Check
- How a rule fares against one event (a dry run).
- Cond
Check - Run
- The run of one rule, handed to
Host::finish_run. - RunResult
- The outcome of one run.
- Runtime
- The chain of rules running now (outermost first) and the runs left for the outermost
event. Owned by the application (one per store or session) and handed out by
Host::runtime.
Constants§
- MAX_
DEPTH - Most rules in one chain (a rule whose action triggers a rule whose action triggers …).
- MAX_
RUNS - Most rule runs started by one outermost event.
- SCHEDULE
- The event kind a scheduled rule runs on. With a
ruleparam naming a rule, only that rule (if it has a schedule or listens toschedule) reacts.
Traits§
- Event
- Something that happened, as the engine sees it.
- Host
- What the engine needs from the application.
- Rule
- A stored rule, as the engine sees it.
Functions§
- brief
- One line about a rule:
on import → 2 actions,every 6h, on import → 1 action (off). - check
- Does the rule apply to the event, and why (not)? Does not look at
enabled. - dispatch
- Run every enabled rule that matches the event (call after each event is recorded). Returns how many runs started.
- due
- Is a scheduled rule due at
now(epoch ms)? - next_
run - When a rule’s schedule runs next (
None: no schedule, or a cron that never fires). - run
- Run a rule’s then-actions for an event, in order; a failing one does not stop the rest.
Does not check whether the rule matches (see
check) or may run.