Collections API

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.

"io.picolabs.collection" must be installed on your pico for these to work

Functions


members

Returns all of the established subscriptions that belong to the collection

Returns

An array of subscription maps

Parameters

None

Returns 

An array of established subscriptions.

Example
membersArray = collection:members()
[
  {
    "Rx_role": "collection",
    "Tx_role": "member",
    "Tx_host": "http://10.37.94.198:8080",
    "Id": "cjyf4v8hd00vuokbz0oz2eb1z",
    "Tx": "YVreELgbGjjFhQYqgGcRKm",
    "Rx": "VQDgK9YF1FPvj7fkwgt94H",
    "Tx_verify_key": "JAhWwk19WqBysronQPD6zbbncLDo7UHT22oaKcZ2dheB",
    "Tx_public_key": "5iArABfAiG8u4SNBhaCzcwtXpauLULfhMkJfHWTkMhe2"
  },
  {
    "Rx_role": "collection",
    "Tx_role": "member",
    "Tx_host": "http://10.5.164.58:8080",
    "Id": "cjygcdpqs0010q3bz05gc68gb",
    "Tx": "RrS9tyHwt8mBuTe7e33BMY",
    "Rx": "CuGaocn4tR2Q32tgBvmBjt",
    "Tx_verify_key": "EYdZVZhZ5cWwWtwCLuUpAnYXjXgFjRDphg1fCxNJVvBc",
    "Tx_public_key": "74Hmo86S5ifVtSyJaCr4wBy6j4sFeJiHSFLaGSUEV5WF"
  }
]
*/

Received Events


send_event_to_collection_members

wrangler:send_event_to_collection_members

This event relies on the internal Rx_role of the collection to send an event to all the members in the collection across the subscription from the collection pico to the members.

Attributes

AttributeDatatypeDescription
domainStringThe domain of the event you want to send

type

StringThe type of the event you want to send
attrsMapThe attrs of the event you want to send

Directives Returned

Will return empty directives. 


new_role_names

collection:new_role_names

Can be used to create a different Rx_role - Tx_role pairing for the collection. By default the collection pico's Rx_role is "collection" and member picos have "member" roles. It will only be successful if the collection has no members.

Attributes

AttributeDatatypeDescription
Rx_roleStringThe new role for the collection pico to take in the collection subscriptions.
Tx_roleStringThe new role for the member picos to take in the collection subscriptions.

Directives Returned

Will return empty directives. 


Copyright Picolabs | Licensed under Creative Commons.