Versions Compared

Key

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


Note

This page is unfinished. For a taste, see the engine module documentation.

Table of Contents
maxLevel4
indent15px

Wrangler is an operating system written in KRL for picos. Wrangler provides developers a way to programmatically and easily manage picos.

To use Wrangler as a module, add "use module io.picolabs.wrangler alias wrangler" in your meta block.

Functions

For all functions, enter the parameters in the order listed.

Italicized parameters are optional.

children

Returns an array of the children of the pico. Has optional parameter "name" which returns just the attributes for the child with the specific name if it exists, otherwise it returns attributes on every child if not provided.

Parameters

...

Returns

An array containing a map for each returned pico. Each map contains:

parent_eci: The ECI from the pico to the respective child. Should be used for parent-child interaction.

name: The child pico's name

id: The id of the child pico

eci: The main wrangler ECI for the child pico

Code Block
languagejs
themeConfluence
children = wrangler:children()
/*
[
  {
    "parent_eci": "CyrmdG4PkiVYRUo2K69k2E",
    "name": "Section CS462-1 Pico",
    "id": "cjh6pbzun005zvde06bwy2pci",
    "eci": "JfcEBxEK5WDKA69Bvach4Y"
  },
  {
    "parent_eci": "Tg5ULPBYByJjsEoKpfsbQ2",
    "name": "Section CS462-2 Pico",
    "id": "cjh6pc28r0067vde04qd23t6o",
    "eci": "56S414r4Uq4kGx6Xi1qmSs"
  }
]
*/

myself

Returns a map giving basic meta information about the pico. This information includes the pico's ID, ECI, and name.

Returns

A map giving basic information about a pico with the following contents:

id: The ID of the pico

eci: The main wrangler ECI of the pico

name: The name of the pico

Code Block
languagejs
themeConfluence
myself_result = wrangler:myself()
/*
{
  "id": "cjhtji2op009hpkrq35bcpodh",
  "eci": "4bUS9W4HY5S1YfsAM9Ygw5",
  "name": "Front Porch"
}
*/

skyQuery

A user friendly way to make an HTTP request between picos. It provides cleanup and returns the error if the returned HTTP status was not 200.

It is mainly used to programmatically call functions inside of other picos from inside a rule. However, do not have a pico query itself, or have two picos query each other simultaneously. See Accessing a Function Shared by Another Pico for more information.

Parameters

...

Returns

The result of the function queried for.

Code Block
languagejs
themeConfluence
pre {
	eci = event:attr("eci")
	wellknown = wrangler:skyQuery( eci , "io.picolabs.subscription", "wellKnown_Rx")
}
if wellknown{"error"}.isnull() then
	noop()
always {
	ent:savedWellknown := wellknown;
}
/*
Query the the function wellKnown_Rx() in the ruleset "io.picolabs.subscription" through the pico ECI given in the event attribute "eci".
*/

pre {
  eci = eci_to_other_pico;
  args = {"arg1": val1, "arg2": val2};
  answer = Wrangler:skyQuery(eci,"my.ruleset.id","myFunction",args);
}
if answer{"error"}.isnull() then noop();
fired {
  // process using answer
}

Defactions

...

When a rule raises an event in the postlude, it will also pass along all the attributes it received (including any attributes not used in that event) in addition to any new information that may be relevant to other rules.

Raised Events are events that the rule will directly raise.

Sent Events are events that the rule will send elsewhere.

Italicized attributes are optional.

Ruleset Events

installRulesets

Domain: wrangler
Type: install_rulesets_requested

Installs the given rulesets in the pico that receives this event.

Attributes

...

Array

String

...

Directives Returned
Code Block
send_directive("rulesets installed", { "rids": /* An array of rids that were installed*/ });
Raised Events

...

Code Block
"rids": /* An array of rids that were installed*/

Pico Events

createChild

Domain: wrangler
Type: child_creation or new_child_request

Creates a new child for this pico with optional arguments for the child's name, and rulesets to install on it upon creation.

...

String Array

String

...

The RIDs of the rulesets to be installed on the new child pico. Each RID can be an entry in an array, or in a semicolon denoted list (e.g. "io.picolabs.ruleset_one;io.picolabs.ruleset_two").

Raised events

...