Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

This quickstart will help you get your KRL programming environment set up and working. 

The old Quickstart for SquareTag is still available. 

Concepts

Getting started with KRL can be a big leap because there are so many things that are different about programming in KRL:

  • KRL is a rule-based language. 
  • KRL primarily follows an event-based programming model. 
  • KRL programs execute with a cloud-based model; there is no way to execute them from the command line.
  • KRL programs are loaded from the cloud using HTTP. 
  • KRL programs execute in a system where identity is pervasive; all events are raised on behalf of a specific entity.
  • KRL programs have built-in, entity-specific persistent storage; there is no need for external databases.

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), a 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

  • available via HTTP and identified by a URL
  • The URL must be registered with one or more instances of KRE and given a ruleset ID or RID
  • The RID must be installed in one or more picos
  • The pico must receive a request via the Sky Cloud API or the Sky Event API

Prerequisites

To complete the following Quickstart you will need

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

Writing KRL

Do the following:

  1. Create a git repo 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. 
  2. Create  file in your ruleset repo called hello.krl and put the following in it:

    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 is active {
        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.

    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 Github. 

 

 

Registering Your Ruleset

Installing the Ruleset

Testing the Ruleset

Debugging the Ruleset

 

  • No labels