What Happens When an Event Is Raised?

When an event is raised, it touches off a series of rule set evaluations. The pico engine is responsible for determining what rule sets need to be evaluated for a given event. I say "evaluated" rather than "executed" because an event may not result in any rules being executed unless they are selected based on their eventex and the past pattern of event

Every rule that has a matching eventex will be added to the execution schedule. The pico engine guarantees that rules in a given rule set will be scheduled in order, but does not give any guarantees about the execution order of rule sets themselves. 

After the schedule has been created, the pico engine executes it. Execution results in the rule prelude being executed, the condition being evaluated, action being taken (based on the outcome of the condition), and the rule postlude being executed. Note that it possible to have an execution cycle that does not take any action if all the scheduled rules have no actions or have conditional actions where the condition is not true.

One action a rule can take is to send a directive (a response from the event). Even if no send_directive() actions are taken, a directive document is still produced, but the list of directives is empty.

Because rules can raise events, one event can result in a rule executing that causes another event. Rules can raise events directly in the rule postlude. In that case, for efficiency reasons, the event is examined and the schedule updated during the same execution cycle. All the directives in this case will have the same event ID.


Copyright Picolabs | Licensed under Creative Commons.