Async.pm

filter: Statementstmt 78.5% 11 / 14 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 3 / 4 Podpod 0.0% 0 / 1 totaltotal 73.6% 14 / 19 CC 1 SCAR 2.2
CC
1
Cov
79%
connection
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« Async/TransactionContext.pm ↑ Summary Async/Pool.pm »
1 package DBIO::PostgreSQL::Async;
2 1 our $VERSION = '0.900000';
3 # ABSTRACT: Async PostgreSQL storage for DBIO via EV::Pg
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use base 'DBIO::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10  
11 sub connection {
12 0 ▶ my ($self, @info) = @_;
Subroutine connection: not called CC=1 SCAR=6.9
Pod undocumented
13 0 $self->storage_type('+DBIO::PostgreSQL::Async::Storage');
14 0 return $self->next::method(@info);
15 }
16  
17 1 1;
18  
19 __END__
20  
21 =pod
22  
23 =encoding UTF-8
24  
25 =head1 NAME
26  
27 DBIO::PostgreSQL::Async - Async PostgreSQL storage for DBIO via EV::Pg
28  
29 =head1 VERSION
30  
31 version 0.900000
32  
33 =head1 SYNOPSIS
34  
35 # Schema setup
36 my $schema = MyApp::Schema->connect(
37 'DBIO::PostgreSQL::Async',
38 {
39 host => 'localhost',
40 dbname => 'myapp',
41 user => 'myapp',
42 pool_size => 10,
43 },
44 );
45  
46 # Async queries return Futures
47 $schema->resultset('Artist')->all_async->then(sub {
48 my @artists = @_;
49 say $_->name for @artists;
50 });
51  
52 # Pipeline mode — batch queries in one round-trip
53 $schema->storage->pipeline(sub {
54 my @futures;
55 push @futures, $schema->resultset('Artist')
56 ->create_async({ name => $_ }) for @names;
57 return Future->needs_all(@futures);
58 });
59  
60 # LISTEN/NOTIFY
61 $schema->storage->listen('changelog', sub {
62 my ($channel, $payload) = @_;
63 say "Event: $payload";
64 });
65  
66 # Sync methods still work (block the event loop)
67 my @all = $schema->resultset('Artist')->all;
68  
69 =head1 DESCRIPTION
70  
71 Async PostgreSQL support for DBIO using L<EV::Pg>, a non-blocking
72 PostgreSQL client built on libpq's async protocol. Bypasses DBI
73 entirely for maximum performance.
74  
75 Supports pipeline mode (batching queries in a single round-trip),
76 prepared statements, COPY, and LISTEN/NOTIFY.
77  
78 =head1 EVENT LOOP COMPATIBILITY
79  
80 L<EV::Pg> uses the L<EV> event loop. This works with:
81  
82 =over 4
83  
84 =item * L<EV> directly
85  
86 =item * L<AnyEvent> (uses EV as backend when available)
87  
88 =item * L<IO::Async> via L<IO::Async::Loop::EV>
89  
90 =item * L<Mojolicious> via L<Mojo::Reactor::EV>
91  
92 =back
93  
94 =head1 AUTHOR
95  
96 DBIO Authors
97  
98 =head1 COPYRIGHT AND LICENSE
99  
100 Copyright (C) 2026 DBIO Authors
101  
102 This is free software; you can redistribute it and/or modify it under
103 the same terms as the Perl 5 programming language system itself.
104  
105 =cut
« Async/TransactionContext.pm ↑ Summary Async/Pool.pm »