Skip to content

Commit

Permalink
Dynamic modification of pool size, added close and remove_idle methods
Browse files Browse the repository at this point in the history
  • Loading branch information
bpardee committed Dec 8, 2011
1 parent 0d08344 commit c065a9b
Show file tree
Hide file tree
Showing 11 changed files with 260 additions and 151 deletions.
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,3 +1,4 @@
doc
pkg
.idea
gene_pool-*.gem
Gemfile.lock
6 changes: 6 additions & 0 deletions Gemfile
@@ -0,0 +1,6 @@
source "http://rubygems.org"

group :development do
gem 'rake'
gem 'rdoc'
end
25 changes: 25 additions & 0 deletions History.md
@@ -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
20 changes: 0 additions & 20 deletions History.txt

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE → LICENSE.txt
@@ -1,4 +1,4 @@
Copyright (c) 2010 Brad Pardee
Copyright (c) 2010-2011 Brad Pardee

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
58 changes: 58 additions & 0 deletions README.md
@@ -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.
44 changes: 0 additions & 44 deletions README.rdoc

This file was deleted.

42 changes: 30 additions & 12 deletions Rakefile
@@ -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
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

55 changes: 9 additions & 46 deletions gene_pool.gemspec
@@ -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

0 comments on commit c065a9b

Please sign in to comment.