class Simple::Sharding::ShardThreadRegistry
Attributes
_current_shard_id[RW]
Public Class Methods
connect_to_master?()
click to toggle source
# File lib/simple/sharding/shard_thread_registry.rb, line 27 def self.connect_to_master? _current_shard_id.nil? end
current_shard_id()
click to toggle source
Returns the current shard id (for the current Thread)
# File lib/simple/sharding/shard_thread_registry.rb, line 22 def self.current_shard_id shard_id_stack.last end
current_shard_id=(shard_id)
click to toggle source
# File lib/simple/sharding/shard_thread_registry.rb, line 35 def self.current_shard_id=(shard_id) self._current_shard_id = shard_id.blank? ? nil : shard_id.to_sym end
notify_connection_retrieved()
click to toggle source
notifies the current connection was used (wee keep track of this to warn the user in case the connection is not used)
# File lib/simple/sharding/shard_thread_registry.rb, line 52 def self.notify_connection_retrieved shard_connection_used_stack[-1] = true if shard_connection_used_stack.present? end
pop_current_shard()
click to toggle source
removes shard connection to the stack
# File lib/simple/sharding/shard_thread_registry.rb, line 57 def self.pop_current_shard [shard_id_stack.pop, shard_connection_used_stack.pop] end
push_current_shard(shard_id)
click to toggle source
adds shard connection to the stack
# File lib/simple/sharding/shard_thread_registry.rb, line 40 def self.push_current_shard(shard_id) # this line supresses the unused connection warning when there are nested # using_shard blocks. We suppress the warning because we view nested using_shard # blocks as a override notify_connection_retrieved shard_id_stack.push(shard_id.blank? ? nil : shard_id.to_sym) shard_connection_used_stack.push(false) end
shard_connection_used_stack()
click to toggle source
# File lib/simple/sharding/shard_thread_registry.rb, line 18 def self.shard_connection_used_stack; self._shard_connection_used_stack ||= [] end
shard_id_stack()
click to toggle source
# File lib/simple/sharding/shard_thread_registry.rb, line 17 def self.shard_id_stack; self._shard_id_stack ||= [] end