Class ManagedLease

java.lang.Object
codes.grow.packages.vault.ManagedLease
All Implemented Interfaces:
AutoCloseable

public final class ManagedLease extends Object implements AutoCloseable
Handle of a lease kept alive by LeaseManager.manage(Lease, RenewalOptions).
  • Method Details

    • leaseId

      public String leaseId()
      Returns the lease id.
      Returns:
      the id
    • running

      public boolean running()
      Returns whether renewal is still active.
      Returns:
      true while running
    • expired

      public boolean expired()
      Returns whether onExpire fired.
      Returns:
      true once expired
    • expiresAt

      public Optional<Instant> expiresAt()
      Returns the expiry of the current lease.
      Returns:
      the expiry, or empty when it never expires
    • stopAsync

      public CompletableFuture<Void> stopAsync()
      Stops renewing (and revokes the lease when revokeOnStop). Idempotent.
      Returns:
      a future completed when stopped (revocation errors go to onError)
    • close

      public void close()
      Stops renewing and waits for the optional revocation. Idempotent.
      Specified by:
      close in interface AutoCloseable
    • toString

      public String toString()
      Overrides:
      toString in class Object