Class: Etcdv3::Lock

Inherits:
Object show all
Includes:
GRPC::Core::TimeConsts
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/lock.rb

Instance Method Summary collapse

Methods included from GRPC::Core::TimeConsts

from_relative_time

Constructor Details

#initialize(hostname, credentials, timeout, metadata = {}) ⇒ Lock

Returns a new instance of Lock.



5
6
7
8
9
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/lock.rb', line 5

def initialize(hostname, credentials, timeout,  = {})
  @stub = V3lockpb::Lock::Stub.new(hostname, credentials)
  @timeout = timeout
  @metadata = 
end

Instance Method Details

#lock(name, lease_id, timeout: nil) ⇒ Object



11
12
13
14
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/lock.rb', line 11

def lock(name, lease_id, timeout: nil)
  request = V3lockpb::LockRequest.new(name: name, lease: lease_id)
  @stub.lock(request, metadata: @metadata, deadline: deadline(timeout))
end

#unlock(key, timeout: nil) ⇒ Object



16
17
18
19
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/lock.rb', line 16

def unlock(key, timeout: nil)
  request = V3lockpb::UnlockRequest.new(key: key)
  @stub.unlock(request, metadata: @metadata, deadline: deadline(timeout))
end