1DBD::Gofer::Transport::UcsoerrosCtornetarmi(b3u)ted PerlDBDDo:c:uGmoefnetra:t:iTornansport::corostream(3)
2
3
4

NAME

6       DBD::Gofer::Transport::corostream - Async DBD::Gofer stream transport
7       using Coro and AnyEvent
8

SYNOPSIS

10          DBI_AUTOPROXY="dbi:Gofer:transport=corostream" perl some-perl-script-using-dbi.pl
11
12       or
13
14          $dsn = ...; # the DSN for the driver and database you want to use
15          $dbh = DBI->connect("dbi:Gofer:transport=corostream;dsn=$dsn", ...);
16

DESCRIPTION

18       The BIG WIN from using Coro is that it enables the use of existing DBI
19       frameworks like DBIx::Class.
20

KNOWN ISSUES AND LIMITATIONS

22         - Uses Coro::Select so alters CORE::select globally
23           Parent class probably needs refactoring to enable a more encapsulated approach.
24
25         - Doesn't prevent multiple concurrent requests
26           Probably just needs a per-connection semaphore
27
28         - Coro has many caveats. Caveat emptor.
29

STATUS

31       THIS IS CURRENTLY JUST A PROOF-OF-CONCEPT IMPLEMENTATION FOR
32       EXPERIMENTATION.
33
34       Please note that I have no plans to develop this code further myself.
35       I'd very much welcome contributions. Interested? Let me know!
36

AUTHOR

38       Tim Bunce, <http://www.tim.bunce.name>
39
41       Copyright (c) 2010, Tim Bunce, Ireland. All rights reserved.
42
43       This module is free software; you can redistribute it and/or modify it
44       under the same terms as Perl itself. See perlartistic.
45

SEE ALSO

47       DBD::Gofer::Transport::stream
48
49       DBD::Gofer
50

APPENDIX

52       Example code:
53
54           #!perl
55
56           use strict;
57           use warnings;
58           use Time::HiRes qw(time);
59
60           BEGIN { $ENV{PERL_ANYEVENT_STRICT} = 1; $ENV{PERL_ANYEVENT_VERBOSE} = 1; }
61
62           use AnyEvent;
63
64           BEGIN { $ENV{DBI_TRACE} = 0; $ENV{DBI_GOFER_TRACE} = 0; $ENV{DBD_GOFER_TRACE} = 0; };
65
66           use DBI;
67
68           $ENV{DBI_AUTOPROXY} = 'dbi:Gofer:transport=corostream';
69
70           my $ticker = AnyEvent->timer( after => 0, interval => 0.1, cb => sub {
71               warn sprintf "-tick- %.2f\n", time
72           } );
73
74           warn "connecting...\n";
75           my $dbh = DBI->connect("dbi:NullP:");
76           warn "...connected\n";
77
78           for (1..3) {
79               warn "entering DBI...\n";
80               $dbh->do("sleep 0.3"); # pseudo-sql understood by the DBD::NullP driver
81               warn "...returned\n";
82           }
83
84           warn "done.";
85
86       Example output:
87
88           $ perl corogofer.pl
89           connecting...
90           -tick- 1293631437.14
91           -tick- 1293631437.14
92           ...connected
93           entering DBI...
94           -tick- 1293631437.25
95           -tick- 1293631437.35
96           -tick- 1293631437.45
97           -tick- 1293631437.55
98           ...returned
99           entering DBI...
100           -tick- 1293631437.66
101           -tick- 1293631437.76
102           -tick- 1293631437.86
103           ...returned
104           entering DBI...
105           -tick- 1293631437.96
106           -tick- 1293631438.06
107           -tick- 1293631438.16
108           ...returned
109           done. at corogofer.pl line 39.
110
111       You can see that the timer callback is firing while the code 'waits'
112       inside the do() method for the response from the database. Normally
113       that would block.
114
115
116
117perl v5.28.0                      2013-04-0D4BD::Gofer::Transport::corostream(3)
Impressum