class Gruf::Interceptors::ActiveRecord::ConnectionReset
Resets the ActiveRecord
connection to maintain accurate connected state in the thread pool
Public Instance Methods
call() { || ... }
click to toggle source
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
# File lib/gruf/interceptors/active_record/connection_reset.rb, line 29 def call ::ActiveRecord::Base.establish_connection if enabled? && !::ActiveRecord::Base.connection.active? yield ensure ::ActiveRecord::Base.clear_active_connections! if enabled? end
Private Instance Methods
enabled?()
click to toggle source
@return [Boolean] If AR is loaded, we can enable this hook safely
# File lib/gruf/interceptors/active_record/connection_reset.rb, line 42 def enabled? defined?(::ActiveRecord::Base) end