distribute_reads 0.3.4 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e52cc02b09f1027e932869c4acacff1d979bbe1c4deb34c952e81bd14c97fc9
4
- data.tar.gz: 783d432ebe59418e717cd52e2b09ae54174a21000f4cdef96be6e0ebf6651c22
3
+ metadata.gz: 3b3c66d675a295bdde2d0dcc05590ed3af790a8a44718b2044fb6482c3330836
4
+ data.tar.gz: 63db83095a8dcadfec723451c89afc9e3f712cef35a01d610b87f308febaa37c
5
5
  SHA512:
6
- metadata.gz: 728d62fd84f564e7e35981ae7bd37177c02ab69304b0a9c36e60ec2045af27a43fb284db4f12f5ca9094cbe9fd8108c3f4b6bed0421f4613bee9fb4a50ca8169
7
- data.tar.gz: 3698ec3ba5c50277a638f013293be1c28a0404baf477a0473e135bf1512641ac9afc6f89060a031f9b256bce162e3585b51640a8672e7c8b8b7ddbb8aa2059ee
6
+ metadata.gz: 0ce34129b83a7e5e5511dd96e5590d6bf80333124290591e94fc2db6291b45979f5dfd4467d2f81c1be4040cab55e451db9c41e318a1aa3285b94802e52c0244
7
+ data.tar.gz: 725b782d62ad8521407a1fd0b3c4a634e09147c83cb40f150cc04bc0ca64f1ac18565e9cfdb24966cf1296b1e4cd30388a8568ec83d84e5fccb1c1d2ce7e7ee7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 0.4.0 (2022-12-28)
2
+
3
+ - Made `distribute_reads` method private to behave like `Kernel` methods
4
+ - Dropped support for Makara 0.3
5
+ - Dropped support for Ruby < 2.6 and Active Record < 5.2
6
+
7
+ ## 0.3.5 (2022-01-30)
8
+
9
+ - Added support for Aurora Postgres 13 replication lag
10
+
1
11
  ## 0.3.4 (2021-08-22)
2
12
 
3
13
  - Added support for Aurora Postgres replication lag
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2017-2021 Andrew Kane
1
+ Copyright (c) 2017-2022 Andrew Kane
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -11,12 +11,12 @@ Scale database reads to replicas in Rails
11
11
  Add this line to your application’s Gemfile:
12
12
 
13
13
  ```ruby
14
- gem 'distribute_reads'
14
+ gem "distribute_reads"
15
15
  ```
16
16
 
17
17
  ## How to Use
18
18
 
19
- [Makara](https://github.com/taskrabbit/makara) does most of the work. First, update `database.yml` to use it:
19
+ [Makara](https://github.com/instacart/makara) does most of the work. First, update `database.yml` to use it:
20
20
 
21
21
  ```yml
22
22
  default: &default
@@ -7,11 +7,7 @@ module DistributeReads
7
7
  included do
8
8
  before_perform do
9
9
  if DistributeReads.by_default
10
- if DistributeReads.makara3?
11
- Makara::Context.set_current(Makara::Context.generate)
12
- else
13
- Makara::Context.release_all
14
- end
10
+ Makara::Context.release_all
15
11
  end
16
12
  end
17
13
  end
@@ -1,3 +1,3 @@
1
1
  module DistributeReads
2
- VERSION = "0.3.4"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -47,7 +47,7 @@ module DistributeReads
47
47
  cache_key = connection.pool.object_id
48
48
 
49
49
  unless @aurora_postgres.key?(cache_key)
50
- @aurora_postgres[cache_key] = connection.select_all("SELECT 1 FROM pg_stat_activity WHERE backend_type = 'aurora runtime'").any?
50
+ @aurora_postgres[cache_key] = connection.select_all("SELECT 1 FROM pg_stat_activity WHERE backend_type IN ('aurora runtime', 'aurora runtime process')").any?
51
51
  end
52
52
 
53
53
  @server_version_num ||= {}
@@ -126,7 +126,6 @@ module DistributeReads
126
126
  end
127
127
  end
128
128
 
129
- # private
130
129
  def self.backtrace_cleaner
131
130
  @backtrace_cleaner ||= begin
132
131
  bc = ActiveSupport::BacktraceCleaner.new
@@ -136,8 +135,8 @@ module DistributeReads
136
135
  bc
137
136
  end
138
137
  end
138
+ private_class_method :backtrace_cleaner
139
139
 
140
- # private
141
140
  def self.with_replica
142
141
  previous_value = Thread.current[:distribute_reads]
143
142
  begin
@@ -147,14 +146,7 @@ module DistributeReads
147
146
  Thread.current[:distribute_reads] = previous_value
148
147
  end
149
148
  end
150
-
151
- # private
152
- def self.makara3?
153
- unless defined?(@makara3)
154
- @makara3 = Gem::Version.new(Makara::VERSION.to_s) < Gem::Version.new("0.4.0")
155
- end
156
- @makara3
157
- end
149
+ private_class_method :with_replica
158
150
 
159
151
  # legacy
160
152
  def self.default_to_primary
@@ -169,8 +161,7 @@ end
169
161
 
170
162
  Makara::Proxy.prepend DistributeReads::AppropriatePool
171
163
  Object.include DistributeReads::GlobalMethods
172
- # TODO uncomment in 0.4.0
173
- # Object.send :private, :distribute_reads
164
+ Object.send :private, :distribute_reads
174
165
 
175
166
  ActiveSupport.on_load(:active_job) do
176
167
  require "distribute_reads/job_methods"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: distribute_reads
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-22 00:00:00.000000000 Z
11
+ date: 2022-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: makara
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0.3'
19
+ version: '0.4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0.3'
26
+ version: '0.4'
27
27
  description:
28
28
  email: andrew@ankane.org
29
29
  executables: []
@@ -51,14 +51,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '2.4'
54
+ version: '2.6'
55
55
  required_rubygems_version: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
59
  version: '0'
60
60
  requirements: []
61
- rubygems_version: 3.2.22
61
+ rubygems_version: 3.4.1
62
62
  signing_key:
63
63
  specification_version: 4
64
64
  summary: Scale database reads with replicas in Rails