knockoff 1.2.0 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 95bb6904e4373aa3b026fc1e950b8f5cc9081a4abd174e58ef4ed521824fb5bb
4
- data.tar.gz: 6bfeeb88cb514854c2e550f531d65c76c160bcac1225b741deab01f6183e0abf
3
+ metadata.gz: 22fb5337ef43e286ab938ab8d6e4905529607979266b8bb7673eccdba23c5d3c
4
+ data.tar.gz: 9990634bf328df85fe419cbb3aea20b591d4a9c94420184f89012a15649ac2af
5
5
  SHA512:
6
- metadata.gz: e2afdaf7285a09cb98a2946f19313160d84fe57208e86e00278732c391143c524093ab40e241a4db0c59711db789737b64e4958f2667fec6c7727f006e584663
7
- data.tar.gz: ee421e025448df4043319d90be8ed9aa8f9e2979d633feaa29d8876ea8bfb24aa1411d6103aeb65d50cb25f5c549732165d60330355bfe944f53fdc6bb14f955
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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Knockoff
2
2
 
3
- [![Build Status](https://travis-ci.com/joinhandshake/knockoff.svg?branch=master)](https://travis-ci.com/github/joinhandshake/knockoff)
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.
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"
@@ -95,18 +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
- if ActiveRecord::VERSION::MAJOR >= 6
102
- full_config = ActiveRecord::Base.configurations.to_h.merge(key => config)
103
-
104
- ActiveRecord::Base.configurations = full_config
105
- @replicas_configurations[key] = config
106
- else
107
- ActiveRecord::Base.configurations[key] = config
108
- @replicas_configurations[key] = config
109
- end
115
+ @replicas_configurations[key] = config
110
116
  rescue URI::InvalidURIError
111
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
112
118
  # Return a 'nil' which will be removed from
@@ -30,6 +30,12 @@ module Knockoff
30
30
  end
31
31
  end
32
32
 
33
+ def set_schema_cache(cache)
34
+ @pool.each do |_name, klass|
35
+ klass.connection_pool.schema_cache = cache
36
+ end
37
+ end
38
+
33
39
  def random_replica_connection
34
40
  @pool[@pool.keys.sample]
35
41
  end
@@ -1,3 +1,3 @@
1
1
  module Knockoff
2
- VERSION = '1.2.0'.freeze
2
+ VERSION = '1.3.0'.freeze
3
3
  end
data/lib/knockoff.rb CHANGED
@@ -49,6 +49,10 @@ module Knockoff
49
49
  @config ||= Config.new
50
50
  end
51
51
 
52
+ def set_schema_cache(cache)
53
+ replica_pool.set_schema_cache(cache)
54
+ end
55
+
52
56
  def base_transaction_depth
53
57
  @base_transaction_depth ||= begin
54
58
  testcase = ActiveSupport::TestCase
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.2.0
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: 2021-01-29 00:00:00.000000000 Z
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
- - ".travis.yml"
119
+ - ".ruby-version"
107
120
  - CHANGELOG.md
108
121
  - Gemfile
109
122
  - LICENSE.txt
@@ -140,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
153
  - !ruby/object:Gem::Version
141
154
  version: '0'
142
155
  requirements: []
143
- rubygems_version: 3.1.2
156
+ rubygems_version: 3.1.4
144
157
  signing_key:
145
158
  specification_version: 4
146
159
  summary: A gem for easily using read replicas
data/.travis.yml DELETED
@@ -1,9 +0,0 @@
1
- language: ruby
2
- notifications:
3
- email: false
4
- rvm:
5
- - 2.4.0
6
- - 2.5.1
7
- - 2.6.6
8
- - 2.7.2
9
- - ruby-head