Fun real-time app to show the amount of caffine consumed at an event and to showcase the use of some intersting technologies
Temp set up instructions:
- Download Event Store from Downloads
Latest build at time of writing: Latest build
-
Unzip, navigate to bin folder and fire up EventStore.SingleNode.exe
-
Navigate to http://localhost:2113/
-
Click on New projection
-
Enter CountByEventType for the Name and this code in the source input:
fromAll().foreachStream().whenAny(function(state,event) { //filter out system streams if(event.streamId.indexOf("$") != 0) { var type = event.eventType; //probably dont want to log types like $stream-created if(type.indexOf("$") != 0) { if(state[type]) { state[type]++; } else { state[type] = 1; } } }
return state;});
-
Fire up Node, order some drinks then go to: http://localhost:2113/projection/CountByEventType/state?partition=caffine-drinks and see how many drinks have been ordered...
curl -i -X POST --data-binary @./es/projections/drink-create-5min-stream.js http://127.0.0.1:2113/projections/persistent?name=drink-5mins&type=native:EventStore.Projections.Core.Standard.IndexStreams
drink-5mins projections state can then be found here: http://127.0.0.1:2113/streams/$projections-drink-5mins-state?format=json latest eg: http://127.0.0.1:2113/streams/$projections-drink-5mins-state/event/7?format=json
drink-timeseries-5 stream of emitted 5 min aggregates of events can be found here: http://127.0.0.1:2113/streams/drink-timeseries-5/event/6?format=json
curl -i -X POST --data-binary @./es/projections/drink-agg-5min-stream.js http://127.0.0.1:2113/projections/persistent?name=drink-5mins-agg&type=native:EventStore.Projections.Core.Standard.IndexStreams
drink-5mins-agg projections state can then be found here: http://127.0.0.1:2113/streams/$projections-drink-5mins-agg-state?format=json latest eg: http://127.0.0.1:2113/streams/$projections-drink-5mins-agg-state/event/7?format=json
On cloud:
http://ec2-46-137-34-123.eu-west-1.compute.amazonaws.com/
curl -i -X POST --data-binary @./es/projections/drink-create-5min-stream.js http://ec2-46-137-34-123.eu-west-1.compute.amazonaws.com:2113/projections/persistent?name=drink-5mins&type=native:EventStore.Projections.Core.Standard.IndexStreams
curl -i -X POST --data-binary @./es/projections/drink-agg-5min-stream.js http://ec2-46-137-34-123.eu-west-1.compute.amazonaws.com:2113/projections/persistent?name=drink-5mins-agg&type=native:EventStore.Projections.Core.Standard.IndexStreams