Skip to content

Commit

Permalink
Merge remote-tracking branch 'forked/master' into rails5
Browse files Browse the repository at this point in the history
  • Loading branch information
jiikko committed Sep 29, 2016
2 parents 70412da + ab9e256 commit f247b42
Show file tree
Hide file tree
Showing 11 changed files with 172 additions and 192 deletions.
20 changes: 20 additions & 0 deletions HISTORY.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
1.0.18

ActiveRecord 5.0 compatibility (thanks jkowens)

1.0.17

Do not update the HTTP session if there are no changes.

1.0.16

Use shorter to_s output for output on connection.inspect.

1.0.15

Implement less wordy connection to string method so logs don't fill up with long messages on connection errors.

Update specs to remove deprecation warnings

Fix adapter specs to work with ActiveRecord 4.1 configuration changes

1.0.14

Remove custom connection timeout logic; Use the underlying driver's timeouts instead.
Expand Down
25 changes: 1 addition & 24 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'rubygems'
require 'rake'
require 'yaml'
require "bundler/gem_tasks"

desc 'Default: run unit tests.'
task :default => :test
Expand Down Expand Up @@ -59,27 +60,3 @@ rescue LoadError
STDERR.puts "You must have rspec >= 2.0 to run the tests"
end
end

begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "seamless_database_pool"
gem.summary = "Add support for master/slave database clusters in ActiveRecord to improve performance."
gem.email = "bbdurand@gmail.com"
gem.homepage = "http://github.com/bdurand/seamless_database_pool"
gem.authors = ["Brian Durand"]
gem.files = FileList["lib/**/*", "spec/**/*", "README.rdoc", "Rakefile", "MIT-LICENSE"].to_a
gem.has_rdoc = true
gem.extra_rdoc_files = ["README.rdoc", "MIT-LICENSE"]

gem.add_dependency('activerecord', '>= 3.0.20')
gem.add_development_dependency('rspec', '>= 2.0')
gem.add_development_dependency('jeweler')
gem.add_development_dependency('sqlite3')
gem.add_development_dependency('mysql')
gem.add_development_dependency('pg')
end

Jeweler::GemcutterTasks.new
rescue LoadError
end
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.14
1.0.18
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def conn.spd_connection_name
end if config[:read_pool]

klass = ::ActiveRecord::ConnectionAdapters::SeamlessDatabasePoolAdapter.adapter_class(master_connection)
klass.new(nil, logger, master_connection, read_connections, pool_weights)
klass.new(nil, logger, master_connection, read_connections, pool_weights, config)
end

def establish_adapter(adapter)
Expand Down Expand Up @@ -162,12 +162,12 @@ def visitor_for(pool)
end
end

def initialize(connection, logger, master_connection, read_connections, pool_weights)
def initialize(connection, logger, master_connection, read_connections, pool_weights, config)
@master_connection = master_connection
@read_connections = read_connections.dup.freeze

super(connection, logger)
super(connection, logger, config)

@weighted_read_connections = []
pool_weights.each_pair do |conn, weight|
weight.times{@weighted_read_connections << conn}
Expand Down Expand Up @@ -266,7 +266,15 @@ def use_master_connection
@use_master = save_val
end
end


def to_s
"#<#{self.class.name}:0x#{object_id.to_s(16)} #{all_connections.size} connections>"
end

def inspect
to_s
end

class DatabaseConnectionError < StandardError
end

Expand Down Expand Up @@ -383,6 +391,7 @@ def do_to_connections
raise e if conn == master_connection
end
end
nil
end
end
end
Expand Down
85 changes: 18 additions & 67 deletions seamless_database_pool.gemspec
Original file line number Diff line number Diff line change
@@ -1,70 +1,21 @@
# Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
Gem::Specification.new do |spec|
spec.name = "seamless_database_pool"
spec.version = File.read(File.expand_path("../VERSION", __FILE__)).chomp
spec.authors = ["Brian Durand"]
spec.email = ["bbdurand@gmail.com"]
spec.description = %q{Add support for master/slave database database clusters in ActiveRecord to improve performance.}
spec.summary = %q{Add support for master/slave database clusters in ActiveRecord to improve performance.}
spec.homepage = "https://github.com/bdurand/seamless_database_pool"
spec.license = "MIT"

Gem::Specification.new do |s|
s.name = "seamless_database_pool"
s.version = "1.0.14"
spec.files = `git ls-files`.split($/)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Brian Durand"]
s.date = "2013-07-18"
s.email = "bbdurand@gmail.com"
s.extra_rdoc_files = [
"MIT-LICENSE",
"README.rdoc"
]
s.files = [
"MIT-LICENSE",
"README.rdoc",
"Rakefile",
"lib/active_record/connection_adapters/seamless_database_pool_adapter.rb",
"lib/seamless_database_pool.rb",
"lib/seamless_database_pool/arel_compiler.rb",
"lib/seamless_database_pool/connection_statistics.rb",
"lib/seamless_database_pool/controller_filter.rb",
"lib/seamless_database_pool/railtie.rb",
"spec/connection_adapters_spec.rb",
"spec/connection_statistics_spec.rb",
"spec/controller_filter_spec.rb",
"spec/database.yml",
"spec/seamless_database_pool_adapter_spec.rb",
"spec/seamless_database_pool_spec.rb",
"spec/spec_helper.rb",
"spec/test_adapter/active_record/connection_adapters/read_only_adapter.rb",
"spec/test_model.rb"
]
s.homepage = "http://github.com/bdurand/seamless_database_pool"
s.require_paths = ["lib"]
s.rubygems_version = "1.8.25"
s.summary = "Add support for master/slave database clusters in ActiveRecord to improve performance."

if s.respond_to? :specification_version then
s.specification_version = 3

if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<activerecord>, [">= 3.0.20"])
s.add_development_dependency(%q<rspec>, [">= 2.0"])
s.add_development_dependency(%q<jeweler>, [">= 0"])
s.add_development_dependency(%q<sqlite3>, [">= 0"])
s.add_development_dependency(%q<mysql>, [">= 0"])
s.add_development_dependency(%q<pg>, [">= 0"])
else
s.add_dependency(%q<activerecord>, [">= 3.0.20"])
s.add_dependency(%q<rspec>, [">= 2.0"])
s.add_dependency(%q<jeweler>, [">= 0"])
s.add_dependency(%q<sqlite3>, [">= 0"])
s.add_dependency(%q<mysql>, [">= 0"])
s.add_dependency(%q<pg>, [">= 0"])
end
else
s.add_dependency(%q<activerecord>, [">= 3.0.20"])
s.add_dependency(%q<rspec>, [">= 2.0"])
s.add_dependency(%q<jeweler>, [">= 0"])
s.add_dependency(%q<sqlite3>, [">= 0"])
s.add_dependency(%q<mysql>, [">= 0"])
s.add_dependency(%q<pg>, [">= 0"])
end
spec.add_runtime_dependency(%q<activerecord>, [">= 3.0.20"])
spec.add_development_dependency(%q<rspec>, [">= 2.0"])
spec.add_development_dependency(%q<sqlite3>, [">= 0"])
spec.add_development_dependency(%q<mysql>, [">= 0"])
spec.add_development_dependency(%q<pg>, [">= 0"])
end

6 changes: 5 additions & 1 deletion spec/connection_adapters_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
let(:master_connection){ connection.master_connection }

before(:all) do
ActiveRecord::Base.configurations = {'adapter' => "sqlite3", 'database' => ":memory:"}
if ActiveRecord::VERSION::MAJOR < 3 || (ActiveRecord::VERSION::MAJOR == 4 && ActiveRecord::VERSION::MINOR == 0)
ActiveRecord::Base.configurations = {'adapter' => "sqlite3", 'database' => ":memory:"}
else
ActiveRecord::Base.configurations = {"test" => {'adapter' => "sqlite3", 'database' => ":memory:"}}
end
ActiveRecord::Base.establish_connection('adapter' => "sqlite3", 'database' => ":memory:")
ActiveRecord::Base.connection
SeamlessDatabasePool::TestModel.db_model(adapter).create_tables
Expand Down
2 changes: 1 addition & 1 deletion spec/connection_statistics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def select (sql, name = nil, binds = [])

it "should increment counts only once within a block" do
connection = SeamlessDatabasePool::ConnectionStatisticsTester.new
connection.should_receive(:execute).with('SQL')
expect(connection).to receive(:execute).with('SQL')
connection.update('SQL')
connection.connection_statistics.should == {:update => 1}
end
Expand Down
1 change: 1 addition & 0 deletions spec/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ postgresql:
mysql:
adapter: seamless_database_pool
database: seamless_database_pool_test
prepared_statements: false
username: root
password:
master:
Expand Down
Loading

0 comments on commit f247b42

Please sign in to comment.