The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Test::mysqld::Pool - create a pool of Test::mysqld-s

SYNOPSIS

use DBI;
use Test::mysqld::Pool;

my $pool = Test::mysqld::Pool->new(
  my_cnf => {
    'skip-networking' => '', # no TCP socket
  },
  jobs   => 2,
) or plan skip_all => $Test::mysqld::errstr;

my $dsn1 = $pool->alloc; # in process 1
my $dsn2 = $pool->alloc; # in process 2
# my $dsn3 = $pool->alloc; # blocks

# after process 1 death
$pool->dealloc_unused;

my $dsn3 = $pool->alloc; # in process 3 (get dsn from pool; reused $dsn of process 1)