Class: Etcdv3::Lease
- Inherits:
-
Object
- Object
- Etcdv3::Lease
- Includes:
- GRPC::Core::TimeConsts
- Defined in:
- lib/etcdv3/lease.rb
Instance Method Summary collapse
-
#initialize(hostname, credentials, timeout, metadata = {}) ⇒ Lease
constructor
A new instance of Lease.
- #lease_grant(ttl, timeout: nil) ⇒ Object
- #lease_keep_alive_once(id, timeout: nil) ⇒ Object
- #lease_revoke(id, timeout: nil) ⇒ Object
- #lease_ttl(id, timeout: nil) ⇒ Object
Constructor Details
#initialize(hostname, credentials, timeout, metadata = {}) ⇒ Lease
5 6 7 8 9 |
# File 'lib/etcdv3/lease.rb', line 5 def initialize(hostname, credentials, timeout, ={}) @stub = Etcdserverpb::Lease::Stub.new(hostname, credentials) @timeout = timeout = end |
Instance Method Details
#lease_grant(ttl, timeout: nil) ⇒ Object
11 12 13 14 |
# File 'lib/etcdv3/lease.rb', line 11 def lease_grant(ttl, timeout: nil) request = Etcdserverpb::LeaseGrantRequest.new(TTL: ttl) @stub.lease_grant(request, metadata: , deadline: deadline(timeout)) end |
#lease_keep_alive_once(id, timeout: nil) ⇒ Object
26 27 28 29 30 31 |
# File '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: , deadline: deadline(timeout)).each do |resp| return resp end end |
#lease_revoke(id, timeout: nil) ⇒ Object
16 17 18 19 |
# File 'lib/etcdv3/lease.rb', line 16 def lease_revoke(id, timeout: nil) request = Etcdserverpb::LeaseRevokeRequest.new(ID: id) @stub.lease_revoke(request, metadata: , deadline: deadline(timeout)) end |
#lease_ttl(id, timeout: nil) ⇒ Object
21 22 23 24 |
# File '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: , deadline: deadline(timeout)) end |