Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 6 commits
  • 3 files changed
  • 0 commit comments
  • 2 contributors
Commits on Feb 22, 2012
@mikepilat mikepilat Remove potential leak of config bfd91e9
Commits on Feb 29, 2012
@bpot bpot DataFabric.logger: set the default logger at INFO level to prevent lo…
…ck contention (@ ConnectionProxy#method_missing) for threaded work loads
bc42acf
@bpot bpot Merge pull request #1 from mikepilat/patch-1
Remove potential leak of config
f38de36
@bpot bpot Merge pull request #3 from otherinbox/master
Prevent lock contention with default logger
0ef0854
Commits on Apr 03, 2012
@bpot bpot Add support for Rails 3.2 ae05ccb
@bpot bpot Fix Rails 3.2 support 0f4942f
View
11 lib/data_fabric.rb
@@ -41,8 +41,7 @@
module DataFabric
def self.logger
- devnull = RUBY_PLATFORM =~ /w32/ ? 'nul' : '/dev/null'
- @logger ||= ActiveRecord::Base.logger || Logger.new(devnull)
+ @logger ||= ActiveRecord::Base.logger || default_logger
end
def self.logger=(log)
@@ -94,6 +93,14 @@ def self.ensure_setup
Thread.current[:shards] = {} unless Thread.current[:shards]
end
+ private
+ def self.default_logger
+ devnull = RUBY_PLATFORM =~ /w32/ ? 'nul' : '/dev/null'
+ l = Logger.new(devnull)
+ l.level = Logger::INFO
+ l
+ end
+
end
require 'data_fabric/extensions'
View
2  lib/data_fabric/connection_proxy.rb
@@ -120,7 +120,7 @@ def current_pool
name = connection_name
self.class.shard_pools[name] ||= begin
config = ActiveRecord::Base.configurations[name]
- raise ArgumentError, "Unknown database config: #{name}, have #{ActiveRecord::Base.configurations.inspect}" unless config
+ raise ArgumentError, "Unknown database config: #{name}" unless config
ActiveRecord::ConnectionAdapters::ConnectionPool.new(spec_for(config))
end
end
View
14 lib/data_fabric/extensions.rb
@@ -22,8 +22,18 @@ def self.included(model)
module ClassMethods
def data_fabric(options)
DataFabric.logger.info { "Creating data_fabric proxy for class #{name}" }
- connection_handler.connection_pools[name] = PoolProxy.new(ConnectionProxy.new(self, options))
+ pool_proxy = PoolProxy.new(ConnectionProxy.new(self, options))
+ klass_name = name
+ connection_handler.instance_eval do
+ if @class_to_pool
+ # Rails 3.2
+ @class_to_pool[klass_name] = pool_proxy
+ else
+ # <= Rails 3.1
+ @connection_pools[klass_name] = pool_proxy
+ end
+ end
end
end
end
-end
+end

No commit comments for this range

Something went wrong with that request. Please try again.