Versions Compared

Key

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

...

A pico can have as many inbound channels as it needs. See Managing Channels for more information. A pico can only create and delete channels for itself.

...

For example, this KRL code creates a channel when the app_section_collection ruleset is installed into a pico (see the Pico to Pico Subscriptions Lesson for context):

Code Block
ruleset app_section_collection {
  ...
  global {
    ...
    tags = ["app_section_collection"]
    eventPolicy = {
      "allow": [ { "domain": "section", "name": "*" }, ],
      "deny": []
    }
    queryPolicy = {
      "allow": [ { "rid": meta:rid, "name": "*" } ],
      "deny": []
    }
  }
  rule initialize_section_collection_pico {
    select when wrangler ruleset_installed
      where event:attr("rids") >< meta:rid
    if ent:section_collection_pico_eci.isnull() then
      wrangler:createChannel(tags,eventPolicy,queryPolicy) setting(channel)
    fired {
      ent:section_collection_pico_eci := channel{"id"}
      ent:sections := {}
    }
  }
  ...
}

...

Note in line 5, the use of the array operator head() to convert the array of channels returned by the wrangler:channels() function into a single channel map.

...

For example, wrangler:rulesetMeta(“hello_world”) (which refers to the ruleset shown in the Pico Engine Quickstart page), would return this map:

...

picoQuery() is mainly used to programmatically call functions inside of other picos from inside a rule. However, deadlocks are possible due to its synchronous nature (e.g. do not let two picos query each other simultaneously). See Accessing a Function Shared by Another Pico for more information.

Parameters

...

Code Block
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(); // Check that it did not return an error
fired {
  // process using answer
}

...