Perl,EV,Mojolicious,芒果

时间:2017-11-12 15:57:41

标签: mongodb perl mojolicious

我不明白为什么这段代码会产生错误。

use strict;
use warnings;

use Mojo::IOLoop;
use Mango;

my $mango = Mango->new('mongodb://username:password@XX.XX.XX.XX:27017/admin');

my $sync = $mango->db('Quag')->collection('Sync');

$sync->save({foo => 'bar'} => sub {
    my ($c, $e, $o) = @_;
    print $e // 'NO ERRROR', "\n";
    Mojo::IOLoop->stop;
});

Mojo::IOLoop->start;
  

Mojo :: Reactor :: EV:I / O观察器失败:
  Mojo :: IOLoop已在/opt/perl5/perls/perl-5.26.1/lib/site_perl/5.26.1/Mango/Auth/SCRAM.pm第66行运行。

     

没有错误

没有MongoDB授权,就没有错误。

另一个样本(来自芒果概要):

use strict;
use warnings;
use feature qw(state say);

use EV;
use AnyEvent;
use Mango;

sub mango {

    state $m = Mango->new('mongodb://usename:password@xx.xx.xx.xx:27017/admin')
}

my $cv = AE::cv;

mango->db('Quag')->command(buildInfo => sub {
    my ($db, $err, $doc) = @_;
    $cv->send($doc->{version});
});

say $cv->recv;
  

Mojo :: Reactor :: EV:I / O观察器失败:
  Mojo :: IOLoop已在/opt/perl5/perls/perl-5.26.1/lib/site_perl/5.26.1/Mango/Auth/SCRAM.pm第66行运行。

     

3.2.11

0 个答案:

没有答案