🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

generic_connection_pool

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

generic_connection_pool

0.1.1
Rubygems
Version published
Maintainers
1
Created
Source

= generic_connection_pool

== DESCRIPTION Always network clients require a connection pool, like database connection, cache connection and others. Generic connection pool can be used with anything. It is extracted from ActiveRecord ConnectionPool, a little changed.Sharing a limited number of network connections among many threads. Connections are created delayed.

== USEAGE

Connections can be obtained and used from a connection pool in several ways:

  • Use connection_pool.connection to obtain a connection instance. and when you're done with the connection(s) and wish it to be returned to the pool, you can call connection_pool.release_connection to release connection back to the connection pool.
  • Manually check out a connection from the pool with connection_pool.checkout. You are responsible for returning this connection to the pool when finished by calling connection_pool.checkin(connection).
  • Use connection_pool.with_connection(&block), which obtains a connection, yields it as the sole argument to the block, and returns it to the pool after the block completes.

Connections in the pool may be Adapter instance that should implete methods like verify!, disconnect!, active? etc.

== Example require 'generic_connection_pool' connection_pool = ConnectionPool.new(:size => 5, :timeout => 5) do new_connection_adapter end connection_pool.connection connection_pool.release_connection

connection = connection_pool.checkout connection_pool.checkin(connection)

connection.with_connection{|connection| do_somting_with_connection}

Do something in the block, that always create an adapter instance or connect to a server.

== INSTALL gem install generic_connection_pool

== AUTHOR Kame Chen

FAQs

Package last updated on 06 Apr 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts