oliwer / mango

Pure-Perl non-blocking I/O MongoDB driver
https://metacpan.org/release/Mango
Artistic License 2.0
27 stars 12 forks source link

Docs refer to `Mojo::IOLoop::Delay`, which has been removed in 9.0 #38

Open AdamWill opened 3 years ago

AdamWill commented 3 years ago

The examples in the docs include one that relies on Mojo::IOLoop::Delay, which has been removed from Mojolicious 9.0. Not sure if there's an alternative way to do what that example does, @kraih would know.

kraih commented 3 years ago

I don't think Mango is maintained anymore.

AdamWill commented 3 years ago

Ah, now I poke through a checkout, there's actually quite a lot of code and test code that use Delay. So this module is incompatible with Mojo 9.

ppisar commented 3 years ago

There is a patch in fortl's fork in commit https://github.com/fortl/mango/commit/90f13e16fd0f8053479fcf2e497672463061e7ea. It's mostly a white-space shuffle. Without it, it boils down to:

--- a/lib/Mango/Auth/SCRAM.pm
+++ b/lib/Mango/Auth/SCRAM.pm
@@ -34,11 +34,9 @@ sub _authenticate {
         password      => $pass
     );

-  my $delay = Mojo::IOLoop::Delay->new;
+    my $loop = Mojo::IOLoop->new;
     my $conv_id;

-  my $end = $delay->begin;
-
     my $command = $self->_cmd_sasl_start($scram_client->first_msg);
     $mango->_fast($id, $db, $command, sub {
         my ($mango, $err, $doc) = @_;
@@ -54,12 +52,12 @@ sub _authenticate {
             $mango->_fast($id, $db, $command, sub {
                 my ($mango, $err, $doc) = @_;
                 $mango->emit(connection => $id)->_next;
-        $end->();
+                $loop->stop;
             })
         })
     });

-  $delay->wait;
+    $loop->start;
 }