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 3 Next »

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

 


Assume that a rule has been selected with an event attribute 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 raise an event using the with keyword. The following KRL would raise an event with event attributes:

 

raise explicit event "testEventAttributes" for a1x100
   with foo = "bar";

 

This attribute could be used in the following rule:

 

rule testEventAttributes {
   select when explicit testEventAttributes
      pre {
         foo = event:attr("foo"); // Equals bar at this point
      }
      noop()
}
  • No labels