Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dynamic modification of pool size, added close and remove_idle methods
- Loading branch information
Showing
11 changed files
with
260 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
doc | ||
pkg | ||
.idea | ||
gene_pool-*.gem | ||
Gemfile.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
source "http://rubygems.org" | ||
|
||
group :development do | ||
gem 'rake' | ||
gem 'rdoc' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
GenePool Changelog | ||
===================== | ||
|
||
1.2.0 / 2011-12-07 | ||
|
||
- Allow dynamic modification of pool size. | ||
- Added close method which will prevent checking out of new connections and wait for and close all current connections. | ||
- Added remove_idle method which will close all current connections which have been idle for the given idle_time. | ||
|
||
1.1.1 / 2010-11-18 | ||
|
||
- In with_connection_auto_retry, add check for e.message =~ /expired/ as JRuby exception won't be a | ||
Timeout::Error at this point (http://jira.codehaus.org/browse/JRUBY-5194) | ||
|
||
1.1.0 / 2010-11-11 | ||
|
||
- Added with_connection_auto_retry to automatically retry yield block if a non-timeout exception occurs | ||
|
||
1.0.1 / 2010-09-12 | ||
|
||
- Debug logging was NOT thread-safe | ||
|
||
1.0.0 / 2010-09-05 | ||
|
||
- Initial release |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# gene_pool | ||
|
||
* http://github.com/bpardee/gene_pool | ||
|
||
## DESCRIPTION: | ||
|
||
Generic pooling library for connection pools. | ||
|
||
## FEATURES/PROBLEMS: | ||
|
||
* Thread-safe | ||
* Pure ruby | ||
|
||
## INSTALL: | ||
|
||
gem install gene_pool | ||
|
||
## EXAMPLE USAGE: | ||
|
||
class MyClient | ||
@@gene_pool = GenePool.new(:name => 'MyClient', | ||
:pool_size => 10, | ||
:warn_timeout => 0.25, | ||
:logger => Rails.logger, | ||
:close_proc => :close) do | ||
TCPSocket.new('myserver', 4321) | ||
end | ||
|
||
def send_message | ||
@@gene_pool.with_connection do |socket| | ||
begin | ||
# use socket here | ||
rescue Exception => e | ||
# If the socket gets closed, remove it from the pool | ||
@@gene_pool.remove(socket) | ||
end | ||
end | ||
end | ||
|
||
# Equivalent to send_message above | ||
def send_message_auto_remove | ||
# On exception, close and reopen socket and perform retry | ||
@@gene_pool.with_connection_auto_remove do |socket| | ||
# use socket here, | ||
end | ||
end | ||
|
||
def send_message_auto_retry | ||
# On exception, close and reopen socket and perform retry | ||
@@gene_pool.with_connection_auto_retry do |socket| | ||
# use socket here, | ||
end | ||
end | ||
end | ||
|
||
## Copyright | ||
|
||
Copyright (c) 2010-2011 Brad Pardee. See LICENSE for details. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,34 @@ | ||
# encoding: UTF-8 | ||
require 'rubygems' | ||
require 'rake' | ||
|
||
begin | ||
require 'jeweler' | ||
Jeweler::Tasks.new do |gemspec| | ||
gemspec.name = "gene_pool" | ||
gemspec.summary = "Generic pooling library for creating a connection pool" | ||
gemspec.description = "Generic pooling library for creating a connection pool" | ||
gemspec.email = "bradpardee@gmail.com" | ||
gemspec.homepage = "http://github.com/bpardee/gene_pool" | ||
gemspec.authors = ["Brad Pardee"] | ||
end | ||
require 'bundler/setup' | ||
rescue LoadError | ||
puts "Jeweler not available. Install it with: gem install jeweler" | ||
puts 'You must `gem install bundler` and `bundle install` to run rake tasks' | ||
end | ||
|
||
require 'rake' | ||
require 'rdoc/task' | ||
require 'rake/testtask' | ||
require 'rake/clean' | ||
|
||
desc "Build gem" | ||
task :gem do |t| | ||
system 'gem build gene_pool.gemspec' | ||
end | ||
|
||
Rake::TestTask.new(:test) do |t| | ||
t.libs << 'lib' | ||
t.libs << 'test' | ||
t.pattern = 'test/**/*_test.rb' | ||
t.verbose = false | ||
end | ||
|
||
task :default => :test | ||
|
||
RDoc::Task.new(:rdoc) do |rdoc| | ||
rdoc.rdoc_dir = 'rdoc' | ||
rdoc.title = 'GenePool' | ||
rdoc.options << '--line-numbers' << '--inline-source' | ||
rdoc.rdoc_files.include('README.md') | ||
rdoc.rdoc_files.include('lib/**/*.rb') | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,12 @@ | ||
# Generated by jeweler | ||
# DO NOT EDIT THIS FILE DIRECTLY | ||
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command | ||
# -*- encoding: utf-8 -*- | ||
|
||
Gem::Specification.new do |s| | ||
s.name = %q{gene_pool} | ||
s.version = "1.1.1" | ||
|
||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= | ||
s.authors = ["Brad Pardee"] | ||
s.date = %q{2010-11-18} | ||
s.description = %q{Generic pooling library for creating a connection pool} | ||
s.email = %q{bradpardee@gmail.com} | ||
s.extra_rdoc_files = [ | ||
"LICENSE", | ||
"README.rdoc" | ||
] | ||
s.files = [ | ||
".gitignore", | ||
"History.txt", | ||
"LICENSE", | ||
"README.rdoc", | ||
"Rakefile", | ||
"VERSION", | ||
"gene_pool.gemspec", | ||
"lib/gene_pool.rb", | ||
"test/gene_pool_test.rb" | ||
] | ||
s.homepage = %q{http://github.com/bpardee/gene_pool} | ||
s.rdoc_options = ["--charset=UTF-8"] | ||
s.name = "gene_pool" | ||
s.summary = 'Generic pooling library for creating a connection pool' | ||
s.description = 'Generic pooling library for creating a connection pool' | ||
s.authors = ['Brad Pardee'] | ||
s.email = ['bradpardee@gmail.com'] | ||
s.homepage = 'http://github.com/bpardee/gene_pool' | ||
s.files = Dir["{examples,lib}/**/*"] + %w(LICENSE.txt Rakefile Gemfile History.md README.md) | ||
s.test_files = ["test/gene_pool_test.rb"] | ||
s.version = '1.2.0' | ||
s.require_paths = ["lib"] | ||
s.rubygems_version = %q{1.3.6} | ||
s.summary = %q{Generic pooling library for creating a connection pool} | ||
s.test_files = [ | ||
"test/gene_pool_test.rb" | ||
] | ||
|
||
if s.respond_to? :specification_version then | ||
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION | ||
s.specification_version = 3 | ||
|
||
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then | ||
else | ||
end | ||
else | ||
end | ||
end | ||
|
Oops, something went wrong.