[1] KRL programs, or rulesets, comprise a number of rules that respond to particular events.
[2][3] KRL is part of an open-source project called KRE,[4] for Kinetic Rules Engine, developed by Kynetx, Inc. KRL was designed by Phil Windley at Kynetx, beginning in 2007.
KRL is event-based with strict evaluation, single assignment, and dynamic typing.
In event-driven programming, events, a notification that something happened, control the flow of execution.
A single event can fire rules from multiple rulesets within the entity's execution environment.
Entity variables, in particular, are a very powerful concept since they provide KRL programmers with the ability to store persistent values without the headache of configuring, linking, and using a database for most things.
KRL is called an event condition action or ECA rule language because of the roles that those three fundamental parts of a rule play: Besides a collection of rules, KRL rulesets also contain a meta section for specifying information about the ruleset, a dispatch section for providing clues about event salience, and a global section for global definitions.
For example, events could be transported by email, SMS, MQTT, or any other system supporting push-style notifications.
An endpoint that generates an event may be observing some activity directly and reporting salient state changes or it might just be reporting or transforming event data from another source (e.g., a webhook).
This means that KRL programs consist of a set of rules that take an action when triggered.
For example, in the web domain, this most often consists of a regular expression to match with the URL of the page being augmented.
This check is done after the rule's prelude section, where values are declared, so that it has the benefit of any computation needed to create or manipulate the context.
The predicate of the conditional is optional, so it is possible to write a rule that always fires because its selector always selects.
The following example shows a simple KRL rule: This rule would send a “good morning” notification to visitors of any page in the archives of a web site (as denoted by the URL path) if it's morning where the user is.