This page is unfinished. For a taste, see the engine module documentation.
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.
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. It gives attributes:
parent_eci: The ECI from the picoto the respective child
name: The child pico's name
id: The id of the child pico
eci: The main wrangler ECI for the child pico
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.
id: The ID of the pico
eci: The main wrangler ECI of the pico
name: The name of the pico
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.
Parameter | Datatype | Description |
---|---|---|
eci | String | The ECI to send the event to |
mod | String | The ruleset to send the event to |
func | String | The name of the function to query |
params | Object | The parameters to be passed to the function on the target pico. Given as an object with parameter name mapped to argument value. |
_host | String | The target pico's host |
_path | String | An optional different path for the beginning of the underlying URL |
_root_url | String | The root URL for the request. Defaults to meta:host (the pico engine itself). |
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
Events/Rules
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.
Bolded attributes are required.
Ruleset Events
installRulesets
(Domain: wrangler, Type: install_rulesets_requested)
Installs the given rulesets in the pico that receives this event.
eventAttrs:
Attribute | Datatype | Required | Additional Description |
---|---|---|---|
<rids> | <array> OR <string> | YES | The array is an array of strings, where each string represents the name of the ruleset (the RID) to be installed. You may alternatively provide a single string that is separated by semicolons. Multiple rulesets are not required. |
Directives Returned:
send_directive("rulesets installed", { "rids": /* An array of rids that were installed*/ });
Raised Events:
Domain | Type | Attributes Added |
---|---|---|
wrangler | ruleset_added | { "rids": /* An array of rids that were installed*/ } |
Sent Events:
None
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.
Attribute | Datatype | Description |
---|---|---|
name | String | The name for the new child pico. Will generate a random name if not provided. |
rids | String String Array | 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"). |