Skip to content

Commit

Permalink
Removes manual establish_connection in interceptor
Browse files Browse the repository at this point in the history
  • Loading branch information
bc-amit committed Apr 5, 2024
1 parent 2a583e5 commit fa305f1
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 8 deletions.
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 fa305f1

Please sign in to comment.