Sha256: 8386eda3a6e3e2ed3d9dbc57641ccb51486792f4d1ef013b5792cdaffe1d63d3

Contents?: true

Size: 1.18 KB

Versions: 10

Compression:

Stored size: 1.18 KB

Contents

class Etcdv3
  class Lease
    include GRPC::Core::TimeConsts

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

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

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

    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

    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

    private

    def deadline(timeout)
      from_relative_time(timeout || @timeout)
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/lease.rb
rubypitaya-3.12.4 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/lease.rb
rubypitaya-3.12.3 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/lease.rb
rubypitaya-3.12.2 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/etcdv3-0.11.5/lib/etcdv3/lease.rb
etcdv3-0.11.5 lib/etcdv3/lease.rb
etcdv3-0.11.4 lib/etcdv3/lease.rb
etcdv3-0.11.3 lib/etcdv3/lease.rb
etcdv3-0.10.2 lib/etcdv3/lease.rb
etcdv3-0.10.1 lib/etcdv3/lease.rb
etcdv3-0.9.0 lib/etcdv3/lease.rb