diff --git a/CHANGELOG.md b/CHANGELOG.md index 78ea5a3..739b9c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/gruf/interceptors/active_record/connection_reset.rb b/lib/gruf/interceptors/active_record/connection_reset.rb index d8d7f30..e0565a2 100644 --- a/lib/gruf/interceptors/active_record/connection_reset.rb +++ b/lib/gruf/interceptors/active_record/connection_reset.rb @@ -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? diff --git a/spec/gruf/interceptors/active_record/connection_reset_spec.rb b/spec/gruf/interceptors/active_record/connection_reset_spec.rb index 51bacfe..e84d8f2 100644 --- a/spec/gruf/interceptors/active_record/connection_reset_spec.rb +++ b/spec/gruf/interceptors/active_record/connection_reset_spec.rb @@ -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 @@ -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