[Dancer-users] ajax progress update

sawyer x xsawyerx at gmail.com
Sat Jul 23 13:04:00 CEST 2011


On Fri, Jul 22, 2011 at 2:54 PM, Mr. Puneet Kishor <punk.kish at gmail.com>wrote:

> One, how can I ignore or reject the extra requests that are a result of
> fidgety behavior? I realize this is a not a Dancer-specific question per se,
> but, one, you guys are likely to have some helpful suggestions, and two, I
> want to have a fall-back on the server side also -- if Dancer is busy with a
> request from a client, is there a way to ignore further requests from the
> same client until at least the first one is complete?
>

Simple locking mechanism. You write down (NoSQL DB should be good for this,
but also in-memory hash, and a bunch of other options that don't necessarily
involve I/O) that a user started an action. Then you can make sure you don't
operate on them again since they already started the action.


> Two, this is more Dancer-specific, I guess -- once Dancer starts a process,
> how can I send periodic updates on that process back to the browser to power
> an ajax-y progress bar? My intent is to show a little floating div with a
> progress bar for each of the processes that were fired by the client.
>

I don't think that's possible at the moment. PSGI allows for that, but we
haven't integrated a comfortable way to do through Dancer itself. You can
subclass that part as a standalone PSGI app layer. Another way would be to
use the trick from the first answer: use an in-memory mechanism to check for
updates. Your code should be writing updates somewhere, and an AJAX request
should make it available, thus allowing the JS code to know what stage a
user is in. This is the currently used way in most applications, but PSGI
allows to something a bit more clever.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.backup-manager.org/pipermail/dancer-users/attachments/20110723/677b6e3e/attachment.htm>


More information about the Dancer-users mailing list