Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: modernize for 0.52.2

...

Code Block
http://localhost:8080/sky/event/citdel5gz00012aaoo5ucc613KpxGihCMrQa2ncYi3jgQmc/1556/echo/hello

Breaking this URL into components:

  • "http://" identifies HTTP as the protocol
  • "localhost:8080" is the domain name and port of the pico engine which hosts the pico
  • "sky/event" identifies this as an event for the pico
  • "citdel5gz00012aaoo5ucc613KpxGihCMrQa2ncYi3jgQmc" is one of the pico's event channel identifiers (ECI) (yours will be different)
  • "1556" is an arbitrary string which serves as an event identifier (EID) and correlation ID. (useful when looking at logs)
  • "echo" identifies the domain of the event
  • "hello" identifies the type of the event

...

Code Block
http://localhost:8080/sky/cloud/citdel5gz00012aaoo5ucc613KpxGihCMrQa2ncYi3jgQmc/hello_world/hello?obj=Bob

...

Code Block
http://localhost:8080/sky/event/citeh9si400022aao04assjxy3BoZqz78hFuDtzAVuQ8ora/5/echo/hello

You can use the URL in any Internet client. For example, you could use it in the `curl` command in a Bash shell.

...

When you develop a ruleset, you may choose to use the "Testing" tab of the "My Picos" page which can provide a simple UI for your event. The "Testing" tab works by querying your ruleset to see if it shares the name __testing and if it does, it parses the structure that __testing points to and builds simple forms to test each of the queries and events which the structure defines.

...

You should see entries like this onethese:

Code Block
[DEBUGEPISODE_START] {ck4yo437i000q86ph3w9n53cy rid: 'hello_world',
  event: 
   { eci: 'citeh9si400022aao04assjxy',
     eid: '5',
     domain: 'echo',
     type: 'hello' } } fired

This console log may be useful in debugging events.

...

| event/3BoZqz78hFuDtzAVuQ8ora/__testing/echo/hello
[DEBUG] ck4yo437i000q86ph3w9n53cy | event received: echo/hello attributes {"_headers":{...
[DEBUG] ck4yo437i000q86ph3w9n53cy | event added to pico queue: ck4x66ydv0000vzphc99n18pq
[DEBUG] ck4yo437i000q86ph3w9n53cy | event being processed
[DEBUG] ck4yo437i000q86ph3w9n53cy | rule added to schedule: hello_world -> hello_world
[DEBUG] ck4yo437i000q86ph3w9n53cy | rule selected: hello_world -> hello_world
[DEBUG] ck4yo437i000q86ph3w9n53cy | fired
[DEBUG] ck4yo437i000q86ph3w9n53cy | event finished processing
[DEBUG] ck4yo437i000q86ph3w9n53cy | {"directives":[{"options":{"something":"Hello World"},"name":"say","meta":...
[EPISODE_STOP] ck4yo437i000q86ph3w9n53cy

This console log may be useful in debugging events.

For example, try introducing a typo in the URL for the event, say by spelling "echo" incorrectly as "ecco". In the console log, you will see that the event is received, and the Pico selected (based on its ECI), but you will not see that the event has fired.

...

Code Block
http://localhost:8080/sky/cloud/citeh9si400022aao04assjxy3BoZqz78hFuDtzAVuQ8ora/hello_world/hello?obj=Bob

...

  • you may be using a different domain (other than "localhost")
  • you may be using a different port (other than "8080")
  • you will be using a different channel identifier (your ECI will not be "citeh9si400022aao04assjxy3BoZqz78hFuDtzAVuQ8ora")
  • you may be using a different value for the expected argument named "obj" (not other than "Bob")

Enter your URL into the location line of your browser, or use it in a `curl` command in a Bash shell.

...

Congratulations! You know how to send queries to a pico, either directly using a URL, or through the "Testing" tab of the UI.

More about logs

KRL provides an operator, klog(), which allows us to print information into the logs. It is an operator, rather than a statement, so it is applied to an expression. It prints into the log the message passed to it as an argument, followed by the value of the expression on which it operates. Finally, it returns the value of the expression on which it operates, unchanged. This makes it easy to add to or remove from your KRL code without changing its meaning.

...

Code Block
    __testing = { "queries": [ { "name": "hello", "args": [ "obj" ] },
           
                   { "name": "__testing" } ],
                  "events": [ { "domain": "echo", "type": "hello",
                                "attrs": [ "name" ] } ]
                }

After making these changes to your ruleset, be sure to validate it, then push your change, and re-install into your pico.

With these changes, refresh the "Testing" tab and you can now enter a value into the box whose placeholder is "name" before clicking on the "echo/hello" button to send the event.

Image Removed

Examine the terminal or console from which you launched your engine. You will see the expected message from the klog operator, which will look like this (embedded in other logging messages, just before the rule fires):

Code Block
[DEBUG] { rid: undefined,
  event: 
   { eci: 'ciu4b6zui0001jfs0nmki6z1y',            { "name": "__testing" } ],
                eid: '5',
     domain: 'echo' "events": [ { "domain": "echo", "type": "hello",
     type: 'hello' } } rule selected: hello_world -> hello_world [KLOG] our passed in name:  Bob [DEBUG] { rid: 'hello_world',   event:     { eci"attrs": 'citeh9si400022aao04assjxy',
     eid: '5',[ "name" ] } ]
      domain: 'echo',      type: 'hello' } } fired

Using the "Logging" tab

Click on the "Logging" tab for your pico.

Image Removed

Notice that logging is disabled. The ruleset required for logging is pre-registered in your pico engine. Click on the "Rulesets" tab, and notice that it appears in a dropdown list named "Available Rulesets".

Image Removed

Click on the "install ruleset" button to install the "io.picolabs.logging" ruleset in your pico.

Click again on the "Logging" tab.

Image Removed

Logging is now available for this pico, but is turned off. Click the "On" button, and refresh the "My Picos" page.

Image Removed

...

 }

After making these changes to your ruleset, be sure to validate it, then push your change, and re-install into your pico.

With these changes, refresh the "Testing" tab and you can now enter a value into the box whose placeholder is "name" before clicking on the "echo/hello" button to send the event.

Image Added

Examine the terminal or console from which you launched your engine. You will see the expected message from the klog operator, which will look like this (embedded in other logging messages):

Code Block
[DEBUG] ck4yoteoc001086phe0g21fz2 | rule selected: hello_world -> hello_world
[KLOG] ck4yoteoc001086phe0g21fz2 | our passed in name:  "Bob"
[DEBUG] ck4yoteoc001086phe0g21fz2 | fired

Using the "Logging" tab

Click on the "Logging" tab for your pico.

Image Added

Notice that logging is disabled. The ruleset required for logging is pre-registered in your pico engine. Click on the "install" link to install the ruleset into your pico.

You should see all of the recent episodes for your pico. Click to open the ones for the "echo:hello" event and the "hello" query:

Here we see the logging for a query and an event.

...