This quickstart is for the classic engine. Go here to get up and running with the Node pico engine.
This Quickstart will help you get your KRL programming environment set up and working.
After completing this Quickstart lesson, you will:
Getting started with KRL can be a big leap because there are so many things that are different about programming in KRL:
The result of these properties is a programming model that more closely resembles programming cloud-based persistent objects than anything else. We call these persistent computational objects "picos".
KRL is executed by the Kinetic Rules Engine (KRE), an open-source, cloud-based rule processing system. All of the properties listed above are present in any KRE system.
To be executed, a ruleset must be
To complete the Quickstart, you will need
The styling of the account creation and OAuth authorization page is different than the KRL Developer Tools page styling. This is normal in an OAuth situation.
Once you create your account, the minimum rulesets for running the pico and the KRL Developer Tools will have been installed. After authorizing the KRL Developer Tools you should see the main page:
Do the following:
gitrepo for your KRL rulesets and put it on GitHub. You can create a different repo for each ruleset if you like or create one repo and put multiple rulesets in it.
Create file in your ruleset repo called
hello.krl and put the following in it:
Use one of the methods in Tips for Developers to validate (parse) your ruleset.
Installing and using the KRL command line parser can be a real time saver if you're going to be writing several rulesets. Checking in and trying to execute rulesets that don't parse is one of the primary frustrations of beginning KRL developers.
Getting your parsed ruleset into GitHub is a great first step, but the rules engine doesn't know anything about it. Registering a ruleset gives it a Ruleset ID (RID) in the rules engine so that other users can install and run it.
To register the ruleset, click on the "Registered Rulesets" menu item in the KRL Developer tools, you will see this page that shows all your registered rulesets and a menu item to register a new ruleset:
When you click on "Register a new ruleset" you'll see this page:
You should enter the URL of the ruleset you saved in the last section. If you saved your ruleset in GitHub, ensure that you enter the raw URL.
After you press "Register Ruleset" you'll be returned to the list of registered rulesets. The ruleset you just registered should be in the list:
Note that registering a ruleset creates both
dev versions of the RID which can be updated independently. You can use different RID versions to create a production copy and a development copy of the ruleset.
The ruleset is now registered and ready for use.
You only need register a ruleset once. Once the RID is created, you can use the KRL Developer Tools to update the URL if you change the location where you're storing it.
Registering a ruleset tells the rules engine about it, but doesn't put in any pico so it can be run. Installing the ruleset in a pico is a separate activity. Registering rulesets is a developer activity, while installing them is a user activity. As a developer, you're in both roles, so you have to do both. Consequently, the next step is to install your ruleset. We're going to install it in the same pico that we're running the KRL Developer Tools from.
When you click on Installed Rulesets, you'll see a page that lists all of the installed rulesets and a menu item to install a new ruleset like so:
When you click on "New Ruleset" you will have a form in which you can type the RID of the ruleset to install. For now, you should stick with the
prod version of the RID.
When you click "Install" you'll be taken back to the list of installed rulesets:
Clicking on the ruleset you just installed will show you information about it (and give you a button for uninstalling it if you choose):
When the rules engine reads a ruleset from the URL where it is located, the rules engine parses it, optimizes it, and caches the result. The next time the ruleset engine needs the ruleset it uses the cached copy, saving time in getting, parsing, and optimizing. This presents a challenge to the developer since changing the KRL in the ruleset doesn't tell the rules engine that new code is available.
One frustrating part of using GitHub for a rule repository is that changes that are checked in can sometimes take several minutes to be seen in the raw URL. Even if you have flushed the ruleset from the rules engine, if Github returns the old content, you'll see the old behavior. You can't really do anything but wait this out.
You can use the KRL Developer Tools to flush any ruleset you've registered, Click on "Registered Rulesets" and then on the ruleset you want to flush.
Clicking "Flush" will flush the selected ruleset.
The rules engine has an API for flushing rulesets so you can tell it that the code has changed. The Tips for Developers gives instructions on how to use the API to flush rulesets. I usually take the time to set up a post-commit hook in GitHub when I use the GitHub repository for my rulesets so that a soon as I check them in, they have been flushed from the rules engine. This saves countless frustrating moments trying to figure out why your changes are being seen in the rules engine when in fact you just forgot to flush the ruleset from the rules engine.
See Debugging KRL Rulesets for detailed information.
After completing this Quickstart you should continue with the Pico Programming Lessons.