Class: Etcdv3::Lease

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/lease.rb

Instance Method Summary collapse

Methods included from GRPC::Core::TimeConsts

from_relative_time

Constructor Details

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

Returns a new instance of Lease.



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

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

Instance Method Details

#lease_grant(ttl, 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/lease.rb', line 11

def lease_grant(ttl, timeout: nil)
  request = Etcdserverpb::LeaseGrantRequest.new(TTL: ttl)
  @stub.lease_grant(request, metadata: @metadata, deadline: deadline(timeout))
end

#lease_keep_alive_once(id, timeout: nil) ⇒ Object



26
27
28
29
30
31
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/lease.rb', line 26

def lease_keep_alive_once(id, timeout: nil)
  request = Etcdserverpb::LeaseKeepAliveRequest.new(ID: id)
  @stub.lease_keep_alive([request], metadata: @metadata, deadline: deadline(timeout)).each do |resp|
    return resp
  end
end

#lease_revoke(id, 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/lease.rb', line 16

def lease_revoke(id, timeout: nil)
  request = Etcdserverpb::LeaseRevokeRequest.new(ID: id)
  @stub.lease_revoke(request, metadata: @metadata, deadline: deadline(timeout))
end

#lease_ttl(id, timeout: nil) ⇒ Object



21
22
23
24
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/lease.rb', line 21

def lease_ttl(id, timeout: nil)
  request = Etcdserverpb::LeaseTimeToLiveRequest.new(ID: id, keys: true)
  @stub.lease_time_to_live(request, metadata: @metadata, deadline: deadline(timeout))
end