Provided by: libmongodbx-class-perl_1.02-3_all
NAME
MongoDBx::Class::ConnectionPool::Backup - A simple connection pool with a backup connection
VERSION
version 1.02
SYNOPSIS
# create a MongoDBx::Class object normally: use MongoDBx::Class; my $dbx = MongoDBx::Class->new(namespace => 'MyApp::Model::DB'); # instead of connection, create a pool my $pool = $dbx->pool(max_conns => 200, type => 'backup'); # max_conns defaults to 100 # or, if you need to pass attributes to MongoDB::Connection->new(): my $pool = $dbx->pool(max_conns => 200, type => 'backup', params => { host => $host, username => $username, password => $password, }); # get a connection from the pool on a per-request basis my $conn = $pool->get_conn; # ... do stuff with $conn and return it when done ... $pool->return_conn($conn);
DESCRIPTION
MongoDBx::Class::ConnectionPool::Backup is an implementation of the MongoDBx::Class::ConnectionPool Moose role. In this implementation, the pool has a maximum number of connections. Whenever someone makes a request for a connection, an existing connection is taken out of the pool and returned (or created if none are available and the maximum has not been reached). When the requester is done with the connection, they are expected to return the connection to the pool. If a connection is not available for the requester (i.e. the maximum has been reached and all connections are used), a backup connection is returned. This backup connection can be shared by multiple requesters, but the pool's main connections cannot. This pool is most appropriate for larger pools where you do not wish to share connections between clients, but want to ensure that on the rare occasions that all connections are used, requests will still be honored.
CONSUMES
MongoDBx::Class::ConnectionPool
ATTRIBUTES
The following attributes are added: backup_conn The backup MongoDBx::Class::Connection object.
METHODS
get_conn() Returns a connection from the pool to a requester. If a connection is not available but the maximum has not been reached, a new connection is made, otherwise the backup connection is returned. return_conn( $conn ) Returns a connection to the pool. If a client attempts to return the backup connection, nothing will happen (the backup connection is always saved).
INTERNAL METHODS
BUILD() Called by Moose after object initiation.
AUTHOR
Ido Perlmuter, "<ido at ido50.net>"
BUGS
Please report any bugs or feature requests to "bug-mongodbx-class at rt.cpan.org", or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MongoDBx-Class <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MongoDBx-Class>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command. perldoc MongoDBx::Class::ConnectionPool::Backup You can also look for information at: • RT: CPAN's request tracker <http://rt.cpan.org/NoAuth/Bugs.html?Dist=MongoDBx::Class> • AnnoCPAN: Annotated CPAN documentation <http://annocpan.org/dist/MongoDBx::Class> • CPAN Ratings <http://cpanratings.perl.org/d/MongoDBx::Class> • Search CPAN <http://search.cpan.org/dist/MongoDBx::Class/>
SEE ALSO
MongoDBx::Class, MongoDB::Connection.
LICENSE AND COPYRIGHT
Copyright 2010-2012 Ido Perlmuter. This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information. perl v5.14.2 2012-12-3MongoDBx::Class::ConnectionPool::Backup(3pm)