Database-Async
view release on metacpan or search on metacpan
lib/Database/Async.pod view on Meta::CPAN
$sth->row_hashrefs
->each(sub {
print $_->{name} . "\n";
})->completed
})
} foreach => [1, 2, 3 ])->get;
=head1 METHODS
=head2 transaction
Resolves to a L<Future> which will yield a L<Database::Async::Transaction>
instance once ready.
=head2 txn
Executes code within a transaction. This is meant as a shorter form of
the common idiom
$db->transaction
->then(sub {
my ($txn) = @_;
Future->call($code)
->then(sub {
$txn->commit
})->on_fail(sub {
$txn->rollback
});
})
The code must return a L<Future>, and the transaction will only be committed
if that L<Future> resolves cleanly.
Returns a L<Future> which resolves once the transaction is committed.
=head1 METHODS - Internal
You're welcome to call these, but they're mostly intended
for internal usage, and the API B<may> change in future versions.
=head2 uri
Returns the configured L<URI> for populating database instances.
=head2 pool
Returns the L<Database::Async::Pool> instance.
=head2 pool_args
Returns a list of standard pool constructor arguments.
=head2 configure
Applies configuration, see L<IO::Async::Notifier> for details.
Supports the following named parameters:
=over 4
=item * C<uri> - the endpoint to use when connecting a new engine instance
=item * C<engine> - the parameters to pass when instantiating a new L<Database::Async::Engine>
=item * C<pool> - parameters for setting up the pool, or a L<Database::Async::Pool> instance
=item * C<encoding> - default encoding to apply to parameters, queries and results, defaults to C<binary>
=back
=head2 ryu
A L<Ryu::Async> instance, used for requesting sources, sinks and timers.
=head2 new_source
Instantiates a new L<Ryu::Source>.
=head2 new_sink
Instantiates a new L<Ryu::Sink>.
=head2 new_future
Instantiates a new L<Future>.
=head1 METHODS - Internal, engine-related
=head2 request_engine
Attempts to instantiate and connect to a new L<Database::Async::Engine>
subclass. Returns a L<Future> which should resolve to a new
L<Database::Async::Engine> instance when ready to use.
=head2 engine_instance
Loads the appropriate engine class and attaches to the loop.
=head2 engine_ready
Called by L<Database::Async::Engine> instances when the engine is
ready for queries.
=head2 queue_query
Assign the given query to the next available engine instance.
=head1 SEE ALSO
There's a range of options for interacting with databases - at a low level:
=over 4
=item * L<DBIx::Async> - runs L<DBI> in subprocesses, very inefficient but tries to
make all the methods behave a bit like DBI but deferring results via L<Future>s.
=item * L<DBI> - synchronous database access
=item * L<Mojo::Pg> - attaches a L<DBD::Pg> handle to an event loop
=item * L<Mojo::mysql> - apparently has the ability to make MySQL "fun", an intriguing
( run in 0.456 second using v1.01-cache-2.11-cpan-39bf76dae61 )