Skip to content

Commit

Permalink
wip: patch for lease_connection
Browse files Browse the repository at this point in the history
  • Loading branch information
fumihumi committed Sep 3, 2024
1 parent b73827d commit fc17846
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/octoball/connection_adapters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,23 @@ def with_connection(prevent_permanent_checkout: false)

def active_connection?
conn = connection_lease.connection
conn.current_shard = conn.shard
conn.current_shard = conn.shard if conn
conn
end

def active_connection
conn = connection_lease.connection
conn.current_shard = conn.shard
conn.current_shard = conn.shard if conn
conn
end

def lease_connection
lease = connection_lease
lease.sticky = true
lease.connection ||= checkout
lease.connection.current_shard = lease.connection.shard
lease.connection
end
end

::ActiveRecord::ConnectionAdapters::ConnectionPool.prepend(ConnectionPoolSetCurrentShard)
Expand Down

0 comments on commit fc17846

Please sign in to comment.