Question

Is there anyone using the nice pinoccio from www.pinocc.io ?

I want to use it to post data into an apache couchdb using node.js. So I'm trying to poll data from the pinnocio API, but I'm a little lost:

  • schedule the polls
  • do long polls
  • do a completely different approach

Any ideas are welcome

Pitt

Was it helpful?

Solution

Sure. I wrote the Pinoccio API, here’s how you do it

https://gist.github.com/soldair/c11d6ae6f4bead140838

This example depends on the pinoccio npm module ~0.1.3 so make sure to npm install again to pick up the newest version.

you don't need to poll because pinoccio will send you changes as they happen if you have an open connection to either "stats" or "sync". if you want to poll you can but its not "real time".

sync gives you the current state + streams changes as they happen. so its perfect if you only need to save the changes to your troop while your script is running. or show the current and last known state on a web page.

The solution that replicates every data point we store is stats. This is the example provided. Stats lets you read everything that has happened to a scout. Digital pins for example are the "digital" report. You can ask for data from a specific point in time or just from the current time (default). Changes to this "digital" report will continue streaming live as they happen, until the "end" time is reached, or if "tail" equals 0 in the options passed to stats.

hope this helps. i tested the script on my local couch and it worked well. you would need to modify it to copy more stats from each scout. I hope that soon you will be able to request multiple reports from multiple scouts in the same stream. i just have some bugs to sort out ;)

OTHER TIPS

You need to look into 2 dimensions:

  • node.js talking to CouchDB. This is well understood and there are some questions you can find here.
  • Getting the data from the pinoccio. The API suggests that as long as the connection is open, you get data. So use a short timeout and a loop. You might want to run your own node.js instance for that.

Interesting fact: the CouchDB team seems to work on replacing their internal JS engine with node.js

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top