couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matteo Caprari <>
Subject ho to notify a client that it's time to update his views?
Date Sun, 06 Dec 2009 12:30:35 GMT

While my couchdb application is very quiet most of the time, sometimes
there is a burst of activity:
tens or hundreds of documents are created and updated in few seconds.
There are many users logged on the system, but each burst is relevant
only for one of them.

When this bursts happen, I want to suggest the user's browser to
reload his views. Clients are connected to a queue via cometd,
messages can be pushed to them.

An approach may be to write a _changes listener that sends a message
to a client when it thinks best, but there's a catch: to know which
client to notify, the proces would either have to download the
documents or I'd have to create one listener for each user, which
would mean one http connection per user. Not that http connections are
a bad thing, but I'm still shy with too many of them around...

Another approach would be to execute a view that counts the documents
for each user and sends a message to  the ones for which the count has
changed since last execution.

I'm sure I'm not seeing better solutions. Suggestions anyone?



Connecting each client to the _changes API is not welcome because each
client is already using one connection with a comet server.
Also, there are different classes of documents associated with
different views,  and I'd end up with multiple connections to
differently filtered _changes.

Of course the processes that create and update the documents know
which user owns the document. I could have them send a message when
due, but I was hoping to keep generators and consumers as decoupled as
possible, with couchdb in the middle.
:Matteo Caprari

View raw message