From: Dobrica Pavlinusic Date: Sun, 21 Nov 2010 21:51:52 +0000 (+0100) Subject: watch CouchDB _changes?feed=continuous X-Git-Url: http://git.rot13.org/?p=NoSQL-toys.git;a=commitdiff_plain;h=3a03a0b9af3b58f67c8f00461f09af2a13fc5f67 watch CouchDB _changes?feed=continuous --- diff --git a/couchdb/couchdb-changes.pl b/couchdb/couchdb-changes.pl new file mode 100755 index 0000000..73fea3a --- /dev/null +++ b/couchdb/couchdb-changes.pl @@ -0,0 +1,29 @@ +#!/usr/bin/perl + +# http://wiki.apache.org/couchdb/HTTP_database_API#Changes + +use warnings; +use strict; + +use LWP::UserAgent; +use Data::Dump qw(dump); + +my $ua = LWP::UserAgent->new; +$ua->timeout( 60 * 60 ); +$ua->env_proxy; + +my $response = $ua->get( + 'http://localhost:5984/monitor/_changes?feed=continuous' + , ':content_cb' => sub { + my ( $data, $response, $protocol ) = @_; + warn dump( $data ); + } +); + +if ($response->is_success) { + print $response->decoded_content; # or whatever +} +else { + die $response->status_line; +} +