Versions Compared

Key

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


...

Info
titleEngine Compatibility

This library has not been completely ported to the Node pico engine. However, it supports attr(), attrs, and a different form of send(). Scheduled event functions and actions are now part of the schedule library.

send is asynchronous, supports attrs values of any type, and accepts an optional second parameter namedhost:

Code Block
languagejavascript
themeConfluence
event:send({"eci":"cj3btnlyj0001y6idgl4api8f", "domain":"test", "type":"test", "attrs":{}})
event:send({"eci":"cj3btnlyj0001y6idgl4api8f", "eid":"test", "domain":"test", "type":"test"}, null)
event:send({"eci":"cj3btnlyj0001y6idgl4api8f", "eid":"test", "domain":"test", "type":"test"}, "http://localhost")
event:send({"eci":"cj3btnlyj0001y6idgl4api8f", "eid":"none", "domain":"test", "type":"test"}, host="https://localhost:8080")

If the eid is omitted (null) or "none","null", or "", it will default to a random uuid.


The event library provides access to event properties, a function for getting attribute values, and an action for sending events.

event properties

The event library provides five properties:

event:domain

The value of this property is the domain which caused the rule to select.

event:name

The value of this property is the event type (or name) which caused this rule to select.

event:eid

The value of this property is the event identifier from the event to which this rule is reacting.

event:time

The value of this property is the time at which the event was received by the pico-engine.

event:attrs

The value of this property is a map of the attributes sent with the event to which this rule is reacting.

event function

event:attr

When this function is called with an attribute name, it returns the attribute value.

event action

event:send

As defined in the compatibility box above, this allows rules to send an event to another pico, whether on the same pico-engine or not.

Warning
titleolder engines

From this point, this page describes older pico engines.



Table of Contents
maxLevel2

...

  • event:attr() - returns a specific event attribute. The function takes the name of the attribute to be returned as its sole argument, and returns null if not found.
  • event:attrs () - returns all the event attributes as a map.

...

Code Block
languagejavascript
themeConfluence
rule dispatch {
  select when explicit schedule_inquiry
    foreach subscribers setting (subscriber)
      pre {
        resp_cookie = math:random(99);
      }
      event:send(subscriber,"schedule","inquiry")
          with attrs = {"from" : event:attr("From"),
                        "message": event:attr("Body"),
                        "cookie": resp_cookie
                        };
      }
      always {
        raise explicit event "subscribers_notified" on final
      }
}

The difference between raising an explicit event on final and using the system generated system:send_complete event shown above might not be obvious. 

...

Code Block
languagejavascript
themeConfluence
rule update_vehicle_data {
  select when fuse updated_vehicle
  pre {
    vid = event:attr("vehicleId");
	keyvalue = event:attr("keyvalue");
    vehicle_info = event:attr("value").decode();
  }
  {send_directive("Updated vehicle data for #{keyvalue} in fleet") with
     id = vid and
     values = vehicle_info and
	 keyvalue = keyvalue and
	 namespace = carvoyant_namespace;
  }
  always {
    set ent:fleet{[keyvalue, vid]} vehicle_info
  }
}

...


Scheduled Event Functions

A scheduled event is created in the rule postlude.

...