octoshark 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ci-legacy.yml +66 -0
- data/.github/workflows/ci.yml +64 -0
- data/.ruby-version +1 -1
- data/Appraisals +20 -19
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -0
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/gemfiles/rails3.0.gemfile +2 -1
- data/gemfiles/rails3.1.gemfile +3 -1
- data/gemfiles/rails3.2.gemfile +3 -1
- data/gemfiles/rails4.0.gemfile +3 -1
- data/gemfiles/rails4.1.gemfile +3 -1
- data/gemfiles/rails4.2.gemfile +3 -1
- data/gemfiles/rails5.0.gemfile +3 -1
- data/gemfiles/rails5.1.gemfile +9 -0
- data/gemfiles/rails5.2.gemfile +9 -0
- data/gemfiles/rails6.0.gemfile +9 -0
- data/gemfiles/rails6.1.gemfile +9 -0
- data/lib/octoshark/connection_pools_manager.rb +16 -13
- data/lib/octoshark/version.rb +1 -1
- data/octoshark.gemspec +3 -4
- data/spec/octoshark/connection_manager_spec.rb +1 -1
- data/spec/octoshark/connection_pools_manager_spec.rb +1 -1
- data/spec/support/{config.yml.travis → config.yml.github} +6 -6
- metadata +20 -30
- data/.travis.yml +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 743be64d2aeb897827aec871dfd86150ea1ca7ce6505839cea1caf16e85676bc
|
4
|
+
data.tar.gz: a801773571a7388fed3d16179be6006d10a6e060fb514813a2e21ba3532816ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fa8e793d0eae00f5d99420e1f3b5bc6218b9b5a5b8c27b0c63dbbde080265d5797cc4d56cbce049cd25459e0f8961228f0acb5d677f35f1de45a42fbd82f610
|
7
|
+
data.tar.gz: 16f82b5d43d619ff5d8691229a8377189c10ef3b9d20752649d2e63725bff171afe9f232d2300916b573bff7260ff63d92be08bae567934ff7751285d6240728
|
@@ -0,0 +1,66 @@
|
|
1
|
+
name: Build Legacy
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
branches:
|
6
|
+
- "*"
|
7
|
+
push:
|
8
|
+
branches:
|
9
|
+
- master
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
test:
|
13
|
+
runs-on: ubuntu-16.04
|
14
|
+
services:
|
15
|
+
mysql:
|
16
|
+
image: mysql:5.5
|
17
|
+
env:
|
18
|
+
MYSQL_ROOT_PASSWORD: pass
|
19
|
+
ports:
|
20
|
+
- "3306:3306"
|
21
|
+
options: >-
|
22
|
+
--health-cmd="mysqladmin ping"
|
23
|
+
--health-interval=10s
|
24
|
+
--health-timeout=5s
|
25
|
+
--health-retries=3
|
26
|
+
|
27
|
+
name: ruby-${{ matrix.ruby }} ${{ matrix.gemfile }}
|
28
|
+
strategy:
|
29
|
+
matrix:
|
30
|
+
include:
|
31
|
+
- gemfile: rails3.0
|
32
|
+
ruby: 2.2
|
33
|
+
- gemfile: rails3.1
|
34
|
+
ruby: 2.2
|
35
|
+
- gemfile: rails3.2
|
36
|
+
ruby: 2.2
|
37
|
+
|
38
|
+
- gemfile: rails4.0
|
39
|
+
ruby: 2.4
|
40
|
+
- gemfile: rails4.1
|
41
|
+
ruby: 2.4
|
42
|
+
- gemfile: rails4.2
|
43
|
+
ruby: 2.4
|
44
|
+
|
45
|
+
env:
|
46
|
+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
|
47
|
+
BUNDLE_PATH_RELATIVE_TO_CWD: true
|
48
|
+
|
49
|
+
steps:
|
50
|
+
- uses: actions/checkout@master
|
51
|
+
|
52
|
+
- name: Set up Ruby
|
53
|
+
uses: ruby/setup-ruby@v1
|
54
|
+
with:
|
55
|
+
ruby-version: ${{ matrix.ruby }}
|
56
|
+
bundler: default
|
57
|
+
bundler-cache: true
|
58
|
+
|
59
|
+
- name: Set up database
|
60
|
+
run: |
|
61
|
+
cp spec/support/config.yml.github spec/support/config.yml
|
62
|
+
bundle exec rake db:create
|
63
|
+
|
64
|
+
- name: Run tests
|
65
|
+
run: |
|
66
|
+
bundle exec rspec spec
|
@@ -0,0 +1,64 @@
|
|
1
|
+
name: Build
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
branches:
|
6
|
+
- "*"
|
7
|
+
push:
|
8
|
+
branches:
|
9
|
+
- master
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
test:
|
13
|
+
runs-on: ubuntu-latest
|
14
|
+
services:
|
15
|
+
mysql:
|
16
|
+
image: mysql:5.7
|
17
|
+
env:
|
18
|
+
MYSQL_ROOT_PASSWORD: pass
|
19
|
+
ports:
|
20
|
+
- "3306:3306"
|
21
|
+
options: >-
|
22
|
+
--health-cmd="mysqladmin ping"
|
23
|
+
--health-interval=10s
|
24
|
+
--health-timeout=5s
|
25
|
+
--health-retries=3
|
26
|
+
|
27
|
+
name: ruby-${{ matrix.ruby }} ${{ matrix.gemfile }}
|
28
|
+
strategy:
|
29
|
+
matrix:
|
30
|
+
include:
|
31
|
+
- gemfile: rails5.0
|
32
|
+
ruby: 2.6
|
33
|
+
- gemfile: rails5.1
|
34
|
+
ruby: 2.6
|
35
|
+
- gemfile: rails5.2
|
36
|
+
ruby: 2.6
|
37
|
+
|
38
|
+
- gemfile: rails6.0
|
39
|
+
ruby: 2.7
|
40
|
+
- gemfile: rails6.1
|
41
|
+
ruby: 2.7
|
42
|
+
|
43
|
+
env:
|
44
|
+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
|
45
|
+
BUNDLE_PATH_RELATIVE_TO_CWD: true
|
46
|
+
|
47
|
+
steps:
|
48
|
+
- uses: actions/checkout@master
|
49
|
+
|
50
|
+
- name: Set up Ruby
|
51
|
+
uses: ruby/setup-ruby@v1
|
52
|
+
with:
|
53
|
+
ruby-version: ${{ matrix.ruby }}
|
54
|
+
bundler: default
|
55
|
+
bundler-cache: true
|
56
|
+
|
57
|
+
- name: Set up database
|
58
|
+
run: |
|
59
|
+
cp spec/support/config.yml.github spec/support/config.yml
|
60
|
+
bundle exec rake db:create
|
61
|
+
|
62
|
+
- name: Run tests
|
63
|
+
run: |
|
64
|
+
bundle exec rspec spec
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.4
|
data/Appraisals
CHANGED
@@ -1,28 +1,29 @@
|
|
1
|
-
appraise "
|
2
|
-
gem "activerecord", "~>
|
3
|
-
gem "mysql2",
|
4
|
-
|
5
|
-
|
6
|
-
appraise "rails3.1" do
|
7
|
-
gem "activerecord", "~> 3.1.0"
|
8
|
-
end
|
9
|
-
|
10
|
-
appraise "rails3.2" do
|
11
|
-
gem "activerecord", "~> 3.2.0"
|
1
|
+
appraise "rails5.0" do
|
2
|
+
gem "activerecord", "~> 5.0.0"
|
3
|
+
gem "mysql2", "~> 0.5.2"
|
4
|
+
gem "sqlite3", "~> 1.3.13"
|
12
5
|
end
|
13
6
|
|
14
|
-
appraise "
|
15
|
-
gem "activerecord", "~>
|
7
|
+
appraise "rails5.1" do
|
8
|
+
gem "activerecord", "~> 5.1.0"
|
9
|
+
gem "mysql2", "~> 0.5.2"
|
10
|
+
gem "sqlite3", "~> 1.4.1"
|
16
11
|
end
|
17
12
|
|
18
|
-
appraise "
|
19
|
-
gem "activerecord", "~>
|
13
|
+
appraise "rails5.2" do
|
14
|
+
gem "activerecord", "~> 5.2.0"
|
15
|
+
gem "mysql2", "~> 0.5.2"
|
16
|
+
gem "sqlite3", "~> 1.4.1"
|
20
17
|
end
|
21
18
|
|
22
|
-
appraise "
|
23
|
-
gem "activerecord", "~>
|
19
|
+
appraise "rails6.0" do
|
20
|
+
gem "activerecord", "~> 6.0.0"
|
21
|
+
gem "mysql2", "~> 0.5.2"
|
22
|
+
gem "sqlite3", "~> 1.4.1"
|
24
23
|
end
|
25
24
|
|
26
|
-
appraise "
|
27
|
-
gem "activerecord", "~>
|
25
|
+
appraise "rails6.1" do
|
26
|
+
gem "activerecord", "~> 6.1.0"
|
27
|
+
gem "mysql2", "~> 0.5.2"
|
28
|
+
gem "sqlite3", "~> 1.4.1"
|
28
29
|
end
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -19,7 +19,7 @@ namespace :db do
|
|
19
19
|
task :create => :establish_connection do
|
20
20
|
@databases.each do |database|
|
21
21
|
begin
|
22
|
-
ActiveRecord::Base.connection.create_database(database)
|
22
|
+
ActiveRecord::Base.connection.create_database(database, charset: 'utf8')
|
23
23
|
puts "#{database} created."
|
24
24
|
rescue ActiveRecord::StatementInvalid => e
|
25
25
|
if e.message.match /database exists/
|
data/gemfiles/rails3.0.gemfile
CHANGED
data/gemfiles/rails3.1.gemfile
CHANGED
data/gemfiles/rails3.2.gemfile
CHANGED
data/gemfiles/rails4.0.gemfile
CHANGED
data/gemfiles/rails4.1.gemfile
CHANGED
data/gemfiles/rails4.2.gemfile
CHANGED
data/gemfiles/rails5.0.gemfile
CHANGED
@@ -61,14 +61,6 @@ module Octoshark
|
|
61
61
|
end
|
62
62
|
|
63
63
|
private
|
64
|
-
def spec_class
|
65
|
-
if defined?(ActiveRecord::ConnectionAdapters::ConnectionSpecification)
|
66
|
-
spec_class = ActiveRecord::ConnectionAdapters::ConnectionSpecification
|
67
|
-
else
|
68
|
-
# Rails 3.0, 3.1 and 3.2
|
69
|
-
spec_class = ActiveRecord::Base::ConnectionSpecification
|
70
|
-
end
|
71
|
-
end
|
72
64
|
|
73
65
|
def setup_connection_pools
|
74
66
|
@connection_pools = HashWithIndifferentAccess.new
|
@@ -79,13 +71,24 @@ module Octoshark
|
|
79
71
|
end
|
80
72
|
|
81
73
|
def create_connection_pool(name, config)
|
82
|
-
adapter_method = "#{config[:adapter]}_connection"
|
83
74
|
spec =
|
84
|
-
if
|
85
|
-
|
86
|
-
|
75
|
+
if defined?(ActiveRecord::ConnectionAdapters::PoolConfig)
|
76
|
+
env_name = defined?(Rails) ? Rails.env : nil
|
77
|
+
db_config = ActiveRecord::DatabaseConfigurations::HashConfig.new(env_name, name, config)
|
78
|
+
ActiveRecord::ConnectionAdapters::PoolConfig.new(owner_name = ActiveRecord::Base, db_config)
|
87
79
|
else
|
88
|
-
|
80
|
+
adapter_method = "#{config[:adapter]}_connection"
|
81
|
+
if defined?(ActiveRecord::ConnectionAdapters::ConnectionSpecification)
|
82
|
+
spec_class = ActiveRecord::ConnectionAdapters::ConnectionSpecification
|
83
|
+
|
84
|
+
if spec_class.instance_method(:initialize).arity == 3
|
85
|
+
spec_class.new(name, config, adapter_method)
|
86
|
+
else
|
87
|
+
spec_class.new(config, adapter_method)
|
88
|
+
end
|
89
|
+
else
|
90
|
+
ActiveRecord::Base::ConnectionSpecification.new(config, adapter_method)
|
91
|
+
end
|
89
92
|
end
|
90
93
|
|
91
94
|
ActiveRecord::ConnectionAdapters::ConnectionPool.new(spec)
|
data/lib/octoshark/version.rb
CHANGED
data/octoshark.gemspec
CHANGED
@@ -20,10 +20,9 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_runtime_dependency "activerecord", ">= 3.0"
|
22
22
|
|
23
|
-
spec.add_development_dependency "bundler", "~> 1.5"
|
24
23
|
spec.add_development_dependency "rake"
|
25
|
-
spec.add_development_dependency "rspec", "~> 3.
|
26
|
-
spec.add_development_dependency "sqlite3", "~> 1.
|
27
|
-
spec.add_development_dependency "mysql2", "~> 0.
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.7.0"
|
25
|
+
spec.add_development_dependency "sqlite3", "~> 1.4.1"
|
26
|
+
spec.add_development_dependency "mysql2", "~> 0.5.2"
|
28
27
|
spec.add_development_dependency "appraisal"
|
29
28
|
end
|
@@ -67,7 +67,7 @@ describe Octoshark::ConnectionPoolsManager do
|
|
67
67
|
it "returns value from execution" do
|
68
68
|
manager = Octoshark::ConnectionPoolsManager.new(configs)
|
69
69
|
result = manager.with_connection(:db1) { |connection| connection.execute("SELECT 1") }
|
70
|
-
expect(result).to eq(
|
70
|
+
expect(result.first['1']).to eq(1)
|
71
71
|
end
|
72
72
|
|
73
73
|
it "raises Octoshark::Error::NoConnection" do
|
@@ -4,9 +4,9 @@ db1:
|
|
4
4
|
reconnect: false
|
5
5
|
database: octoshark_db1
|
6
6
|
pool: 5
|
7
|
-
username:
|
8
|
-
password:
|
9
|
-
host:
|
7
|
+
username: root
|
8
|
+
password: pass
|
9
|
+
host: 127.0.0.1
|
10
10
|
port: 3306
|
11
11
|
|
12
12
|
db2:
|
@@ -15,7 +15,7 @@ db2:
|
|
15
15
|
reconnect: false
|
16
16
|
database: octoshark_db2
|
17
17
|
pool: 5
|
18
|
-
username:
|
19
|
-
password:
|
20
|
-
host:
|
18
|
+
username: root
|
19
|
+
password: pass
|
20
|
+
host: 127.0.0.1
|
21
21
|
port: 3306
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octoshark
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dalibor Nasevic
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: bundler
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.5'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '1.5'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: rake
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,42 +44,42 @@ dependencies:
|
|
58
44
|
requirements:
|
59
45
|
- - "~>"
|
60
46
|
- !ruby/object:Gem::Version
|
61
|
-
version: 3.
|
47
|
+
version: 3.7.0
|
62
48
|
type: :development
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
52
|
- - "~>"
|
67
53
|
- !ruby/object:Gem::Version
|
68
|
-
version: 3.
|
54
|
+
version: 3.7.0
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: sqlite3
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
59
|
- - "~>"
|
74
60
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.
|
61
|
+
version: 1.4.1
|
76
62
|
type: :development
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
66
|
- - "~>"
|
81
67
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.
|
68
|
+
version: 1.4.1
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: mysql2
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
73
|
- - "~>"
|
88
74
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
75
|
+
version: 0.5.2
|
90
76
|
type: :development
|
91
77
|
prerelease: false
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
93
79
|
requirements:
|
94
80
|
- - "~>"
|
95
81
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
82
|
+
version: 0.5.2
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
84
|
name: appraisal
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -115,10 +101,11 @@ executables: []
|
|
115
101
|
extensions: []
|
116
102
|
extra_rdoc_files: []
|
117
103
|
files:
|
104
|
+
- ".github/workflows/ci-legacy.yml"
|
105
|
+
- ".github/workflows/ci.yml"
|
118
106
|
- ".gitignore"
|
119
107
|
- ".rspec"
|
120
108
|
- ".ruby-version"
|
121
|
-
- ".travis.yml"
|
122
109
|
- Appraisals
|
123
110
|
- CHANGELOG.md
|
124
111
|
- Gemfile
|
@@ -132,6 +119,10 @@ files:
|
|
132
119
|
- gemfiles/rails4.1.gemfile
|
133
120
|
- gemfiles/rails4.2.gemfile
|
134
121
|
- gemfiles/rails5.0.gemfile
|
122
|
+
- gemfiles/rails5.1.gemfile
|
123
|
+
- gemfiles/rails5.2.gemfile
|
124
|
+
- gemfiles/rails6.0.gemfile
|
125
|
+
- gemfiles/rails6.1.gemfile
|
135
126
|
- lib/octoshark.rb
|
136
127
|
- lib/octoshark/active_record_extensions.rb
|
137
128
|
- lib/octoshark/connection_manager.rb
|
@@ -145,14 +136,14 @@ files:
|
|
145
136
|
- spec/octoshark/connection_pools_manager_spec.rb
|
146
137
|
- spec/octoshark/current_connection_spec.rb
|
147
138
|
- spec/spec_helper.rb
|
139
|
+
- spec/support/config.yml.github
|
148
140
|
- spec/support/config.yml.template
|
149
|
-
- spec/support/config.yml.travis
|
150
141
|
- spec/support/helpers.rb
|
151
142
|
homepage: https://github.com/dalibor/octoshark
|
152
143
|
licenses:
|
153
144
|
- MIT
|
154
145
|
metadata: {}
|
155
|
-
post_install_message:
|
146
|
+
post_install_message:
|
156
147
|
rdoc_options: []
|
157
148
|
require_paths:
|
158
149
|
- lib
|
@@ -167,9 +158,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
158
|
- !ruby/object:Gem::Version
|
168
159
|
version: '0'
|
169
160
|
requirements: []
|
170
|
-
|
171
|
-
|
172
|
-
signing_key:
|
161
|
+
rubygems_version: 3.1.6
|
162
|
+
signing_key:
|
173
163
|
specification_version: 4
|
174
164
|
summary: Octoshark is an ActiveRecord connection switcher
|
175
165
|
test_files:
|
@@ -178,6 +168,6 @@ test_files:
|
|
178
168
|
- spec/octoshark/connection_pools_manager_spec.rb
|
179
169
|
- spec/octoshark/current_connection_spec.rb
|
180
170
|
- spec/spec_helper.rb
|
171
|
+
- spec/support/config.yml.github
|
181
172
|
- spec/support/config.yml.template
|
182
|
-
- spec/support/config.yml.travis
|
183
173
|
- spec/support/helpers.rb
|
data/.travis.yml
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
rvm:
|
2
|
-
- 2.2.2
|
3
|
-
cache:
|
4
|
-
- bundler
|
5
|
-
notifications:
|
6
|
-
email:
|
7
|
-
- dalibor.nasevic@gmail.com
|
8
|
-
gemfile:
|
9
|
-
- gemfiles/rails3.0.gemfile
|
10
|
-
- gemfiles/rails3.1.gemfile
|
11
|
-
- gemfiles/rails3.2.gemfile
|
12
|
-
- gemfiles/rails4.0.gemfile
|
13
|
-
- gemfiles/rails4.1.gemfile
|
14
|
-
- gemfiles/rails4.2.gemfile
|
15
|
-
- gemfiles/rails5.0.gemfile
|
16
|
-
before_script:
|
17
|
-
- cp spec/support/config.yml.travis spec/support/config.yml
|
18
|
-
- bundle exec rake db:create
|
19
|
-
script:
|
20
|
-
- bundle exec rspec spec
|