Versions Compared

Key

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

Event attributes are one of the most important sources of data for computation in a rule because they convey information about the context of the event. In Chapter 3 (of the book The Live Web: Building Event-based Connections in the Cloud (download PDF)), you saw how eventexes can use expressions on event attributes as filters for which events match a given primitive eventex. Event attributes can also be used in KRL expressions. To avoid conflict with user-declared variables names, event attributes are namespaced using the keyword event. (Prepending the namespace name and a colon to a variable forms namespaces in KRL. This is used in three ways: a namespace as a built-in library (such as event), a namespace for a KRL module, the namespace ent for entity variables)


Assume that a rule has been selected with an event attribute named url. The following KRL expression could be used to extract the domain name from the url attribute:
 

event:attr("url").extract(re#http://(\[^/?]+)#)


Event attributes can be sent to an event in different ways. One way is by using GET or POST requests with the HTTP library. The other way is to include attributes when raising an event. The following KRL would raise an event with event attributes:

...