Hi Rob, take a look at the 3rd clause of couch_db_update_notifier:handle_event (line ~55). That's the code that sends update notifications to your Ruby script. It handles couch_db_update_notifier:notify() calls, which you'll find in couch_server.erl and couch_db_updater.erl.

From a technical perspective it would be easy enough to change the "updated" atoms sent in couch_db_updater to something a little more detailed (and extend the gen_event code to work with terms other than atoms at the same time). I haven't used DbUpdateNotificationProcesses much myself so I'm not sure if there are higher-level design reasons why sending this more detailed info should be discouraged. Best,

Adam

On Dec 4, 2008, at 4:51 PM, Rob Law wrote:

Hey,

I am trying to modify the data that gets sent to my ruby script when an
Update happens (as described here :
http://wiki.apache.org/couchdb/Regenerating_views_on_update). I am hoping to have couchdb alert me with the actual document that was updated or added (like id, and attributes, etc), so that I can parse this update in my ruby script and act accordingly. So instead of the update_call looking like:

{"type":"updated","db":"DB_NAME"}

it would look like this:

{"type":"updated","db":"DB_NAME", "document":"_id" : "2342331232",
"data":"test"}

Is there any hope of getting that kind of data from couch on document
update?  I could just have my ruby script request changed documents or
something, but I thought it would be cleaner and more extensible if couch
just told my script the document that got updated.

Any tips would help. Also, could someone direct me to the file and/ or line where that data gets sent to my script. This is my first foray into Erlang
and I am trying to get into playing with couches internals, etc.

thanks

Rob

Reply via email to