This page will guide you through the steps necessary to obtain and operate your own Kinetic Rules Engine (KRE).
After completing this Quickstart lesson, you will:
*This section is copied verbatim from Quickstart (the one for the original KRE system)
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 your instance of the node pico-engine, 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
Prerequisite: you will need to install node (also known as Node.js) on your machine. Be sure that you are installing at least version 4. The installation includes npm, the node package manager, which you will use to install the pico engine. (Node.js is a trademark of Joyent, Inc. and is used with its permission. Picolabs is not endorsed by or affiliated with Joyent.)
Once you have npm and node on your machine, open a command line window and issue these two commands, which will install and start the node pico engine.
The node pico engine will spend some time initializing internal data structures before it starts its web server. After doing this, it will start a web server on port 8080.
Note that the web server displays the URL of its document root, ex. "http://localhost:8080" and then continues to run. As we will see later, messages will be logged to this console, so it is best not to close this command line window.
During the pico engine initialization, it creates a primary pico, naming it "Owner Pico" and then registers three rulesets and installs two of them in the owner pico. These are the minimum required for running the pico and the developer UI. You can visit the developer UI, "My Picos", at the address on which the pico engine is listening.
Your owner pico is represented by a rounded rectangle, which is placed on a canvas, allowing you to change its placement. Keep this tab open for use in registering and installing your ruleset, below.
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 a file in your ruleset repo called
hello_world.krl and put the code below into it.
A first ruleset, in a file named hello_world.krl:
Overall Structure of a KRL Ruleset
A ruleset is enclosed by the "ruleset" keyword, the ruleset identifier or RID, and curly braces, as shown above in lines 1 and 25. In this case, the RID is "hello_world".
A ruleset usually contains a "meta" block giving information about the ruleset and any names which it "shares" with the outside world (including other rulesets). Lines 2-10.
A ruleset usually contains a "global" block which binds values to names, some of which may be shared. Lines 12-17. In this case, the name "hello" is bound to a function value and is shared.
A ruleset usually contains one or more rules. Lines 19-23. In this case there is one rule named "hello_world" which will be watching for events with domain "echo" and type "hello".
Registering and Installing Your Ruleset
Installing a ruleset to a pico is properly a user function, but as a developer, you are functioning in both user and developer capacities.
View your Owner Pico by visiting the "My Picos" page (linked from the "Pico Bootstrap" page), as shown above.
Single click on the rounded rectangle which represents your Owner Pico. It opens up, giving you access to information about it.
The "About" tab will be used in subsequent lessons.
Now, click on the "Rulesets" tab. Enter the URL to the KRL source code in the box beside the button "install ruleset from URL" and click on that button.
Clicking on the "install ruleset from URL" will send an event to your pico. This event is captured by rules in the "io.picolabs.pico" ruleset, which will cause the pico engine to get your ruleset from the Internet, compile it, and register it.
Finally, the ruleset will be installed in this pico, as you can see when the page refreshes.
Notice that you are allowed to delete from the pico any ruleset that you install.
Having completed this quickstart, you should continue with Lesson 1. Events and Queries