Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: (Classic)

Learning Objective

After completing this lesson you will be able to:

  • Explain channels and use the Developer Tools console to manage them.
  • Send events and queries to a pico on custom channels using curl, the event console and a browser.
  • View events and queries in pico logs.
  • Log variables inside rules using log() and klog() functions

Prerequisites

Create a Channel

Channels are the way picos receive events. Picos can have multiple channels. Best practice is to create a separate channel for each purpose or correspondent.  Each channel can have a name and a type. 

...

Congratulations! You just created your first Channel. Now you have a designated channel to raise events to. You can read more about Channels here.

Raising Events to the Channel

Open the Kynetx Event Console app in a new tab in Google Chrome.

...

Way to go! You just raised your first Event to a Channel you created. But wait!! We don't see the execpted string, "Hello World", in the Response (because of our capitalized domain bug).

View Event in Pico Logs

Let's debug the rule set with Pico Logs in devtools.

...

Directives allow picos to direct endpoints to react a certain way to an event.  Our rule's directive just says hello, but it could be used to do more complex things. Directives allow the program's logic to be placed in the rules, not in the end points.  Placing logic in the rules provides loose coupling with easier scaling and maintenance.  

Logs

The klog() operator allows you to log or print values to your pico logs.

...

Awesome Sauce! Armed with a knowledge of logs, now your ready to wage war on KRL bugs.

Raise Event with Sky API

The Sky Event API allows you to raise your event in the form of a web hook. We will raise an event in your browser as well with curl and view the results in Pico Logs.

...

You should have the same results but in your terminal.

Querying the hello Function

The Sky Cloud API allows you to query a ruleset's functions.

...

Way to go, you just queried your hello() function in hello_world ruleset.

Congratulations!

You have completed Events and Queries lesson ...

Challenges

  1. Create a new rule that selects on a custom domain, raise an event to your rule and view your new rule in Pico logs to guarantee its firing.
  2. Modify hello function to print, "Im alive", after your name.

...