Module: BusinessFlow::ClusterLock
- Defined in:
- lib/business_flow/cluster_lock.rb
Overview
Mixin for business flow to acquire and retain a cluster lock.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
- .default_servers ⇒ Object
- .default_servers=(servers) ⇒ Object
- .disable! ⇒ Object
- .disabled? ⇒ Boolean
- .enable! ⇒ Object
- .included(klass) ⇒ Object
Instance Method Summary collapse
Class Method Details
.default_servers ⇒ Object
32 33 34 |
# File 'lib/business_flow/cluster_lock.rb', line 32 def self.default_servers @default_servers ||= proc {} end |
.default_servers=(servers) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/business_flow/cluster_lock.rb', line 22 def self.default_servers=(servers) @default_servers = if servers.is_a?(String) proc { servers } elsif servers Callable.new(servers) else nil end end |
.disable! ⇒ Object
10 11 12 |
# File 'lib/business_flow/cluster_lock.rb', line 10 def self.disable! @disabled = true end |
.disabled? ⇒ Boolean
18 19 20 |
# File 'lib/business_flow/cluster_lock.rb', line 18 def self.disabled? !!@disabled end |
.enable! ⇒ Object
14 15 16 |
# File 'lib/business_flow/cluster_lock.rb', line 14 def self.enable! @disabled = false end |
.included(klass) ⇒ Object
6 7 8 |
# File 'lib/business_flow/cluster_lock.rb', line 6 def self.included(klass) klass.extend(ClassMethods) end |
Instance Method Details
#assert_cluster_lock! ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/business_flow/cluster_lock.rb', line 36 def assert_cluster_lock! @_business_flow_cluster_lock.assert! unless BusinessFlow::ClusterLock.disabled? rescue ZK::Exceptions::ZKError => e BusinessFlow.add_error(errors, :cluster_lock, :assert_failed, e.) raise end |
#read_attribute_for_validation(key) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/business_flow/cluster_lock.rb', line 44 def read_attribute_for_validation(key) if key == :cluster_lock ClassMethods.lock_name(self) else super(key) end end |