I’ve been following Rob Ashton’s projection series (http://docs.geteventstore.com/#rob-ashton’s-projections-series), and I can get pretty far. I’ve been able to write events to the “ponies” stream, and create basic projections from that stream. For example, the following projection (PonyJumpCount) works just fine:
fromStream(“ponies”)
.when({
$init: function() { return { count: 0 } },
“PonyJumped”: function(state, event) { state.count += 1 }
})
Suppose I have two events in the “ponies” stream:
{ EventType: “PonyJumped”, Data: { Pony: “Pinkie Pie”, Distance: 13 } }
{ EventType: “PonyJumped”, Data: { Pony: “Rainbow Dash”, Distance: 13 } }
I can retrieve the state of the projection by a query to “/projection/PonyJumpCount/state”. The result, as you might imagine, is {“count”: 2}. Great.
Ashton goes on to demonstrate that projections can be used to partition streams:
fromStream(‘ponies’)
.whenAny(function(state, ev) { linkTo(‘pony-’ + ev.data.Pony, ev) })
I save this projection as “continuous”, with the “emit-enabled” flag turned on under the name “PonyPartition”. It processes each event, and creates the appropriate streams. I can query the streams “pony-Rainbow%20Dash” and “pony-Pinkie%20Pie” as expected.
But what I can’t get to work are projections that use the “fromCategory” function.
fromCategory(‘pony’)
.foreachStream()
.when({
“$init”: function(state, ev) { return { count: 0 } },
“PonyJumped”: function(state, ev) { state.count++ }
})
I name this projection “JumpingPonies”. The web interface reports that the projection has processed all events, and lists the number of cached partitions as 2. I’m looking to get the state of the projection for each of the streams of the “pony” category. In Ashton’s blog post (http://codeofrob.com/entries/creating-a-projection-per-stream-in-the-eventstore.html), he writes that a query to “/projection/JumpingPonies/state?partition=Rainbow%20Dash” should get me what I’m looking for. When I perform that query, though, I get a 200 OK response, with no content (Content-Length: 0). I would expect instead to see something like {“count”: 1}.
I’ve also seen (on other posts to this mailing list), that projections should emit “state” events to a stream like $projection-JumpingPonies-Rainbow%20Dash-state, but I can’t find any evidence of those streams being created either.
I’m running EventStore 3.0.3 from within a Docker container. The container uses the pre-packaged Linux binary. I’m running event store with the “–run-projections=all” flag, and I’m running all system projections ($by_category, $by_event_type, $stream_by_category, $streams).