Skip to content

Latest commit

 

History

History

nodejs-simple-processing

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

nodejs-simple-processing

This examples relies on the data produced through the nodejs-event-gateway example. It consumes the "events" log, computes aggregates and pushes them to the "stats" log in real time.

Usage

Install dependencies

npm install

Run the processor

node index.js

From another terminal, with nodejs-event-gateway running, simulate events on the gateway

curl "localhost:9000/?type=view"
curl "localhost:9000/?type=view"
curl "localhost:9000/?type=click"
curl "localhost:9000/?type=sale"

From yet another terminal, follow the contents of the "stats" log with Styx CLI

styx logs read stats --follow

You should see stat counters update as you send requests.

{"view":1}
{"view":2}
{"view":2,"click":1}
{"view":2,"click":1,"sale":1}

The latest values can read by fetching the last record from the stats log

curl "localhost:7123/logs/stats/records?whence=end&position=-1" -s | jq .
``