Package io.etcd.jetcd

Interface Lease

  • All Superinterfaces:
    java.lang.AutoCloseable, CloseableClient

    public interface Lease
    extends CloseableClient
    Interface of KeepAlive talking to etcd.
    • Method Detail

      • grant

        java.util.concurrent.CompletableFuture<LeaseGrantResponse> grant​(long ttl)
        New a lease with ttl value.
        Parameters:
        ttl - ttl value, unit seconds
        Returns:
        the grant response
      • grant

        java.util.concurrent.CompletableFuture<LeaseGrantResponse> grant​(long ttl,
                                                                         long timeout,
                                                                         java.util.concurrent.TimeUnit unit)
        New a lease with ttl value.Waits if necessary for at most the given time if etcd server is available.
        Parameters:
        ttl - ttl value, unit seconds
        timeout - the maximum time to waits
        unit - the time unit of the timeout argument
        Returns:
        The grant response
      • revoke

        java.util.concurrent.CompletableFuture<LeaseRevokeResponse> revoke​(long leaseId)
        revoke one lease and the key bind to this lease will be removed.
        Parameters:
        leaseId - id of the lease to revoke
        Returns:
        the revoke response
      • keepAliveOnce

        java.util.concurrent.CompletableFuture<LeaseKeepAliveResponse> keepAliveOnce​(long leaseId)
        keep alive one lease only once.
        Parameters:
        leaseId - id of lease to keep alive once
        Returns:
        The keep alive response
      • timeToLive

        java.util.concurrent.CompletableFuture<LeaseTimeToLiveResponse> timeToLive​(long leaseId,
                                                                                   LeaseOption leaseOption)
        retrieves the lease information of the given lease ID.
        Parameters:
        leaseId - id of lease
        leaseOption - LeaseOption
        Returns:
        LeaseTimeToLiveResponse wrapped in CompletableFuture
      • keepAlive

        CloseableClient keepAlive​(long leaseId,
                                  io.grpc.stub.StreamObserver<LeaseKeepAliveResponse> observer)
        keep the given lease alive forever.
        Parameters:
        leaseId - lease to be keep alive forever.
        observer - the observer
        Returns:
        a KeepAliveListener that listens for KeepAlive responses.