Method: Etcdv3#with_lock
- Defined in:
- lib/etcdv3.rb
#with_lock(name, lease_id, timeout: nil) ⇒ Object
Yield into the critical section while holding lock with the given name. The lock will be unlocked even if the block throws. name - string lease_id - integer optional :timeout - integer
125 126 127 128 129 130 131 132 |
# File 'lib/etcdv3.rb', line 125 def with_lock(name, lease_id, timeout: nil) key = lock(name, lease_id, timeout: timeout).key begin yield ensure unlock(key, timeout: timeout) end end |