projects
/
angular-mojolicious.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e7a086b
)
use floating point 10.5 unix timestamp as key
author
Dobrica Pavlinusic
<dpavlin@rot13.org>
Thu, 1 Dec 2011 19:34:09 +0000
(20:34 +0100)
committer
Dobrica Pavlinusic
<dpavlin@rot13.org>
Thu, 1 Dec 2011 19:34:09 +0000
(20:34 +0100)
mmonit/collector.pl
patch
|
blob
|
history
diff --git
a/mmonit/collector.pl
b/mmonit/collector.pl
index
ecbc2ed
..
eed0649
100755
(executable)
--- a/
mmonit/collector.pl
+++ b/
mmonit/collector.pl
@@
-8,6
+8,7
@@
use Mojo::JSON;
use Mojo::UserAgent;
use Data::Dump qw(dump);
use XML::Simple;
use Mojo::UserAgent;
use Data::Dump qw(dump);
use XML::Simple;
+use Time::HiRes;
my $json = Mojo::JSON->new;
my $client = Mojo::UserAgent->new;
my $json = Mojo::JSON->new;
my $client = Mojo::UserAgent->new;
@@
-17,7
+18,9
@@
post '/collector' => sub {
my $data = XMLin( $self->req->body );
warn dump( $data );
my $data = XMLin( $self->req->body );
warn dump( $data );
- my $res = $client->post( 'http://localhost:5984/mmonit/' => { 'Content-Type' => 'application/json' } => $json->encode( $data ) )->res->json;
+ # post will create new dockument, put will insert known key
+ my $key = sprintf "%10.5f", Time::HiRes::time;
+ my $res = $client->put( "http://localhost:5984/mmonit/$key" => { 'Content-Type' => 'application/json' } => $json->encode( $data ) )->res->json;
warn "# res = ",dump($res);
warn "# res = ",dump($res);