Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Content added

Table of Contents
maxLevel3
excludeNotes

Notes

  • For all functions, enter the parameters in the order listed.
  • Italicized parameters are optional.
  • Received Events are events of the "wrangler" domain that Wrangler will respond to
  • Raised Events are events that can be selected on within any ruleset in the pico when they occur
  • Sent Events are events that the pico will send elsewhere as a result of triggering a Wrangler event.
Excerpt

Functions


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, 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

ParameterDatatypeDescription
eciStringThe ECI to send the query to
modStringThe ruleset to send the query to
funcStringThe name of the function to query
paramsMapThe parameters to be passed to the function on the target pico. Given as an object with parameter name mapped to argument value.
_hostStringThe host of the pico engine being queried.
Note this must include protocol (http:// or https://) being used and port number if not 80.
For example "http://localhost:8080", which also is the default.
_pathStringThe sub path of the url which does not include mod or func.
For example "/sky/cloud/", which also is the default.
_root_urlStringThe entire URL except eci, mod , func.
For example, dependent on _host and _path is
"http://localhost:8080/sky/cloud/", which also is the default. Defaults to meta:host (the pico engine itself).


Returns

Success: the result of the function queried for.

Failure: a map of error information which contains:


Code Block
languagejs
themeConfluence
{
	"error":"general error message",
	"skyQueryError":"The value of the 'error key', if it exists, of the function results"
	"skyQueryErrorMsg":"The value of the 'error_str', if it exists, of the function results"
	"skyQueryReturnValue":"The function call results"
}


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