Class TokenRenewer

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

public final class TokenRenewer extends Object implements AutoCloseable
Renews the client token in the background (auth/token/renew-self at 2/3 of the TTL). When the token cannot be renewed any more it logs in again (when a re-login method is set) or calls onExpire once at expiry. Stopped by close() or VaultClient.close().
  • Method Details

    • running

      public boolean running()
      Returns whether the renewer is active.
      Returns:
      true while renewing
    • expired

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

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

      public void close()
      Stops renewing. Idempotent; onExpire is not called.
      Specified by:
      close in interface AutoCloseable