I'll appreciate any feedback on how to implement the following
As an authenticated administrator
When I follow "Reload the collections"
Then the reloading page is displayed
And for each collection N read from an external file N
- When the collection is processed (reloaded into the database or
- I can see a sequential status line displayed on the reloading
And when all collection files are processed
I can see a final status line displayed on the reloading page
Its basically a workflow followup on the displayed on a page
the admin see the progress of this workflow ( new line added after
each collection is processed)
the admin can cancel the processing by clicking on a Cancel button
the collection processing is not a lengthy process, so starting a
background process would not be necessary, my concern (and
questioning) is more about synchronizing the processes and the display
of the workflow...
any suggestion will be appreciated ....
I just started to read about Ruote ( workflow engine but isn't it a
hammer to smash a fly ?
What you're wanting to do really should be done using asynchronous
processing. Progress monitoring has two simultaneous things going on:
the potentially long-running work being performed; and the monitoring
of that work's progress. Synchronous processing implies that only one
thing can be done at a time (thus no work being performed at the same
time as monitoring of that work).
Typically such process monitoring is done by firing the long-running
work in a background process, and then rendering in the ui that that
(async) process has started. From then on, until the work is
completed, on some periodic basis you check on the status of that work
and update the progress in the ui (and possibly provide a way to kill
the process and/or undo/rollback if taking too long, or too many
errors, or ...).
I guess if you really didn't want to go with async processing/
monitoring for your particular project, an alternative strategy would
be to break down the total work into incremental bits of work that
could be performed one at a time synchronously, ie display the list of
items of work that need to be done to the admin, and then have the
admin fire them one at a time, so that that item alone is processed
and when done updates the ui, in order until all work is completed.
Note that this type of strategy may not really be possible, nor
preferable really compared to just doing it the right way ...
Thanks Jeff, it's clear ....
in this project , I believe the alternative strategy would be fine ...
it's actually a 'sequential' list of small tasks to be performed ...
and simple progress display in the UI (started - done)
I'll test an 'human' (admin) firing first.... but I guess I can also
have an auto firing of the next task asap a previous one just ended...
('observers' are here for that....)