Creating Rules
The first step in creating a rule is selecting the rule type.
Each rule type serves a distinct purpose and can accept or not certain types of ops from the palette.
But in general we can divide rule types in 2 distinct groups: return rules and action rules.
Action Rules¶
Action rules are meant to run code the interact with the external world, implying what is called side effects, like copying files, calling webservices.
But by definition, the variables in their stash values are primarily ignored, with some known exceptions such as Webservice rules.
These are:
-
Independent rules called from other execution rule types or used in a scheduler.
-
Event rules, triggered with events, are used for event control and event-related tasks.
-
Pipeline rules hold the tasks that run in deployment jobs.
-
Webservice rules, invoked from an URL into the system.
Return Rules¶
These rules have as purpose configuration return data into the stash. This data is then used to compose views in the product, such as forms, dashboards, reports or control workflow behavior.
-
Form rules return form metadata in the stash.
-
Workflow rules return workflow structure and decisions.
-
Dashboard rules return stash data with a list of dashlets, their configuration and position in the dashboard.
-
Reports return metadata and data to be loaded into a data table in the UI.
-
Blueprints are a set of variables that compose a template definition for configuring environments.
-
Independent rules may fall into this category also, as they could hold reusable rule ops, say a set of form fields.
Compilation mode¶
This field controls how your rule is going to be compiled into the system.
-
None the rule will be compiled on-demand. This has a (usually small) performance penalty but allows for quicker system start.
-
Precompile precompiled rules are compiled when the system starts. For example, when the Dispatcher or Web Server starts. It has a startup penalty and can slow job execution start. On the other hand, Do not use this option when developing a rule, creating frequent versions of it.
Getting Started¶
For starting with rules, we recommend creating a simple Independent Rule.
Try dragging and dropping ops into the rule. Then hit the Run
button to
open the Run panel.
Steps:
-
Create an independent rule and give it a name, ie
Foo
-
Drag and drop the
LOG
operation from the palette -
Double click on the dropped log operation to open the
Configuration
panel. Optionally, right-click on theLOG
op to get the op context menu and select theConfiguration
option. -
Put
Hello world
into theText
field and Save (Ctrl/Cmd-S) to close the window. -
Select the
Run
button on the button bar. This will open the runner console underneath your rule. Hit theRun
button again for it to compile and run your rule.
Voilà! You have just created and run your first rule.