-
-
Save heikojansen/3aec5349e7fcc009a420a69a3f8271eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
requires "Mojolicious" => "6.66"; | |
requires "Mango" => "1.29"; | |
requires "Data::Dump" => "1.23"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/mango_test> MANGO_DEBUG=1 carton exec morbo ./myapp.pl | |
Server available at http://127.0.0.1:3000 | |
[Wed Jul 6 12:46:03 2016] [debug] GET "/" | |
[Wed Jul 6 12:46:03 2016] [debug] Routing to a callback | |
before... at /tmp/mango_test/myapp.pl line 11. | |
after... at /tmp/mango_test/myapp.pl line 29. | |
in first step at /tmp/mango_test/myapp.pl line 15. | |
-- Operation #1 (query) | |
[ | |
"mydb.mycoll", | |
{}, | |
0, | |
-1, | |
{ | |
"_id" => "whatever" | |
}, | |
{} | |
] | |
-- New connection (localhost:27017:1) | |
-- Operation #2 (query) | |
[ | |
"admin.\$cmd", | |
{}, | |
0, | |
-1, | |
{ | |
"isMaster" => 1 | |
}, | |
{} | |
] | |
-- Client >>> Server (#2) | |
-- Client <<< Server (#2) | |
{ | |
"cursor" => 0, | |
"docs" => [ | |
{ | |
"ismaster" => bless( do{\(my $o = 1)}, 'JSON::PP::Boolean' ), | |
"localTime" => bless( { | |
"time" => '1467801963197' | |
}, 'Mango::BSON::Time' ), | |
"maxBsonObjectSize" => 16777216, | |
"maxMessageSizeBytes" => 48000000, | |
"maxWireVersion" => 4, | |
"maxWriteBatchSize" => 1000, | |
"minWireVersion" => 0, | |
"ok" => 1 | |
} | |
], | |
"flags" => { | |
"await_capable" => 1 | |
}, | |
"from" => 0, | |
"id" => 0, | |
"to" => 2 | |
} | |
-- Client >>> Server (#1) | |
-- Client <<< Server (#1) | |
{ | |
"cursor" => 0, | |
"docs" => [], | |
"flags" => { | |
"await_capable" => 1 | |
}, | |
"from" => 0, | |
"id" => 1, | |
"to" => 1 | |
} | |
Use of uninitialized value $_[1] in concatenation (.) or string at /tmp/mango_test/myapp.pl line 20. | |
in second step; error: at /tmp/mango_test/myapp.pl line 20. | |
-- Operation #3 (query) | |
[ | |
"mydb.mycoll", | |
{}, | |
0, | |
-1, | |
{ | |
"_id" => "whatever" | |
}, | |
{} | |
] | |
-- Client >>> Server (#3) | |
in third step; error: Premature connection close at /tmp/mango_test/myapp.pl line 25. | |
[Wed Jul 6 12:46:03 2016] [debug] 200 OK (0.007479s, 133.708/s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2016-07-06T12:46:03.196+0200 I NETWORK [initandlisten] connection accepted from 127.0.0.1:53564 #1 (1 connection now open) | |
2016-07-06T12:46:03.197+0200 D COMMAND [conn1] run command admin.$cmd { isMaster: 1 } | |
2016-07-06T12:46:03.197+0200 I COMMAND [conn1] command admin.$cmd command: isMaster { isMaster: 1 } keyUpdates:0 writeConflicts:0 numYields:0 reslen:178 locks:{} protocol:op_query 0ms | |
2016-07-06T12:46:03.198+0200 D QUERY [conn1] Running query: query: { _id: "whatever" } sort: {} projection: {} ntoreturn=1 | |
2016-07-06T12:46:03.198+0200 D QUERY [conn1] Collection mydb.mycoll does not exist. Using EOF plan: query: { _id: "whatever" } sort: {} projection: {} ntoreturn=1 | |
2016-07-06T12:46:03.198+0200 I COMMAND [conn1] query mydb.mycoll query: { _id: "whatever" } planSummary: EOF ntoskip:0 keysExamined:0 docsExamined:0 cursorExhausted:1 keyUpdates:0 writeConflicts:0 numYields:0 nreturned:0 reslen:20 locks:{ Global: { acquireCount: { r: 2 } }, Database: { acquireCount: { r: 1 } }, Collection: { acquireCount: { r: 1 } } } 0ms | |
2016-07-06T12:46:03.202+0200 D QUERY [conn1] Running query: query: { _id: "whatever" } sort: {} projection: {} ntoreturn=1 | |
2016-07-06T12:46:03.202+0200 D QUERY [conn1] Collection mydb.mycoll does not exist. Using EOF plan: query: { _id: "whatever" } sort: {} projection: {} ntoreturn=1 | |
2016-07-06T12:46:03.202+0200 I COMMAND [conn1] query mydb.mycoll query: { _id: "whatever" } planSummary: EOF ntoskip:0 keysExamined:0 docsExamined:0 cursorExhausted:1 keyUpdates:0 writeConflicts:0 numYields:0 nreturned:0 reslen:20 locks:{ Global: { acquireCount: { r: 2 } }, Database: { acquireCount: { r: 1 } }, Collection: { acquireCount: { r: 1 } } } 0ms | |
2016-07-06T12:46:03.202+0200 D NETWORK [conn1] SocketException: remote: 127.0.0.1:53564 error: 9001 socket exception [CLOSED] server [127.0.0.1:53564] | |
2016-07-06T12:46:03.203+0200 I NETWORK [conn1] end connection 127.0.0.1:53564 (0 connections now open) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use Mojolicious::Lite; | |
use Data::Dump qw(dump); | |
use Mango; | |
get '/' => sub { | |
my $c = shift; | |
my $m = Mango->new(); | |
warn "before..."; | |
Mojo::IOLoop->delay( | |
sub { | |
my $delay = shift; | |
warn "in first step"; | |
$m->db('mydb')->collection('mycoll')->find_one( { _id => "whatever" } => $delay->begin(0) ); | |
}, | |
sub { | |
my $delay = shift; | |
warn "in second step; error: " . $_[1]; | |
$m->db('mydb')->collection('mycoll')->find_one( { _id => "whatever" } => $delay->begin(0) ); | |
}, | |
sub { | |
my $delay = shift; | |
warn "in third step; error: " . $_[1]; | |
$c->render( json => { json => { success => 1 } } ); | |
} | |
); | |
warn "after..."; | |
$c->render_later; | |
}; | |
app->start; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment