Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: remove references to `rs_attrs`

...

Code Block
linenumberstrue
  rule create_child_pico {
    select when gen_rs ruleset_needed
    pre {
      rid = event:attr("rid")
    }
    fired {
      raise wrangler event "new_child_request" attributes {
        "name": random:uuid(), "rids": [meta:rid], "rid_to_gen": rid
      }
    }
  }
  rule evaluate_expression {
    select when wrangler new_child_created
    pre {
      rid = event:attr("rs_attrs"){"rid_to_gen"})
      eci = event:attr("eci")
      url = <<#{meta:host}/sky/cloud/#{eci}/gen_rs/rs.txt?rid=#{rid}>>
      picoId = event:attr("id")
    }
    engine:registerRuleset(url=url) setting(rid)
    fired {
      raise wrangler event "child_deletion" attributes event:attrs
    }
  }

...

The attribute expr provided by the user is passed along as an extra attribute when we raise wrangler event: "new_child_request". This extra attribute is passed through the sequence of events we are initiating in wrangler, in a map named rs_attrs. We pick it up in the next rule:

Code Block
linenumberstrue
  rule evaluate_expression {
    select when wrangler new_child_created
    pre {
      expr = event:attr("rs_attrsexpr"){"expr"}
      e = expr.math:base64encode().replace(re#[+]#g,"-")
      eci = event:attr("eci")
      url = <<#{meta:host}/sky/cloud/#{eci}/gen_rs/rs.txt?expr=#{e}>>
      picoId = event:attr("id")
    }
    every {
      // actions unchanged
    }
    fired {
      raise wrangler event "child_deletion" attributes event:attrs
    }
  }

Line 4 retrieves the user-supplied expression from the rs_attrs attribute that has the attributes that have been passed along.

Since line 7 is embedding the expression in a URL, we Base 64 encode it in line 5. The function rs will then expect the user-supplied expression as its argument.

...