knockoff 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +5 -4
- data/.gitignore +1 -2
- data/.ruby-version +1 -1
- data/CHANGELOG.md +9 -1
- data/Gemfile.lock +65 -0
- data/README.md +33 -11
- data/knockoff.gemspec +6 -5
- data/lib/knockoff/base.rb +1 -1
- data/lib/knockoff/config.rb +62 -73
- data/lib/knockoff/replica_connection_pool.rb +3 -3
- data/lib/knockoff/version.rb +1 -1
- metadata +22 -22
- data/ci/install_modern_sqlite.sh +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e921df87f0b4a745efbf78fc20ef215d3460979feb98caed591cee11a34ee2f0
|
4
|
+
data.tar.gz: a9766e158829c30fd0de4a488818b5e5f1bcfa5e0586f8800292ebfb258f9a9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33af6faf673b2eb80408f93fac592b05202e304e644d33a14237a49aab213b5f45d6fceb82961965de6993213aeac415184adde22baf1701a5bc21fc06859d61
|
7
|
+
data.tar.gz: 78122861367012310acae82efc930c59b9da403b4bc0cbaf15af629e85eed621247bb073507e9da307ad9822799971c0308accdcf2ac7755d60f806ebeff437c
|
data/.github/workflows/ruby.yml
CHANGED
@@ -5,20 +5,21 @@ on: push
|
|
5
5
|
jobs:
|
6
6
|
test:
|
7
7
|
|
8
|
-
runs-on: ubuntu-
|
8
|
+
runs-on: ubuntu-latest
|
9
9
|
|
10
10
|
strategy:
|
11
11
|
matrix:
|
12
|
-
ruby-version: ['2.
|
12
|
+
ruby-version: ['2.7.8', '3.0.6', '3.1.4']
|
13
13
|
|
14
14
|
steps:
|
15
15
|
# Pin to this commit: v2
|
16
16
|
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
17
17
|
- name: Set up Ruby
|
18
|
-
|
19
|
-
uses: ruby/setup-ruby@5e4f0a10bfc39c97cd5358121291e27e5d97e09b
|
18
|
+
uses: ruby/setup-ruby@v1
|
20
19
|
with:
|
21
20
|
ruby-version: ${{ matrix.ruby-version }}
|
22
21
|
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
22
|
+
cache-version: 2
|
23
|
+
|
23
24
|
- name: Run tests
|
24
25
|
run: bundle exec rake spec
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.1.4
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
## Unreleased
|
2
2
|
|
3
|
+
## 1.5.0
|
4
|
+
|
5
|
+
Update to be Rails 7.0 compatible. Drops support for ruby 2.6 and Rails 6.0-
|
6
|
+
|
7
|
+
## 1.4.0
|
8
|
+
|
9
|
+
Update to be Rails 6.1 compatible
|
10
|
+
|
3
11
|
## 1.1.1
|
4
12
|
|
5
13
|
- Drop Ruby 2.3 support
|
@@ -11,4 +19,4 @@
|
|
11
19
|
- Allow for not checking `inside_transaction?` on primary database (https://github.com/joinhandshake/knockoff/pull/13)
|
12
20
|
- Allow setting `Knockoff.default_target` to set the default target other than `:primary` (https://github.com/joinhandshake/knockoff/pull/11)
|
13
21
|
- Drop Ruby 2.2 support
|
14
|
-
- Add Ruby 2.5 support
|
22
|
+
- Add Ruby 2.5 support
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
knockoff (1.5.0)
|
5
|
+
activerecord (>= 6.1, < 7.1)
|
6
|
+
activesupport (>= 6.1, < 7.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activemodel (7.0.8.4)
|
12
|
+
activesupport (= 7.0.8.4)
|
13
|
+
activerecord (7.0.8.4)
|
14
|
+
activemodel (= 7.0.8.4)
|
15
|
+
activesupport (= 7.0.8.4)
|
16
|
+
activesupport (7.0.8.4)
|
17
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
|
+
i18n (>= 1.6, < 2)
|
19
|
+
minitest (>= 5.1)
|
20
|
+
tzinfo (~> 2.0)
|
21
|
+
concurrent-ruby (1.3.4)
|
22
|
+
diff-lcs (1.5.1)
|
23
|
+
i18n (1.14.5)
|
24
|
+
concurrent-ruby (~> 1.0)
|
25
|
+
minitest (5.24.1)
|
26
|
+
rake (10.5.0)
|
27
|
+
rspec (3.13.0)
|
28
|
+
rspec-core (~> 3.13.0)
|
29
|
+
rspec-expectations (~> 3.13.0)
|
30
|
+
rspec-mocks (~> 3.13.0)
|
31
|
+
rspec-core (3.13.0)
|
32
|
+
rspec-support (~> 3.13.0)
|
33
|
+
rspec-expectations (3.13.1)
|
34
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
+
rspec-support (~> 3.13.0)
|
36
|
+
rspec-mocks (3.13.1)
|
37
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
+
rspec-support (~> 3.13.0)
|
39
|
+
rspec-support (3.13.1)
|
40
|
+
sqlite3 (1.5.4-aarch64-linux)
|
41
|
+
sqlite3 (1.5.4-arm-linux)
|
42
|
+
sqlite3 (1.5.4-arm64-darwin)
|
43
|
+
sqlite3 (1.5.4-x86-linux)
|
44
|
+
sqlite3 (1.5.4-x86_64-darwin)
|
45
|
+
sqlite3 (1.5.4-x86_64-linux)
|
46
|
+
tzinfo (2.0.6)
|
47
|
+
concurrent-ruby (~> 1.0)
|
48
|
+
|
49
|
+
PLATFORMS
|
50
|
+
aarch64-linux
|
51
|
+
arm-linux
|
52
|
+
arm64-darwin
|
53
|
+
x86-linux
|
54
|
+
x86_64-darwin
|
55
|
+
x86_64-linux
|
56
|
+
|
57
|
+
DEPENDENCIES
|
58
|
+
bundler
|
59
|
+
knockoff!
|
60
|
+
rake (~> 10.0)
|
61
|
+
rspec
|
62
|
+
sqlite3 (~> 1.5.0)
|
63
|
+
|
64
|
+
BUNDLED WITH
|
65
|
+
2.4.22
|
data/README.md
CHANGED
@@ -17,7 +17,29 @@ A gem for easily using read replicas.
|
|
17
17
|
|
18
18
|
## Supported Versions
|
19
19
|
|
20
|
-
Knockoff
|
20
|
+
| Knockoff version: | 1.0 | 1.1.0 | 1.1.1 | 1.4 | 1.5 |
|
21
|
+
| --- | --- | --- | --- | --- | --- |
|
22
|
+
| Ruby 2.2 | [x] | [ ] | [ ] | [ ] | [ ] |
|
23
|
+
| Ruby 2.3 | [x] | [x] | [ ] | [ ] | [ ] |
|
24
|
+
| Ruby 2.4 | [x] | [x] | [x] | [ ] | [ ] |
|
25
|
+
| Ruby 2.5 | [ ] | [x] | [x] | [ ] | [ ] |
|
26
|
+
| Ruby 2.6 | [ ] | [ ] | [x] | [x] | [ ] |
|
27
|
+
| Ruby 2.7 | [ ] | [ ] | [x] | [x] | [x] |
|
28
|
+
| Ruby 3.0 | [ ] | [ ] | [ ] | [x] | [x] |
|
29
|
+
| Ruby 3.1 | [ ] | [ ] | [ ] | [x] | [x] |
|
30
|
+
|
31
|
+
| Knockoff version: | 1.0 | 1.1.0 | 1.1.1 | 1.4 | 1.5 |
|
32
|
+
| --- | --- | --- | --- | --- | --- |
|
33
|
+
| Rails 4 | [x] | [x] | [ ] | [ ] | [ ] |
|
34
|
+
| Rails 5.0 | [x] | [x] | [x] | [ ] | [ ] |
|
35
|
+
| Rails 5.1 | [x] | [x] | [x] | [ ] | [ ] |
|
36
|
+
| Rails 5.2 | [x] | [x] | [x] | [ ] | [ ] |
|
37
|
+
| Rails 6.0 | [ ] | [ ] | [x] | [x] | [ ] |
|
38
|
+
| Rails 6.1 | [ ] | [ ] | [ ] | [x] | [x] |
|
39
|
+
| Rails 7.0 | [ ] | [ ] | [ ] | [ ] | [x] |
|
40
|
+
| Rails 7.1 | [ ] | [ ] | [ ] | [ ] | [ ] |
|
41
|
+
| Rails 7.2 | [ ] | [ ] | [ ] | [ ] | [ ] |
|
42
|
+
|
21
43
|
|
22
44
|
## Installation
|
23
45
|
|
@@ -41,7 +63,7 @@ Or install it yourself as:
|
|
41
63
|
|
42
64
|
Add an initializer at config/knockoff.rb with the below contents
|
43
65
|
|
44
|
-
```
|
66
|
+
```ruby
|
45
67
|
Knockoff.enabled = true # NOTE: Consider adding ENV based disabling
|
46
68
|
```
|
47
69
|
|
@@ -49,7 +71,7 @@ Knockoff.enabled = true # NOTE: Consider adding ENV based disabling
|
|
49
71
|
|
50
72
|
Configuration is done using ENV properties. This makes it easy to add and remove replicas at runtime (or to fully disable if needed). First, set up ENV variables pointing to your replica databases. Consider using the [dotenv](https://github.com/bkeepers/dotenv) gem for manging ENV variables.
|
51
73
|
|
52
|
-
```
|
74
|
+
```dotenv
|
53
75
|
# .env
|
54
76
|
|
55
77
|
REPLICA_1=postgres://username:password@localhost:5432/database_name
|
@@ -71,7 +93,7 @@ KNOCKOFF_REPLICA_ENVS=REPLICA_1,REPLICA_2
|
|
71
93
|
|
72
94
|
Lastly, knockoff will read the `'knockoff_replicas'` database.yml config for specifying additional params:
|
73
95
|
|
74
|
-
```
|
96
|
+
```yml
|
75
97
|
# database.yml
|
76
98
|
|
77
99
|
knockoff_replicas:
|
@@ -83,13 +105,13 @@ knockoff_replicas:
|
|
83
105
|
|
84
106
|
To use one of the replica databases, use
|
85
107
|
|
86
|
-
```
|
108
|
+
```ruby
|
87
109
|
Knockoff.on_replica { User.count }
|
88
110
|
```
|
89
111
|
|
90
112
|
To force primary, use
|
91
113
|
|
92
|
-
```
|
114
|
+
```ruby
|
93
115
|
Knockoff.on_primary { User.create(name: 'Bob') }
|
94
116
|
```
|
95
117
|
|
@@ -97,7 +119,7 @@ Knockoff.on_primary { User.create(name: 'Bob') }
|
|
97
119
|
|
98
120
|
A common use case is to use replicas for GET requests and otherwise use primary. A simplified use case might look something like this:
|
99
121
|
|
100
|
-
```
|
122
|
+
```ruby
|
101
123
|
# application_controller.rb
|
102
124
|
|
103
125
|
around_action :choose_database
|
@@ -120,7 +142,7 @@ end
|
|
120
142
|
|
121
143
|
Replicas will often be slightly behind the primary database. To compensate, consider "sticking" a user who has recently made changes to the primary for a small duration of time to the primary database. This will avoid cases where a user creates a record on primary, is redirected to view that record, and receives a 404 error since the record is not yet in the replica. A simple implementation for this could look like:
|
122
144
|
|
123
|
-
```
|
145
|
+
```ruby
|
124
146
|
# application_record.rb
|
125
147
|
|
126
148
|
after_commit :track_commit_occurred_in_request
|
@@ -149,13 +171,13 @@ Then, in your `should_use_primary_database?` method, consult `session[:use_leade
|
|
149
171
|
|
150
172
|
Knockoff can be configured during runtime. This is done through the `establish_new_connections!` method which takes in a hash of new configurations to apply to each replica before re-connecting.
|
151
173
|
|
152
|
-
```
|
174
|
+
```ruby
|
153
175
|
Knockoff.establish_new_connections!({ 'pool' => db_pool })
|
154
176
|
```
|
155
177
|
|
156
178
|
For example, to specify a puma connection pool at bootup your code might look something like
|
157
179
|
|
158
|
-
```
|
180
|
+
```ruby
|
159
181
|
# puma.rb
|
160
182
|
|
161
183
|
db_pool = Integer(ENV['PUMA_WORKER_DB_POOL'] || threads_count)
|
@@ -171,7 +193,7 @@ Knockoff.establish_new_connections!({ 'pool' => db_pool })
|
|
171
193
|
|
172
194
|
For forking servers, you may disconnect all replicas before forking with `Knockoff.disconnect_all!`.
|
173
195
|
|
174
|
-
```
|
196
|
+
```ruby
|
175
197
|
# puma.rb
|
176
198
|
|
177
199
|
before_fork do
|
data/knockoff.gemspec
CHANGED
@@ -13,16 +13,17 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = "https://github.com/sgringwe/knockoff"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
|
+
spec.required_ruby_version = '>= 2.7.0'
|
17
|
+
spec.platform = Gem::Platform::RUBY
|
16
18
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
-
spec.bindir = "
|
18
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.bindir = "bin"
|
19
20
|
spec.require_paths = ["lib"]
|
20
21
|
|
21
|
-
spec.add_runtime_dependency 'activerecord', '>=
|
22
|
-
spec.add_runtime_dependency 'activesupport', '>=
|
22
|
+
spec.add_runtime_dependency 'activerecord', '>= 6.1', "< 7.1"
|
23
|
+
spec.add_runtime_dependency 'activesupport', '>= 6.1', "< 7.1"
|
23
24
|
|
24
25
|
spec.add_development_dependency "bundler"
|
25
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
27
|
spec.add_development_dependency "rspec"
|
27
|
-
spec.add_development_dependency 'sqlite3'
|
28
|
+
spec.add_development_dependency 'sqlite3', "~> 1.5.0"
|
28
29
|
end
|
data/lib/knockoff/base.rb
CHANGED
@@ -28,7 +28,7 @@ module Knockoff
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def inside_transaction?
|
31
|
-
open_transactions = run_on(:primary) { ActiveRecord::Base.connection.open_transactions }
|
31
|
+
open_transactions = run_on(:primary) { ::ActiveRecord::Base.connection.open_transactions }
|
32
32
|
open_transactions > Knockoff.base_transaction_depth
|
33
33
|
end
|
34
34
|
|
data/lib/knockoff/config.rb
CHANGED
@@ -8,11 +8,11 @@ module Knockoff
|
|
8
8
|
attr_reader :replica_configs
|
9
9
|
|
10
10
|
# A hash of replica configs to their config hash.
|
11
|
-
attr_reader :
|
11
|
+
attr_reader :replicas_configuration_hash
|
12
12
|
|
13
13
|
def initialize
|
14
14
|
@environment = 'development'
|
15
|
-
@
|
15
|
+
@replicas_configuration_hash = {}
|
16
16
|
set_replica_configs
|
17
17
|
|
18
18
|
if !properly_configured? && Knockoff.enabled
|
@@ -21,8 +21,28 @@ module Knockoff
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
25
|
-
@
|
24
|
+
def set_replica_configs
|
25
|
+
@replica_configs ||= parse_knockoff_replica_envs_to_configs
|
26
|
+
end
|
27
|
+
|
28
|
+
def parse_knockoff_replica_envs_to_configs
|
29
|
+
# As a basic prevention of crashes, attempt to parse each DB uri
|
30
|
+
# and don't add the uri to the final list if it can't be parsed
|
31
|
+
replica_env_keys.map.with_index(0) do |env_key, index|
|
32
|
+
begin
|
33
|
+
|
34
|
+
# Configure parameters such as prepared_statements, pool, reaping_frequency for all replicas.
|
35
|
+
to_copy = ActiveRecord::Base.configurations.configs_for(env_name: 'knockoff_replicas')&.first&.configuration_hash || {}
|
36
|
+
register_replica_copy(index, env_key, to_copy)
|
37
|
+
|
38
|
+
rescue URI::InvalidURIError
|
39
|
+
Rails.logger.info "LOG NOTIFIER: Invalid URL specified in follower_env_keys. Not including URI, which may result in no followers used." # URI is purposely not printed to logs
|
40
|
+
# Return a 'nil' which will be removed from
|
41
|
+
# configs with `compact`, resulting in no configs and no followers,
|
42
|
+
# therefore disabled since this env will not be in environments list.
|
43
|
+
nil
|
44
|
+
end
|
45
|
+
end.compact
|
26
46
|
end
|
27
47
|
|
28
48
|
def replica_env_keys
|
@@ -34,9 +54,12 @@ module Knockoff
|
|
34
54
|
end
|
35
55
|
|
36
56
|
def update_replica_configs(new_configs)
|
37
|
-
ActiveRecord::Base.configurations
|
38
|
-
|
39
|
-
|
57
|
+
if ActiveRecord::Base.configurations.configs_for(env_name: 'knockoff_replicas').present?
|
58
|
+
updated_config = new_configs.deep_dup.merge!(ActiveRecord::Base.configurations.configs_for(env_name: 'knockoff_replicas').first.configuration_hash)
|
59
|
+
end
|
60
|
+
|
61
|
+
@replicas_configuration_hash.each do |key, _config|
|
62
|
+
update_replica_config(key, updated_config)
|
40
63
|
end
|
41
64
|
end
|
42
65
|
|
@@ -47,80 +70,46 @@ module Knockoff
|
|
47
70
|
!@replica_configs.empty?
|
48
71
|
end
|
49
72
|
|
73
|
+
def replica_database_keys
|
74
|
+
@replicas_configuration_hash.keys
|
75
|
+
end
|
76
|
+
|
50
77
|
private
|
51
78
|
|
52
|
-
def update_replica_config(key,
|
53
|
-
@
|
54
|
-
|
79
|
+
def update_replica_config(key, updated_config)
|
80
|
+
merged_config = @replicas_configuration_hash[key].configuration_hash.deep_dup.merge!(updated_config)
|
81
|
+
@replicas_configuration_hash[key] = ActiveRecord::DatabaseConfigurations::HashConfig.new(key, key, merged_config)
|
82
|
+
ActiveRecord::Base.configurations.configurations << @replicas_configuration_hash[key]
|
55
83
|
end
|
56
84
|
|
57
|
-
def
|
58
|
-
|
85
|
+
def register_replica_copy(index, env_key, configuration_hash)
|
86
|
+
key = "knockoff_replica_#{index}"
|
87
|
+
new_config = create_replica_copy(env_key, key, configuration_hash.deep_dup)
|
88
|
+
ActiveRecord::Base.configurations.configurations << new_config
|
89
|
+
@replicas_configuration_hash[key] = new_config
|
59
90
|
end
|
60
91
|
|
61
|
-
def
|
62
|
-
|
63
|
-
# and don't add the uri to the final list if it can't be parsed
|
64
|
-
replica_env_keys.map.with_index(0) do |env_key, index|
|
65
|
-
begin
|
66
|
-
uri = URI.parse(ENV[env_key])
|
92
|
+
def create_replica_copy(env_key, key, replica_config_hash)
|
93
|
+
uri = URI.parse(ENV[env_key])
|
67
94
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
'postgresql'
|
74
|
-
else
|
75
|
-
uri.scheme
|
76
|
-
end
|
77
|
-
|
78
|
-
# Base config from the ENV uri. Sqlite is a special case
|
79
|
-
# and all others follow 'normal' config
|
80
|
-
uri_config =
|
81
|
-
if uri.scheme == 'sqlite3'
|
82
|
-
{
|
83
|
-
'adapter' => adapter,
|
84
|
-
'database' => uri.to_s.split(':')[1]
|
85
|
-
}
|
86
|
-
else
|
87
|
-
{
|
88
|
-
'adapter' => adapter,
|
89
|
-
'database' => (uri.path || "").split("/")[1],
|
90
|
-
'username' => uri.user,
|
91
|
-
'password' => uri.password,
|
92
|
-
'host' => uri.host,
|
93
|
-
'port' => uri.port
|
94
|
-
}
|
95
|
-
end
|
96
|
-
|
97
|
-
# Store the hash in configuration and use it when we establish the connection later.
|
98
|
-
# TODO: In ActiveRecord >= 6, this is a deprecated way to set a configuration. However
|
99
|
-
# there appears to be an issue when calling `ActiveRecord::Base.configurations.to_h` in
|
100
|
-
# version 6.0.4.8 where
|
101
|
-
# multi-database setup is being ignored / dropped. For example if a database.yml setup
|
102
|
-
# has something like..
|
103
|
-
#
|
104
|
-
# development:
|
105
|
-
# primary:
|
106
|
-
# ...
|
107
|
-
# other:
|
108
|
-
# ...
|
109
|
-
#
|
110
|
-
# then the 'other' database configuration is being dropped.
|
111
|
-
key = "knockoff_replica_#{index}"
|
112
|
-
config = replica_config.merge(uri_config)
|
113
|
-
ActiveRecord::Base.configurations[key] = config
|
114
|
-
|
115
|
-
@replicas_configurations[key] = config
|
116
|
-
rescue URI::InvalidURIError
|
117
|
-
Rails.logger.info "LOG NOTIFIER: Invalid URL specified in follower_env_keys. Not including URI, which may result in no followers used." # URI is purposely not printed to logs
|
118
|
-
# Return a 'nil' which will be removed from
|
119
|
-
# configs with `compact`, resulting in no configs and no followers,
|
120
|
-
# therefore disabled since this env will not be in environments list.
|
121
|
-
nil
|
95
|
+
replica_config_hash[:adapter] =
|
96
|
+
if uri.scheme == "postgres"
|
97
|
+
'postgresql'
|
98
|
+
else
|
99
|
+
uri.scheme
|
122
100
|
end
|
123
|
-
|
101
|
+
|
102
|
+
if uri.scheme == 'sqlite3'
|
103
|
+
replica_config_hash[:database] = uri.to_s.split(':')[1]
|
104
|
+
else
|
105
|
+
replica_config_hash[:database] = (uri.path || "").split("/")[1]
|
106
|
+
replica_config_hash[:username] = uri.user
|
107
|
+
replica_config_hash[:password] = uri.password
|
108
|
+
replica_config_hash[:host] = uri.host
|
109
|
+
replica_config_hash[:port] = uri.port
|
110
|
+
end
|
111
|
+
|
112
|
+
ActiveRecord::DatabaseConfigurations::HashConfig.new(key, key, replica_config_hash)
|
124
113
|
end
|
125
114
|
end
|
126
115
|
end
|
@@ -49,11 +49,11 @@ module Knockoff
|
|
49
49
|
# TODO: Hardcoding the uri string feels meh. Either set the database config
|
50
50
|
# or reference ENV instead
|
51
51
|
Knockoff.module_eval %Q{
|
52
|
-
class #{class_name} < ActiveRecord::Base
|
52
|
+
class #{class_name} < ::ActiveRecord::Base
|
53
53
|
self.abstract_class = true
|
54
54
|
establish_connection :#{config_key}
|
55
|
-
def self.
|
56
|
-
configurations
|
55
|
+
def self.connection_db_config
|
56
|
+
configurations.find_db_config #{config_key.to_s.inspect}
|
57
57
|
end
|
58
58
|
end
|
59
59
|
}, __FILE__, __LINE__
|
data/lib/knockoff/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knockoff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Ringwelski
|
8
|
-
autorequire:
|
9
|
-
bindir:
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,40 +16,40 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '6.1'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '7.1'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: '6.1'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '7.1'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: activesupport
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
39
|
+
version: '6.1'
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
42
|
+
version: '7.1'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
49
|
+
version: '6.1'
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '
|
52
|
+
version: '7.1'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: bundler
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -96,17 +96,17 @@ dependencies:
|
|
96
96
|
name: sqlite3
|
97
97
|
requirement: !ruby/object:Gem::Requirement
|
98
98
|
requirements:
|
99
|
-
- - "
|
99
|
+
- - "~>"
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version:
|
101
|
+
version: 1.5.0
|
102
102
|
type: :development
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
105
|
requirements:
|
106
|
-
- - "
|
106
|
+
- - "~>"
|
107
107
|
- !ruby/object:Gem::Version
|
108
|
-
version:
|
109
|
-
description:
|
108
|
+
version: 1.5.0
|
109
|
+
description:
|
110
110
|
email:
|
111
111
|
- me@sgringwe.com
|
112
112
|
executables: []
|
@@ -119,12 +119,12 @@ files:
|
|
119
119
|
- ".ruby-version"
|
120
120
|
- CHANGELOG.md
|
121
121
|
- Gemfile
|
122
|
+
- Gemfile.lock
|
122
123
|
- LICENSE.txt
|
123
124
|
- README.md
|
124
125
|
- Rakefile
|
125
126
|
- bin/console
|
126
127
|
- bin/setup
|
127
|
-
- ci/install_modern_sqlite.sh
|
128
128
|
- knockoff.gemspec
|
129
129
|
- lib/knockoff.rb
|
130
130
|
- lib/knockoff/active_record/base.rb
|
@@ -138,7 +138,7 @@ homepage: https://github.com/sgringwe/knockoff
|
|
138
138
|
licenses:
|
139
139
|
- MIT
|
140
140
|
metadata: {}
|
141
|
-
post_install_message:
|
141
|
+
post_install_message:
|
142
142
|
rdoc_options: []
|
143
143
|
require_paths:
|
144
144
|
- lib
|
@@ -146,15 +146,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
146
146
|
requirements:
|
147
147
|
- - ">="
|
148
148
|
- !ruby/object:Gem::Version
|
149
|
-
version:
|
149
|
+
version: 2.7.0
|
150
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
151
|
requirements:
|
152
152
|
- - ">="
|
153
153
|
- !ruby/object:Gem::Version
|
154
154
|
version: '0'
|
155
155
|
requirements: []
|
156
|
-
rubygems_version: 3.
|
157
|
-
signing_key:
|
156
|
+
rubygems_version: 3.5.7
|
157
|
+
signing_key:
|
158
158
|
specification_version: 4
|
159
159
|
summary: A gem for easily using read replicas
|
160
160
|
test_files: []
|
data/ci/install_modern_sqlite.sh
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
set -e # halt script on error
|
3
|
-
|
4
|
-
sudo apt-get autoremove sqlite3
|
5
|
-
sudo apt-get install python-software-properties
|
6
|
-
sudo apt-add-repository -y ppa:travis-ci/sqlite3
|
7
|
-
sudo apt-get -y update
|
8
|
-
sudo apt-cache show sqlite3
|
9
|
-
sudo apt-get install sqlite3=3.7.15.1-1~travis1
|
10
|
-
sudo sqlite3 -version
|
11
|
-
sudo psql --version
|
12
|
-
sudo mysql --version
|
13
|
-
gem update bundler
|