Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes manual establish_connection in interceptor #209

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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