Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: G/github -> GitHub

...

  1. An editor. There are KRL plugins for many popular editors
  2. A Github GitHub account
  3. An account on a KRE instance. The easiest way to do this is to use the Pico Labs-hosted instance of KRE

...

  1. Create a git repo for your KRL rulesets and put it on GithubGitHub. You can create a different repo for each ruleset if you like or create one repo and put multiple rulesets in it. 
  2. Create  file in your ruleset repo called hello.krl and put the following in it:

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


  3. Use one of the methods in Tips for Developers to validate (parse) your ruleset.

    Info

    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.


  4. Check your ruleset into GithubGitHub.

Registering Your Ruleset

Getting your parsed ruleset into Github 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. 

...

You should enter the URL of the ruleset you saved in the last section. If you saved your ruleset in GithubGitHub, ensure that you enter the raw URL. 

Info

A Github GitHub raw URL returns the file without any Github GitHub page chrome. For example, this is a raw and cooked example of the same ruleset.

...

Info

One frustrating part of using Github 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.

...

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 GitHub when I use the Github 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. 

...