Class: Etcdv3::Namespace::Lock
- Includes:
- Utilities, GRPC::Core::TimeConsts
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/namespace/lock.rb
Instance Method Summary collapse
-
#initialize(hostname, credentials, timeout, namespace, metadata = {}) ⇒ Lock
constructor
A new instance of Lock.
- #lock(name, lease_id, timeout: nil) ⇒ Object
- #unlock(key, timeout: nil) ⇒ Object
Methods included from Utilities
#delete_prefix, #prepend_prefix, #strip_prefix, #strip_prefix_from_events, #strip_prefix_from_lock
Methods included from GRPC::Core::TimeConsts
Constructor Details
#initialize(hostname, credentials, timeout, namespace, metadata = {}) ⇒ Lock
Returns a new instance of Lock.
6 7 8 9 10 11 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/namespace/lock.rb', line 6 def initialize(hostname, credentials, timeout, namespace, = {}) @stub = V3lockpb::Lock::Stub.new(hostname, credentials) @timeout = timeout @namespace = namespace @metadata = end |
Instance Method Details
#lock(name, lease_id, timeout: nil) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/namespace/lock.rb', line 13 def lock(name, lease_id, timeout: nil) name = prepend_prefix(@namespace, name) request = V3lockpb::LockRequest.new(name: name, lease: lease_id) resp = @stub.lock(request, metadata: @metadata, deadline: deadline(timeout)) strip_prefix_from_lock(@namespace, resp) end |
#unlock(key, timeout: nil) ⇒ Object
20 21 22 23 24 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/namespace/lock.rb', line 20 def unlock(key, timeout: nil) key = prepend_prefix(@namespace, key) request = V3lockpb::UnlockRequest.new(key: key) @stub.unlock(request, metadata: @metadata, deadline: deadline(timeout)) end |