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

ResourcePool::Resource - A wrapper class for a resource

SYNOPSIS

 use ResourcePool::Resource;

 my $resource = ResourcePool::Resource->new();

DESCRIPTION

This type of classes is used by the ResourcePool internaly. It's thougt to be an abstract base class for further resources which will be used with the ResourcePool.

This classes gets constructed by a Factory like ResourcePool::Factory. The factory knows about the actual parameters to pass to the Resource. So in fact a Factory doens't create the resource like DBI, it creates a wrapper Resource for it which also supports some test functionality.

Every class which is derived from ResourcePool::Resource must overload this member functions:

$self->close

Closes a connection gracefully.

$self->fail_close

Closes a failed connection and ignores error (since this connection is known as bad)

$self->get_plain_resource

Returns the nacked resource which can be used by the client. This an the DBI or Net::LDAP handle for example.

Additonally a ResourcePool::Resource derived class should overload at least one of the check methods:

$self->precheck

Checks a connection. This method is called by the get() method of the ResourcePool before it returns a connection. The default implementation always returns true.

$self->postcheck

Checks a connection. This method is called by the free() method of the ResourcePool to check if a connection is still valid. The default implementation always returns true.

SEE ALSO

ResourcePool(3pm), ResourcePool::Resource::DBI(3pm), ResourcePool::Resource::Net::LDAP(3pm)

AUTHOR

    Copyright (C) 2002 by Markus Winand <mws@fatalmind.com>

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