class Blender::Lock::Zk
Public Class Methods
new(name, options = {})
click to toggle source
# File lib/blender/lock/zk.rb, line 26 def initialize(name, options = {}) @path = options[:path] || name @hosts = options[:hosts] || 'localhost:2181' @chroot = options[:chroot] || :do_nothing @thread = options[:thread] || :single @timeout = options[:timeout] || 0 end
Public Instance Methods
with_lock() { || ... }
click to toggle source
# File lib/blender/lock/zk.rb, line 34 def with_lock ZK.open(@hosts) do |zk| zk.with_lock(@path, wait: @timeout) do yield if block_given? end end rescue ZK::Exceptions::LockWaitTimeoutError => e raise LockAcquisitionError, e.message end