projects
/
angular-mojolicious.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
implement delete
[angular-mojolicious.git]
/
couchdb-trigger.pl
diff --git
a/couchdb-trigger.pl
b/couchdb-trigger.pl
index
02f5c32
..
db5acb0
100755
(executable)
--- a/
couchdb-trigger.pl
+++ b/
couchdb-trigger.pl
@@
-25,6
+25,7
@@
my ( $url, $trigger_path ) = @ARGV;
$url ||= 'http://localhost:5984/monitor';
$trigger_path ||= 'trigger/shell.pm' ;
$url ||= 'http://localhost:5984/monitor';
$trigger_path ||= 'trigger/shell.pm' ;
+sub commit { warn "# commit ignored\n"; }
require $trigger_path if -e $trigger_path;
my $seq = 0;
require $trigger_path if -e $trigger_path;
my $seq = 0;
@@
-45,12
+46,9
@@
while( ! $error ) {
$tx->res->body(sub{
my ( $content, $body ) = @_;
$tx->res->body(sub{
my ( $content, $body ) = @_;
- debug 'BODY' => $body;
+ return if length($body) == 0; # empty chunk, heartbeat?
- if ( length($body) == 0 ) {
- warn "# empty chunk, heartbeat?\n";
- return;
- }
+ debug 'BODY' => $body;
foreach ( split(/\r?\n/, $body) ) { # we can get multiple documents in one chunk
foreach ( split(/\r?\n/, $body) ) { # we can get multiple documents in one chunk
@@
-83,7
+81,7
@@
while( ! $error ) {
if ( $tx->res->code == 409 ) {
info "TRIGGER ABORTED started on another worker? ", $tx->error;
} else {
if ( $tx->res->code == 409 ) {
info "TRIGGER ABORTED started on another worker? ", $tx->error;
} else {
- info "ERROR ", $tx->error;
+ info "ERROR
$url/$id
", $tx->error;
}
} else {
my $res = $tx->res->json;
}
} else {
my $res = $tx->res->json;
@@
-97,7
+95,7
@@
while( ! $error ) {
$client->put( "$url/$id" => $json->encode( $change->{doc} ) => sub {
my ($client,$tx) = @_;
if ($tx->error) {
$client->put( "$url/$id" => $json->encode( $change->{doc} ) => sub {
my ($client,$tx) = @_;
if ($tx->error) {
- info "ERROR", $tx->error;
+ info "ERROR
$url/$id
", $tx->error;
} else {
my $res = $tx->res->json;
$change->{doc}->{_rev} = $res->{rev};
} else {
my $res = $tx->res->json;
$change->{doc}->{_rev} = $res->{rev};
@@
-114,6
+112,8
@@
while( ! $error ) {
}
}
+ commit;
+
});
$client->start($tx);
});
$client->start($tx);