Module: Octoball::ConnectionPoolSetCurrentShard

Defined in:
lib/octoball/connection_adapters.rb

Instance Method Summary collapse

Instance Method Details

#active_connectionObject



32
33
34
35
36
# File 'lib/octoball/connection_adapters.rb', line 32

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

#active_connection?Boolean

Returns:

  • (Boolean)


26
27
28
29
30
# File 'lib/octoball/connection_adapters.rb', line 26

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

#lease_connectionObject



38
39
40
41
42
43
44
# File 'lib/octoball/connection_adapters.rb', line 38

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

#with_connection(prevent_permanent_checkout: false) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/octoball/connection_adapters.rb', line 17

def with_connection(prevent_permanent_checkout: false)
  lease = connection_lease
  if lease.connection
    lease.connection.current_shard = lease.connection.shard
  end

  super
end