Versions Compared

Key

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

...

Assuming that we have this statement in the meta block of our ruleset:

Code Block
    use module io.picolabs.wrangler alias wrangler

We can use the picoQuery function (), provided by Wrangler, as shown in the following rule fragment:

Code Block
rule query_rule {
  pre {
    eci = eci_to_other_pico;
    args = {"arg1": val1, "arg2": val2};
    answer = wrangler:picoQuery(eci,"my.ruleset.id","myFunction",{}.put(args));
  }
  if answer{"error"}.isnull() then noop();
  fired {
    // process using answer
  }
}

This will only succeed if my.ruleset.id has shared myFunction in its meta block.

Wrangler's picoQuery() function will use ctx:query() to query the other pico if it is on the same pico engine. If it is not, picoQuery() will send an HTTP GET request to the other pico, which includes the RID and function name, and the named argument values which the remote function expects. It will check the HTTP return code, and decode the returned content, finally returning it to our code as KRL data. If an error is detected, the return value will instead be a map with key error. HTTP request may also include the keys httpStatuspicoQueryErrorpicoQueryErrorMsg, and picoQueryReturnValue.

...