seamless_database_pool 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/{README → README.rdoc} +0 -0
- data/Rakefile +27 -27
- data/VERSION +1 -0
- data/lib/active_record/connection_adapters/seamless_database_pool_adapter.rb +0 -2
- data/lib/seamless_database_pool.rb +5 -0
- data/seamless_database_pool.gemspec +69 -0
- data/spec/connection_statistics_spec.rb +2 -2
- data/spec/filter_spec.rb +6 -6
- data/spec/seamless_database_pool_adapter_spec.rb +4 -23
- data/spec/spec_helper.rb +12 -0
- data/spec/test_models.rb +35 -0
- metadata +56 -22
data/{README → README.rdoc}
RENAMED
File without changes
|
data/Rakefile
CHANGED
@@ -1,15 +1,20 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rake'
|
3
3
|
require 'rake/rdoctask'
|
4
|
-
require 'rake/gempackagetask'
|
5
|
-
require 'spec/rake/spectask'
|
6
4
|
|
7
5
|
desc 'Default: run unit tests.'
|
8
6
|
task :default => :test
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
begin
|
9
|
+
require 'spec/rake/spectask'
|
10
|
+
desc 'Test seamless_database_pool.'
|
11
|
+
Spec::Rake::SpecTask.new(:test) do |t|
|
12
|
+
t.spec_files = FileList.new('spec/**/*_spec.rb')
|
13
|
+
end
|
14
|
+
rescue LoadError
|
15
|
+
tast :test do
|
16
|
+
STDERR.puts "You must have rspec >= 1.2.9 to run the tests"
|
17
|
+
end
|
13
18
|
end
|
14
19
|
|
15
20
|
desc 'Generate documentation for seamless_database_pool.'
|
@@ -20,25 +25,20 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
20
25
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
26
|
end
|
22
27
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
Rake::GemPackageTask.new(spec) do |pkg|
|
43
|
-
pkg.need_tar = true
|
44
|
-
end
|
28
|
+
begin
|
29
|
+
require 'jeweler'
|
30
|
+
Jeweler::Tasks.new do |gem|
|
31
|
+
gem.name = "seamless_database_pool"
|
32
|
+
gem.summary = "Add support for master/slave database clusters in ActiveRecord to improve performance."
|
33
|
+
gem.email = "brian@embellishedvisions.com"
|
34
|
+
gem.homepage = "http://github.com/bdurand/seamless_database_pool"
|
35
|
+
gem.authors = ["Brian Durand"]
|
36
|
+
|
37
|
+
gem.add_dependency('activerecord', '>= 2.2.2')
|
38
|
+
gem.add_development_dependency('rspec', '>= 1.2.9')
|
39
|
+
gem.add_development_dependency('jeweler')
|
40
|
+
end
|
41
|
+
|
42
|
+
Jeweler::GemcutterTasks.new
|
43
|
+
rescue LoadError
|
44
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.5
|
@@ -1,3 +1,8 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'seamless_database_pool', 'connect_timeout')
|
2
|
+
require File.join(File.dirname(__FILE__), 'seamless_database_pool', 'connection_statistics')
|
3
|
+
require File.join(File.dirname(__FILE__), 'seamless_database_pool', 'controller_filter')
|
4
|
+
require File.join(File.dirname(__FILE__), 'active_record', 'connection_adapters', 'seamless_database_pool_adapter')
|
5
|
+
|
1
6
|
# This module allows setting the read pool connection type. Generally you will use one of
|
2
7
|
#
|
3
8
|
# - use_random_read_connection
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{seamless_database_pool}
|
8
|
+
s.version = "1.0.5"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Brian Durand"]
|
12
|
+
s.date = %q{2010-02-07}
|
13
|
+
s.email = %q{brian@embellishedvisions.com}
|
14
|
+
s.extra_rdoc_files = [
|
15
|
+
"README.rdoc"
|
16
|
+
]
|
17
|
+
s.files = [
|
18
|
+
"MIT-LICENSE",
|
19
|
+
"README.rdoc",
|
20
|
+
"Rakefile",
|
21
|
+
"VERSION",
|
22
|
+
"init.rb",
|
23
|
+
"lib/active_record/connection_adapters/seamless_database_pool_adapter.rb",
|
24
|
+
"lib/seamless_database_pool.rb",
|
25
|
+
"lib/seamless_database_pool/connect_timeout.rb",
|
26
|
+
"lib/seamless_database_pool/connection_statistics.rb",
|
27
|
+
"lib/seamless_database_pool/controller_filter.rb",
|
28
|
+
"seamless_database_pool.gemspec",
|
29
|
+
"spec/connection_statistics_spec.rb",
|
30
|
+
"spec/filter_spec.rb",
|
31
|
+
"spec/seamless_database_pool_adapter_spec.rb",
|
32
|
+
"spec/seamless_database_pool_spec.rb",
|
33
|
+
"spec/spec_helper.rb",
|
34
|
+
"spec/test_models.rb"
|
35
|
+
]
|
36
|
+
s.homepage = %q{http://github.com/bdurand/seamless_database_pool}
|
37
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
38
|
+
s.require_paths = ["lib"]
|
39
|
+
s.rubygems_version = %q{1.3.5}
|
40
|
+
s.summary = %q{Add support for master/slave database clusters in ActiveRecord to improve performance.}
|
41
|
+
s.test_files = [
|
42
|
+
"spec/connection_statistics_spec.rb",
|
43
|
+
"spec/filter_spec.rb",
|
44
|
+
"spec/seamless_database_pool_adapter_spec.rb",
|
45
|
+
"spec/seamless_database_pool_spec.rb",
|
46
|
+
"spec/spec_helper.rb",
|
47
|
+
"spec/test_models.rb"
|
48
|
+
]
|
49
|
+
|
50
|
+
if s.respond_to? :specification_version then
|
51
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
52
|
+
s.specification_version = 3
|
53
|
+
|
54
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
55
|
+
s.add_runtime_dependency(%q<activerecord>, [">= 2.2.2"])
|
56
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
57
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
58
|
+
else
|
59
|
+
s.add_dependency(%q<activerecord>, [">= 2.2.2"])
|
60
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
61
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
62
|
+
end
|
63
|
+
else
|
64
|
+
s.add_dependency(%q<activerecord>, [">= 2.2.2"])
|
65
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
66
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe SeamlessDatabasePool::ConnectionStatistics do
|
4
4
|
|
5
5
|
module SeamlessDatabasePool
|
6
6
|
class ConnectionStatisticsTester
|
@@ -23,7 +23,7 @@ describe "SeamlessDatabasePool::ConnectionStatistics" do
|
|
23
23
|
"SELECT #{sql}/#{name}"
|
24
24
|
end
|
25
25
|
|
26
|
-
include ConnectionStatistics
|
26
|
+
include ::SeamlessDatabasePool::ConnectionStatistics
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
data/spec/filter_spec.rb
CHANGED
@@ -22,21 +22,21 @@ describe "SeamlessDatabasePool::ControllerFilter" do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def base_action
|
25
|
-
SeamlessDatabasePool.read_only_connection_type
|
25
|
+
::SeamlessDatabasePool.read_only_connection_type
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
class TestBaseController < TestApplicationController
|
30
|
-
include SeamlessDatabasePool::ControllerFilter
|
30
|
+
include ::SeamlessDatabasePool::ControllerFilter
|
31
31
|
|
32
32
|
use_database_pool :read => :persistent
|
33
33
|
|
34
34
|
def read
|
35
|
-
SeamlessDatabasePool.read_only_connection_type
|
35
|
+
::SeamlessDatabasePool.read_only_connection_type
|
36
36
|
end
|
37
37
|
|
38
38
|
def other
|
39
|
-
SeamlessDatabasePool.read_only_connection_type
|
39
|
+
::SeamlessDatabasePool.read_only_connection_type
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -44,11 +44,11 @@ describe "SeamlessDatabasePool::ControllerFilter" do
|
|
44
44
|
use_database_pool :all => :random, [:edit, :save, :redirect_master_action] => :master
|
45
45
|
|
46
46
|
def edit
|
47
|
-
SeamlessDatabasePool.read_only_connection_type
|
47
|
+
::SeamlessDatabasePool.read_only_connection_type
|
48
48
|
end
|
49
49
|
|
50
50
|
def save
|
51
|
-
SeamlessDatabasePool.read_only_connection_type
|
51
|
+
::SeamlessDatabasePool.read_only_connection_type
|
52
52
|
end
|
53
53
|
|
54
54
|
def redirect_master_action
|
@@ -363,32 +363,13 @@ end
|
|
363
363
|
|
364
364
|
describe "Reload extensions" do
|
365
365
|
before(:all) do
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
t.column :name, :string
|
370
|
-
t.column :seamless_database_pool_test_model_id, :integer
|
371
|
-
end unless table_exists?
|
372
|
-
belongs_to :seamless_database_pool_test_model
|
373
|
-
end
|
374
|
-
|
375
|
-
class SeamlessDatabasePoolTestModel < ActiveRecord::Base
|
376
|
-
ActiveRecord::Migration.create_table(:seamless_database_pool_test_models) do |t|
|
377
|
-
t.column :name, :string
|
378
|
-
end unless table_exists?
|
379
|
-
has_many :seamless_database_pool_test_things
|
380
|
-
end
|
381
|
-
end
|
382
|
-
|
383
|
-
@record = SeamlessDatabasePoolTestModel.create(:name => 'test')
|
384
|
-
@thing = SeamlessDatabasePoolTestThing.create(:name => 'thing', :seamless_database_pool_test_model_id => @record.id)
|
366
|
+
SeamlessDatabasePool::Test.create_tables
|
367
|
+
@record = SeamlessDatabasePool::Test::Model.create(:name => 'test')
|
368
|
+
@thing = SeamlessDatabasePool::Test::Thing.create(:name => 'thing', :model_id => @record.id)
|
385
369
|
end
|
386
370
|
|
387
371
|
after(:all) do
|
388
|
-
|
389
|
-
ActiveRecord::Migration.drop_table(:seamless_database_pool_test_models) if SeamlessDatabasePoolTestModel.table_exists?
|
390
|
-
ActiveRecord::Migration.drop_table(:seamless_database_pool_test_things) if SeamlessDatabasePoolTestThing.table_exists?
|
391
|
-
end
|
372
|
+
SeamlessDatabasePool::Test.drop_tables
|
392
373
|
end
|
393
374
|
|
394
375
|
it "should force the master connection on reload" do
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
active_record_version = ENV["ACTIVE_RECORD_VERSION"] || [">= 2.2.2", "< 3.0"]
|
4
|
+
active_record_version = [active_record_version] unless active_record_version.is_a?(Array)
|
5
|
+
gem 'activerecord', *active_record_version
|
6
|
+
|
7
|
+
require 'spec'
|
8
|
+
require 'active_record'
|
9
|
+
puts "Testing Against ActiveRecord #{ActiveRecord::VERSION::STRING}" if defined?(ActiveRecord::VERSION)
|
10
|
+
|
11
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'seamless_database_pool'))
|
12
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'test_models'))
|
data/spec/test_models.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
module SeamlessDatabasePool
|
2
|
+
class Test < ActiveRecord::Base
|
3
|
+
def self.create_tables
|
4
|
+
db_dir = File.expand_path(File.join(__FILE__, '..', 'tmp'))
|
5
|
+
Dir.mkdir(db_dir) unless File.exist?(db_dir)
|
6
|
+
db = File.join(db_dir, 'test_SeamlessDatabasePool.sqlite3')
|
7
|
+
establish_connection("adapter" => "sqlite3", "database" => db)
|
8
|
+
|
9
|
+
connection.create_table(Thing.table_name) do |t|
|
10
|
+
t.column :name, :string
|
11
|
+
t.column :model_id, :integer
|
12
|
+
end unless Thing.table_exists?
|
13
|
+
|
14
|
+
connection.create_table(Model.table_name) do |t|
|
15
|
+
t.column :name, :string
|
16
|
+
end unless Model.table_exists?
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.drop_tables
|
20
|
+
db_dir = File.expand_path(File.join(__FILE__, '..', 'tmp'))
|
21
|
+
db = File.join(db_dir, 'test_SeamlessDatabasePool.sqlite3')
|
22
|
+
connection.disconnect!
|
23
|
+
File.delete(db) if File.exist?(db)
|
24
|
+
Dir.delete(db_dir) if File.exist?(db_dir) and Dir.entries(db_dir).reject{|f| f.match(/^\.+$/)}.empty?
|
25
|
+
end
|
26
|
+
|
27
|
+
class Thing < Test
|
28
|
+
belongs_to :model, :class_name => "SeamlessDatabasePool::Test::Model"
|
29
|
+
end
|
30
|
+
|
31
|
+
class Model < Test
|
32
|
+
has_many :things, :class_name => "SeamlessDatabasePool::Test::Thing"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seamless_database_pool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Durand
|
@@ -9,40 +9,72 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-02-07 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: activerecord
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.2.2
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.2.9
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: jeweler
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
description:
|
17
46
|
email: brian@embellishedvisions.com
|
18
47
|
executables: []
|
19
48
|
|
20
49
|
extensions: []
|
21
50
|
|
22
51
|
extra_rdoc_files:
|
23
|
-
- README
|
52
|
+
- README.rdoc
|
24
53
|
files:
|
54
|
+
- MIT-LICENSE
|
55
|
+
- README.rdoc
|
56
|
+
- Rakefile
|
57
|
+
- VERSION
|
58
|
+
- init.rb
|
25
59
|
- lib/active_record/connection_adapters/seamless_database_pool_adapter.rb
|
60
|
+
- lib/seamless_database_pool.rb
|
26
61
|
- lib/seamless_database_pool/connect_timeout.rb
|
27
62
|
- lib/seamless_database_pool/connection_statistics.rb
|
28
63
|
- lib/seamless_database_pool/controller_filter.rb
|
29
|
-
-
|
30
|
-
-
|
31
|
-
-
|
32
|
-
-
|
33
|
-
-
|
64
|
+
- seamless_database_pool.gemspec
|
65
|
+
- spec/connection_statistics_spec.rb
|
66
|
+
- spec/filter_spec.rb
|
67
|
+
- spec/seamless_database_pool_adapter_spec.rb
|
68
|
+
- spec/seamless_database_pool_spec.rb
|
69
|
+
- spec/spec_helper.rb
|
70
|
+
- spec/test_models.rb
|
34
71
|
has_rdoc: true
|
35
|
-
homepage: http://
|
72
|
+
homepage: http://github.com/bdurand/seamless_database_pool
|
36
73
|
licenses: []
|
37
74
|
|
38
75
|
post_install_message:
|
39
76
|
rdoc_options:
|
40
|
-
- --
|
41
|
-
- Seamless Database Pool
|
42
|
-
- --line-numbers
|
43
|
-
- --inline-source
|
44
|
-
- --main
|
45
|
-
- README
|
77
|
+
- --charset=UTF-8
|
46
78
|
require_paths:
|
47
79
|
- lib
|
48
80
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -57,15 +89,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
89
|
- !ruby/object:Gem::Version
|
58
90
|
version: "0"
|
59
91
|
version:
|
60
|
-
requirements:
|
61
|
-
|
62
|
-
rubyforge_project:
|
92
|
+
requirements: []
|
93
|
+
|
94
|
+
rubyforge_project:
|
63
95
|
rubygems_version: 1.3.5
|
64
96
|
signing_key:
|
65
97
|
specification_version: 3
|
66
|
-
summary:
|
98
|
+
summary: Add support for master/slave database clusters in ActiveRecord to improve performance.
|
67
99
|
test_files:
|
68
100
|
- spec/connection_statistics_spec.rb
|
69
101
|
- spec/filter_spec.rb
|
70
102
|
- spec/seamless_database_pool_adapter_spec.rb
|
71
103
|
- spec/seamless_database_pool_spec.rb
|
104
|
+
- spec/spec_helper.rb
|
105
|
+
- spec/test_models.rb
|