Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Child pages (Children Display)

Installation Video

Widget Connector
overlayyoutube
_templatecom/atlassian/confluence/extra/widgetconnector/templates/youtube.vm
width400px
urlhttps://www.youtube.com/watch?v=8sPAS6RBps4&t=14s
height300px

Installation

Normally, this will be a single command, shown here:

Code Block
npm install -g pico-engine

To do this you will need to first install node. You may need to upgrade your version of node to the latest version if it is already installed.

If you experience permission problems, consult this page of the npm Docs. Depending on your OS, you may need to install as root. There is also a troubleshooting section in the pico-engine code repository.

...

Code Block
ruleset hello_world {
  meta {
    name "Hello World"
    description <<
A first ruleset for the Quickstart
>>
    author "Phil Windley"
    logging
on     shares hello
  }
   
  global {
    hello = function(obj) {
      msg = "Hello " + obj;
      msg
    }
  }
   
  rule hello_world {
    select when echo hello
    send_directive("say", {"something": "Hello World"})
  }
   
}

...

Line 1: A ruleset starts with the ruleset keyword, followed by the ruleset identifier or RID. In this case, the RID is hello_world. The body of a ruleset is contained within the curly brackets opening at line 1 and closing at line 24. By convention, this ruleset will be stored in a file named hello_world.krl (the RID followed by a .krl file extension).

Lines 2-109: A ruleset usually contains a meta block giving information about the ruleset. This information includes data like the ruleset name and author, as well as pragmas that affect the ruleset's behavior. For example, this ruleset has a shares pragma saying which global functions are shared with the outside world. 

Lines 1211-1716: A ruleset usually contains a global block which globally binds values to names, some of which may be shared. In this case, the name hello is bound to a function value and is shared.

Lines 1918-2221: A ruleset usually contains one or more rules. In this case there is one rule named hello_world which will be watching for events with domain echo and name, or type, hello.

...

A recommended workflow for writing KRL is found in KRL Programming Workflow. This example uses the local filesystem of the author to host KRL source code. 

...

Your URL will be different from the one shown here.

If you're using something like GitHub to host your rulesets, be sure that you supply the "raw" URL. The raw URL returns the file without any page chrome.  For example, this is a raw and cooked example of the same ruleset.  If you're hosting your rulesets on Amazon S3, be sure the URL is public and can be retrieved using a browser. 

...

Having completed this Quickstart, you are prepared to continue with the pico-engine NEXT Events and Queries Lesson