Skip to content
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
6 changes: 5 additions & 1 deletion lib/gruf/interceptors/active_record/connection_reset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ class ConnectionReset < ::Gruf::Interceptors::ServerInterceptor
def call
yield
ensure
target_classes.each { |klass| klass.connection_handler.clear_active_connections! } if enabled?
if enabled?
target_classes.each do |klass|
klass.connection_handler.clear_active_connections!(::ActiveRecord::Base.current_role)
end
end
end

private
Expand Down
6 changes: 5 additions & 1 deletion spec/support/rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ def self.connection_handler
def self.connected?
true
end

def self.current_role
:writing
end
end

class Connection
Expand All @@ -45,7 +49,7 @@ def active?
end

class ConnectionHandler
def clear_active_connections!
def clear_active_connections!(role)
true
end
end
Expand Down