Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: show a housekeeping technique

...

The policy for a testing channel should allow for the events that the rules in your ruleset select on, and all of the shared functions from the global block of your ruleset.

You can create this manually in the developer UI, or programmatically by adding a rule that selects on the wrangler:ruleset_installed event, and having that rule create a permissive channel specifically tailored to the rules and functions of the ruleset.

Instructions

Add an initialization rule to your ruleset, or add code like this to such a rule if you already have one.

...

Code Block
.filter(function(d){d != "wrangler"})

Keeping channels clean

In the instructions given, Wrangler will tag your channel with the RID of your ruleset.

Note that any dots in the RID will be changed to hyphens in the creation process, so while you can use meta:rid to create a channel, you would have to use this to find it later when you call the wrangler:channels(meta:rid.replace(re#[.]#,"-")) function.

Especially during the ruleset writing and debugging process, but sometimes also in operation, you may need to install the ruleset multiple times. Each time you do so, yet another channel with those tags will be created and added to the pico. Since the usual idiom for finding the channel id is wrangler:channels(tags).head().get("id") (alternatively, wrangler:channels(tags).head(){"id"}), you only really want your pico to have one such channel. This is particularly true if during debugging you find you need to make changes to the event/query policies!

The suggested way to do this is to add a terminal event to the initialize rule, and a rule to select on that event, like so:

Code Block
  rule initialize {
    select when wrangler ruleset_installed
      where event:attr("rids") >< meta:rid
    ...
    wrangler:createChannel(tags,eventPolicy,queryPolicy)
    fired {
      raise my_ruleset_event_domain_here event "channel_created"
    }
  }
  rule keepChannelsClean {
    select when my_ruleset_event_domain_here channel_created
    foreach wrangler:channels(tags).reverse().tail() setting(chan)
    wrangler:deleteChannel(chan.get("id"))
  }

This gets all of the channels with the same tags, except for the latest one created, and deletes them.

Related pages