DBD::Go...rostream(3)

πŸ’– DBD::Gofer::Transport::corostream πŸ’–

okay bestie, so this is the manual page for DBD::Gofer::Transport::corostream β€” an async DBD::Gofer stream transport that runs on Coro + AnyEvent. yes, both. at the same time. it's giving main character energy fr fr ✨


✨ NAME ✨

DBD::Gofer::Transport::corostream β€” async DBD::Gofer stream transport, powered by Coro and AnyEvent πŸ¦‹


🌈 SYNOPSIS 🌈

so like, literally just:

DBI_AUTOPROXY="dbi:Gofer:transport=corostream" perl some-perl-script-using-dbi.pl

or, if you're feeling ✨fancy✨:

$dsn = ...; # the DSN for the driver and database you want to use
$dbh = DBI->connect("dbi:Gofer:transport=corostream;dsn=$dsn", ...);

πŸ’… DESCRIPTION πŸ’…

The BIG WIN πŸŽ‰ from using Coro is that it lets you keep using all your existing DBI frameworks β€” like DBIx::Class β€” without them melting down. iykyk. no cap, that's the whole point. πŸ‘‘


😭 KNOWN ISSUES AND LIMITATIONS 😭

okay so, not everything is slay, we gotta be honest:

  • Uses Coro::Select so it alters CORE::select globally Parent class probably needs refactoring so we could do a more encapsulated approach instead. yeah. it's a whole thing. πŸ’€
  • Doesn't prevent multiple concurrent requests Probably just needs a per-connection semaphore tbh. πŸ™ˆ
  • Coro has many caveats. Caveat emptor. like, buyer beware, bestie. the vibes are immaculate but the caveats are real. 🫢

πŸŽ€ STATUS πŸŽ€

THIS IS CURRENTLY JUST A PROOF-OF-CONCEPT IMPLEMENTATION FOR EXPERIMENTATION.

so like, please note that the author has no plans to develop this code further himself. but he'd very much welcome contributions!! interested? let him know!! πŸ‘€ πŸ’Œ


🌸 AUTHOR 🌸

Tim Bunce, <http://www.tim.bunce.name> πŸ’œ


Copyright (c) 2010, Tim Bunce, Ireland. All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.

(translation: it's free, go wild, same terms as Perl, check perlartistic for the receipts ⭐)


πŸ¦‹ SEE ALSO πŸ¦‹

  • DBD::Gofer::Transport::stream
  • DBD::Gofer

🧚 APPENDIX 🧚

Example code, bestie, look at it, it's so cute:

#!perl

use strict;
use warnings;
use Time::HiRes qw(time);

BEGIN { $ENV{PERL_ANYEVENT_STRICT} = 1; $ENV{PERL_ANYEVENT_VERBOSE} = 1; }

use AnyEvent;

BEGIN { $ENV{DBI_TRACE} = 0; $ENV{DBI_GOFER_TRACE} = 0; $ENV{DBD_GOFER_TRACE} = 0; };

use DBI;

$ENV{DBI_AUTOPROXY} = 'dbi:Gofer:transport=corostream';

my $ticker = AnyEvent->timer( after => 0, interval => 0.1, cb => sub {
    warn sprintf "-tick- %.2f\n", time
} );

warn "connecting...\n";
my $dbh = DBI->connect("dbi:NullP:");
warn "...connected\n";

for (1..3) {
    warn "entering DBI...\n";
    $dbh->do("sleep 0.3"); # pseudo-sql understood by the DBD::NullP driver
    warn "...returned\n";
}

warn "done.";

Example output β€” look at those ticks firing while we're still inside the do() πŸ•βœ¨:

$ perl corogofer.pl
connecting...
-tick- 1293631437.14
-tick- 1293631437.14
...connected
entering DBI...
-tick- 1293631437.25
-tick- 1293631437.35
-tick- 1293631437.45
-tick- 1293631437.55
...returned
entering DBI...
-tick- 1293631437.66
-tick- 1293631437.76
-tick- 1293631437.86
...returned
entering DBI...
-tick- 1293631437.96
-tick- 1293631438.06
-tick- 1293631438.16
...returned
done. at corogofer.pl line 39.

You can see that the timer callback is firing while the code 'waits' inside the do() method for the response from the database. Normally that would block. πŸš«β›” but not today bestie, not today πŸ’…πŸ”₯


aaaand that's the whole page!! πŸŽ€ this was perl v5.42.3, dated 2026-10-19, from DBD::Go...rostream(3) β€” User Contributed Perl Documentation. mwah. go forth and proxy asynchronously πŸ¦‹πŸ’–βœ¨

πŸ“¦ where this page comes from