Skip to content

Commit

Permalink
Merge pull request #209 from bc-amit/remove_manual_establish_connection
Browse files Browse the repository at this point in the history
Removes manual establish_connection in interceptor
  • Loading branch information
splittingred authored Apr 24, 2024
2 parents 2a583e5 + 272ecb2 commit e1c7822
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog for the gruf gem. This includes internal history before the gem was ma

* [#190] Remove unsued `e2mmap` and `thwait` gems from `runtime_dependency`.
* [#194] Add interceptor to reload Rails app code accross requests
* [#209] Removes manual `establish_connection` and active connection check for each request from `Gruf::Interceptors::ActiveRecord::ConnectionReset`.

### 2.19.0

Expand Down
4 changes: 0 additions & 4 deletions lib/gruf/interceptors/active_record/connection_reset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ class ConnectionReset < ::Gruf::Interceptors::ServerInterceptor
# connection pool, we need to ensure that this is done to properly
#
def call
if enabled?
target_classes.each { |klass| klass.establish_connection unless klass.connection.active? }
end

yield
ensure
target_classes.each(&:clear_active_connections!) if enabled?
Expand Down
4 changes: 0 additions & 4 deletions spec/gruf/interceptors/active_record/connection_reset_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@
end

it 'tries to clear any active connections' do
expect(animals_record).to receive(:establish_connection).and_call_original
expect(animals_record).to receive(:clear_active_connections!).and_call_original
expect(::ActiveRecord::Base).to receive(:establish_connection)
expect(::ActiveRecord::Base).to receive(:clear_active_connections!)
subject
end
Expand All @@ -47,9 +45,7 @@
end

it 'does not try to clear any active connections' do
expect(::ActiveRecord::Base).not_to receive(:establish_connection)
expect(::ActiveRecord::Base).not_to receive(:clear_active_connections!)
expect(animals_record).not_to receive(:establish_connection)
expect(animals_record).not_to receive(:clear_active_connections!)
subject
end
Expand Down

0 comments on commit e1c7822

Please sign in to comment.