NAME

DBIO::MySQL::EV::Pool - EV::MariaDB connection pool for DBIO

VERSION

version 0.900001

SYNOPSIS

my $pool = DBIO::MySQL::EV::Pool->new(
    conninfo => { host => 'localhost', database => 'myapp', user => 'myapp' },
    size     => 10,
    on_error => sub { warn $_[0] },
);

my $mdb = $pool->acquire;       # get idle connection
$pool->release($mdb);           # return to pool
my $mdb = $pool->acquire_txn;   # pinned for transaction

DESCRIPTION

Connection pool for DBIO::MySQL::EV::Storage. Manages a pool of EV::MariaDB connections, dispatching queries to available connections and queuing when all are busy.

The acquire / release / capacity / shutdown mechanics, including the connection-readiness gate, are inherited from DBIO::Storage::PoolBase; this class supplies only the EV::MariaDB seam — see "_create_connection", "_connection_ready_future" and "_shutdown_connection".

METHODS

_create_connection

Builds one EV::MariaDB connection from the (already-transformed) connect info. Accepts a hashref of EV::MariaDB named parameters or a plain string (passed as the conninfo argument). The pool tracks the returned connection — do not push it onto "_connections" yourself.

Wires the connection's readiness Future (see "_connection_ready_future"): on_connect resolves it with the connection; an error before connect fails it, so a dependent "acquire" in DBIO::Storage::PoolBase Future fails rather than hanging (karr #20).

_connection_ready_future

Overrides "_connection_ready_future" in DBIO::Storage::PoolBase: the resolved Future does not complete until the connection is actually ready for queries.

EV::MariaDB->new returns before its async connect finishes, so the base's default (immediately-done) seam would hand back a brand-new handle whose on_connect has not fired — the very first bound query on a cold pool then throws not connected (karr #20; this pool previously wired on_connect => sub {}, a pure no-op, with no readiness tracking at all). We look up the per-connection readiness Future registered in "_create_connection" via "_connection_ready_lookup" in DBIO::Storage::PoolBase, falling back to the base's immediately-done seam for an already-connected (idle-reused) connection.

_shutdown_connection

Closes one EV::MariaDB connection during "shutdown" in DBIO::Storage::PoolBase. Errors are swallowed by the caller.

AUTHOR

DBIO Authors

COPYRIGHT AND LICENSE

Copyright (C) 2026 DBIO Authors

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.