Async.pm

filter: Statementstmt 100% 11 / 11 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 14 / 14 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Async/Pool.pm ↑ Summary Async/TransactionContext.pm »
1 package DBIO::Async;
2 2 our $VERSION = '0.900001';
3 # ABSTRACT: Shared, loop-agnostic async layer for DBIO drivers
4  
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use base 'DBIO::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # ADR 0030 refinement (karr #65): future_io does NOT register a generic backend
11 # on the core base. The core resolver discovers the per-driver transport adapter
12 # by CONVENTION -- ref($storage) . '::Async' (e.g. DBIO::PostgreSQL::Storage ->
13 # DBIO::PostgreSQL::Storage::Async) -- so merely loading this module no longer
14 # globally claims future_io for every driver. This module just carries the
15 # shared abstract Future::IO backend (DBIO::Async::Storage) that each driver's
16 # ::Storage::Async adapter subclasses and completes.
17  
18  
19 2 1;
20  
21 __END__
22  
23 =pod
24  
25 =encoding UTF-8
26  
27 =head1 NAME
28  
29 DBIO::Async - Shared, loop-agnostic async layer for DBIO drivers
30  
31 =head1 VERSION
32  
33 version 0.900001
34  
35 =head1 SYNOPSIS
36  
37 See L<DBIO::Async::Storage> for the subclass contract and the seam hooks a
38 DB-specific driver supplies.
39  
40 =head1 DESCRIPTION
41  
42 Shared, loop-agnostic async layer for L<DBIO> drivers. This distribution
43 carries the Future / L<Future::IO> requirements and the generic async plumbing
44 that every DB-specific async driver needs, so a sync-only driver pulls no
45 async dependencies.
46  
47 The C<future_io> async I<mode> (ADR 0030) resolves its transport adapter B<by
48 convention>: a schema connected with C<< { async => 'future_io' } >> uses the
49 per-driver adapter class C<< ref($storage) . '::Async' >> for its C<< *_async >>
50 methods -- e.g. a PostgreSQL storage C<DBIO::PostgreSQL::Storage> resolves
51 C<DBIO::PostgreSQL::Storage::Async>. Loading this module does B<not> globally
52 register future_io for every driver; it provides the shared abstract backend
53 those per-driver adapters subclass. A driver with no such adapter croaks early
54 and clearly. There is no auto-fallback and no
55 C<async_backend>/C<async_fallback> -- the mode is explicit or the connection
56 stays synchronous.
57  
58 use DBIO::Async; # provides the shared future_io backend base
59  
60 my $schema = MyApp::Schema->connect(
61 $dsn, $user, $pass, { async => 'future_io' },
62 );
63  
64 $schema->resultset('Artist')->all_async->then(sub { ... });
65  
66 The async work lives in L<DBIO::Async::Storage>, a concrete, DB-agnostic
67 skeleton subclassing core L<DBIO::Storage::Async>. A DB-specific driver
68 subclasses it as C<< DBIO::X::Storage::Async >> and supplies only the
69 DB-specific seam hooks (how to submit an async query, collect the ready result,
70 the socket fd to watch, SQL transform, connect-info shape); the generic CRUD
71 runner, transaction pinning, pipeline bracketing, sync C<< ->get >> fallbacks
72 and AccessBroker wiring live here.
73  
74 =head1 EVENT LOOP COMPATIBILITY
75  
76 The watcher seam is loop-agnostic: L<Future::IO>'s default implementation is
77 L<IO::Poll> (core, no event loop), and it auto-routes through L<IO::Async>,
78 L<AnyEvent>, L<Mojolicious>, L<UV> or L<Glib> when the matching
79 C<Future::IO::Impl::*> module is installed. The user picks the loop; no event
80 loop is a hard requirement (core ADR 0014).
81  
82 =head1 AUTHOR
83  
84 DBIO Authors
85  
86 =head1 COPYRIGHT AND LICENSE
87  
88 Copyright (C) 2026 DBIO Authors
89  
90 This is free software; you can redistribute it and/or modify it under
91 the same terms as the Perl 5 programming language system itself.
92  
93 =cut
« Async/Pool.pm ↑ Summary Async/TransactionContext.pm »