NAME

Dancer2::Plugin::JobScheduler::Client::TheSchwartz - Client connector to TheSchwartz

DESCRIPTION

Internal class.

Not to be used separately. Please see Dancer2::Plugin::JobScheduler.

CONFIGURATION

The configuration of Dancer2::Plugin::JobScheduler::Client::TheSchwartz requires only the knowledge of how to connect with its database backends. TheSchwartz can use simultaneously several databases as backends. When inserting a new task, TheSchwartz loops over all available databases until it finds one that it can connect to and inserts the task there. TheSchwartz client does not maintain its own database handles. Instead, it requires the calling program to give a subroutine pointer or the name and method of a class which can provide the handle.

In a long running process, such as a web service, the database handle can become invalid. Database can close the handle if it stays unused a long period of time. The database handle has to be recreated if that happens.

If callback is a subroutine pointer, then Dancer2::Plugin::JobScheduler will call the given pointer and give one argument: the name of the database it wants to reach.

This example creates two databases and uses a locally defined subroutine to get the database handle:

use Database::Temp;
use DBI;
my %test_dbs = (
    theschwartz_db1 => Database::Temp->new( driver => 'SQLite', );
    theschwartz_db2 => Database::Temp->new( driver => 'SQLite', );
);
my $get_dbh = sub {
    my ($id) = @_;
    return DBI->connect( $test_dbs{ $id }->connection_info );
};
my %plugin_config = (
    default => 'theschwartz',
    schedulers => {
        theschwartz => {
            package => 'TheSchwartz',
            parameters => {
                dbh_callback => $get_dbh,
                databases => [
                    {
                        id => 'theschwartz_db1',
                        prefix => q{},
                    },
                ]
            }
        }
    }
);

This example uses the Perl package Database::ManagedHandle to provide an open database handle.

my %plugin_config = (
    default => 'theschwartz',
    schedulers => {
        theschwartz => {
            package => 'TheSchwartz',
            parameters => {
                dbh_callback => 'Database::ManagedHandle->instance->dbh',
                databases => [
                    {
                        id => 'theschwartz_db1',
                        prefix => q{},
                    },
                ]
            }
        }
    }
);
    my $get_dbh = sub {
        my ($id) = @_;
        return DBI->connect( $test_dbs{ $id }->connection_info );
    };

Please see Dancer2::Plugin::JobScheduler on how to attach this configuration to the plugin's configuration.

ADOPTION

If you're interested in adopting this module, and the author/maintainer appears to be no longer active, please consult the PAUSE module adoption process documented at https://github.com/Perl-Toolchain-Gang/pause/blob/master/doc/takeover-policy.md.

The PAUSE admins (modules@perl.org) may grant co-maintainer or primary-maintainer permissions to a suitable adopter if:

  • There has been no release for a year or more, AND

  • There are outstanding issues, pull requests, or bug reports that would benefit from attention, AND

  • Reasonable attempts to contact me have failed (CPAN email address, GitHub issues on the project repository, and any other channels listed in this distribution) over a period of at least one month, AND

  • The prospective adopter intends to make changes that benefit users of the module.

In the event of my death or permanent incapacity, my heirs are not obligated to maintain these modules, and I explicitly authorize the PAUSE admins to transfer maintainership without further consultation once the conditions above are met.

AUTHOR

Mikko Koivunalho <mikkoi@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Mikko Koivunalho.

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