Projector status
basz opened this issue · comments
While fixing #179 I think I might have stumbled upon some deeper problem.
Suppose I have no projections running and with help of the projection manager I instruct a projection to stop. The remote status is changed to 'stopping'. This is weird in itself because it was not running, but ok.
So now the projection is started to begin projecting event. Upon startup the active projector will see the 'stopping' status and update it's status to idle and exits promptly. The result is a not running projector, just one that might have overwritten an 'stopping' state for a possibly running projector. (without the PR from #180 you would even loose stream positions state.)
I wonder if we are missing a 'stopped' state to complement the idle state of an active projector. When a active projector exits it should set the status to stopped
. Then the stopping
status should only be acted on by active (running, or idle) projector.
If a Projector with a status of 'stopping' is started, why would it be allowed to persist anything? It should either wait until stopped and continue as an active projector or exit immediately.
This is kind of hard to wrap inside my head. Not even taking into account the locking mechanism of the projectors. So, this is only a call for feedback for now.
Edit: My mistake. Currently 'idle' is equivalent to 'stopped', so that's fine I guess. However I would like to be able to pause a projector via the process manager.
Why? While testing it helps when I am able to pause a projector, wait for it to be actually paused (via fetchProjectionStatus
) then restore the events store from some fixtures, reset (or fast forward without emitting events) the projector and then activate it again.
To me pause is the same as stop, so we have this already, no?
Not really.
Consider having a long-running process managed by supervisord. There is a difference between that being stopped and the projection being (what I would call) paused.
I would like to keep the process running but the projector inactive (via the process manager) so I can reset the event store with fixtures in tests or development. Currently, I need to stop it, do my tests or import fixtures and then manually restart the process...
Additionally: I have built my projectors such that I can specify if events are actually being projected. That is useful to fast-forward process-manager projections. Of course, I would like to see that also build into the projectors themselves. A status 'fast-forward' which automatically goes to 'idle' when it has reached the tip.
Then I also noticed some dislike (in prooph/event-store#352 (comment)) around the integration of the projections and event-store.
So, all in all, maybe some refactoring might be needed. But please consider these requests are a mere collection of ideas for now.