Class: Gruf::Interceptors::ActiveRecord::ConnectionReset
- Inherits:
-
ServerInterceptor
- Object
- Base
- ServerInterceptor
- Gruf::Interceptors::ActiveRecord::ConnectionReset
- Defined in:
- lib/gruf/interceptors/active_record/connection_reset.rb
Overview
Resets the ActiveRecord connection to maintain accurate connected state in the thread pool
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#call ⇒ Object
Reset any ActiveRecord connections after a gRPC service is called.
Methods included from Errors::Helpers
Methods inherited from Base
Constructor Details
This class inherits a constructor from Gruf::Interceptors::Base
Instance Method Details
#call ⇒ Object
Reset any ActiveRecord connections after a gRPC service is called. Because of the way gRPC manages its connection pool, we need to ensure that this is done to properly
27 28 29 30 31 32 33 34 |
# File 'lib/gruf/interceptors/active_record/connection_reset.rb', line 27 def call if enabled? && !::ActiveRecord::Base.connection.active? ::ActiveRecord::Base.establish_connection end yield ensure ::ActiveRecord::Base.clear_active_connections! if enabled? end |