knockoff 1.1.0.alpha → 1.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/ruby.yml +24 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +8 -0
- data/README.md +3 -3
- data/knockoff.gemspec +2 -2
- data/lib/knockoff/active_record/relation.rb +3 -3
- data/lib/knockoff/config.rb +16 -3
- data/lib/knockoff/replica_connection_pool.rb +6 -0
- data/lib/knockoff/version.rb +1 -1
- data/lib/knockoff.rb +4 -0
- metadata +19 -7
- data/.travis.yml +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 22fb5337ef43e286ab938ab8d6e4905529607979266b8bb7673eccdba23c5d3c
|
4
|
+
data.tar.gz: 9990634bf328df85fe419cbb3aea20b591d4a9c94420184f89012a15649ac2af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7e7d9f11f4a7ea199d48e98c322d66b75db01eb2659b5218ea3928c586e1cab1d4087e3c7eb2aa1c54bdce744beb4f5c46fd2e4b43dc3972c1d735c6762acbf
|
7
|
+
data.tar.gz: 4a6d620cffa48322560e060e1b500704791216d9daf6a3f6f81e90adaec25546012dbf0a55ca66c427265b87f42d3f0a1818f2aa93fbb84292a89ff7cd816bd2
|
@@ -0,0 +1,24 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on: push
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
|
8
|
+
runs-on: ubuntu-20.04
|
9
|
+
|
10
|
+
strategy:
|
11
|
+
matrix:
|
12
|
+
ruby-version: ['2.4.0', '2.5.1', '2.6.6', '2.7.2']
|
13
|
+
|
14
|
+
steps:
|
15
|
+
# Pin to this commit: v2
|
16
|
+
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
17
|
+
- name: Set up Ruby
|
18
|
+
# Lock to this commit, v1.82.0
|
19
|
+
uses: ruby/setup-ruby@5e4f0a10bfc39c97cd5358121291e27e5d97e09b
|
20
|
+
with:
|
21
|
+
ruby-version: ${{ matrix.ruby-version }}
|
22
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
23
|
+
- name: Run tests
|
24
|
+
run: bundle exec rake spec
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.2
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
## Unreleased
|
2
2
|
|
3
|
+
## 1.1.1
|
4
|
+
|
5
|
+
- Drop Ruby 2.3 support
|
6
|
+
- Add Ruby 2.6 and 2.7 support
|
7
|
+
- Fix a deprecation warning in Rails 6
|
8
|
+
|
9
|
+
## 1.1.0
|
10
|
+
|
3
11
|
- Allow for not checking `inside_transaction?` on primary database (https://github.com/joinhandshake/knockoff/pull/13)
|
4
12
|
- Allow setting `Knockoff.default_target` to set the default target other than `:primary` (https://github.com/joinhandshake/knockoff/pull/11)
|
5
13
|
- Drop Ruby 2.2 support
|
data/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# Knockoff
|
2
2
|
|
3
|
-
[![Build Status](https://
|
3
|
+
[![Build Status](https://github.com/joinhandshake/knockoff/actions/workflows/ruby.yml/badge.svg)](https://github.com/joinhandshake/knockoff/actions)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/knockoff.svg)](https://badge.fury.io/rb/knockoff)
|
5
5
|
|
6
6
|
A gem for easily using read replicas.
|
7
7
|
|
8
|
-
:handshake: Battle tested at [Handshake](https://joinhandshake.com/
|
8
|
+
:handshake: Battle tested at [Handshake](https://joinhandshake.com/)
|
9
9
|
|
10
10
|
## Library Goals
|
11
11
|
|
@@ -17,7 +17,7 @@ A gem for easily using read replicas.
|
|
17
17
|
|
18
18
|
## Supported Versions
|
19
19
|
|
20
|
-
Knockoff supports Rails 4 and
|
20
|
+
Knockoff supports Rails 4, 5 and 6
|
21
21
|
|
22
22
|
## Installation
|
23
23
|
|
data/knockoff.gemspec
CHANGED
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_runtime_dependency 'activerecord', '>= 4.0.0'
|
22
|
-
spec.add_runtime_dependency 'activesupport', '>= 4.0.0'
|
21
|
+
spec.add_runtime_dependency 'activerecord', '>= 4.0.0', '< 6.1'
|
22
|
+
spec.add_runtime_dependency 'activesupport', '>= 4.0.0', '< 6.1'
|
23
23
|
|
24
24
|
spec.add_development_dependency "bundler"
|
25
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
@@ -5,11 +5,11 @@ module ActiveRecord
|
|
5
5
|
# Supports queries like User.on_replica.to_a
|
6
6
|
alias_method :exec_queries_without_knockoff, :exec_queries
|
7
7
|
|
8
|
-
def exec_queries
|
8
|
+
def exec_queries(&block)
|
9
9
|
if knockoff_target == :replica
|
10
|
-
Knockoff.on_replica { exec_queries_without_knockoff }
|
10
|
+
Knockoff.on_replica { exec_queries_without_knockoff(&block) }
|
11
11
|
else
|
12
|
-
exec_queries_without_knockoff
|
12
|
+
exec_queries_without_knockoff(&block)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
data/lib/knockoff/config.rb
CHANGED
@@ -95,11 +95,24 @@ module Knockoff
|
|
95
95
|
end
|
96
96
|
|
97
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.
|
98
111
|
key = "knockoff_replica_#{index}"
|
99
|
-
|
112
|
+
config = replica_config.merge(uri_config)
|
113
|
+
ActiveRecord::Base.configurations[key] = config
|
100
114
|
|
101
|
-
|
102
|
-
@replicas_configurations[key] = full_config
|
115
|
+
@replicas_configurations[key] = config
|
103
116
|
rescue URI::InvalidURIError
|
104
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
|
105
118
|
# Return a 'nil' which will be removed from
|
data/lib/knockoff/version.rb
CHANGED
data/lib/knockoff.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.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Ringwelski
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -17,6 +17,9 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 4.0.0
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '6.1'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,6 +27,9 @@ dependencies:
|
|
24
27
|
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: 4.0.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '6.1'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: activesupport
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -31,6 +37,9 @@ dependencies:
|
|
31
37
|
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
33
39
|
version: 4.0.0
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '6.1'
|
34
43
|
type: :runtime
|
35
44
|
prerelease: false
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -38,6 +47,9 @@ dependencies:
|
|
38
47
|
- - ">="
|
39
48
|
- !ruby/object:Gem::Version
|
40
49
|
version: 4.0.0
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '6.1'
|
41
53
|
- !ruby/object:Gem::Dependency
|
42
54
|
name: bundler
|
43
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,9 +113,10 @@ executables: []
|
|
101
113
|
extensions: []
|
102
114
|
extra_rdoc_files: []
|
103
115
|
files:
|
116
|
+
- ".github/workflows/ruby.yml"
|
104
117
|
- ".gitignore"
|
105
118
|
- ".rspec"
|
106
|
-
- ".
|
119
|
+
- ".ruby-version"
|
107
120
|
- CHANGELOG.md
|
108
121
|
- Gemfile
|
109
122
|
- LICENSE.txt
|
@@ -136,12 +149,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
136
149
|
version: '0'
|
137
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
151
|
requirements:
|
139
|
-
- - "
|
152
|
+
- - ">="
|
140
153
|
- !ruby/object:Gem::Version
|
141
|
-
version:
|
154
|
+
version: '0'
|
142
155
|
requirements: []
|
143
|
-
|
144
|
-
rubygems_version: 2.6.13
|
156
|
+
rubygems_version: 3.1.4
|
145
157
|
signing_key:
|
146
158
|
specification_version: 4
|
147
159
|
summary: A gem for easily using read replicas
|