Sha256: d008ca8ee8452859d2c1ee50c2dca7524fcd2affe58d6dc574ef438b1bca22fa
Contents?: true
Size: 434 Bytes
Versions: 4
Compression:
Stored size: 434 Bytes
Contents
module ConsulStockpile module ConsulLock extend self def with_lock(key:) sessionid = nil locked = false sessionid = Diplomat::Session.create(Name: "#{key}.lock") locked = Diplomat::Lock.wait_to_acquire(key, sessionid) yield ensure if sessionid != nil Diplomat::Lock.release(key, sessionid) if locked Diplomat::Session.destroy(sessionid) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems