java.lang.Object
codes.grow.packages.awssecretsmanager.secrets.Watcher
All Implemented Interfaces:
AutoCloseable

public final class Watcher extends Object implements AutoCloseable
Polls secrets for changes on one daemon thread (created on the first watch). close() stops every watch.
  • Constructor Details

    • Watcher

      public Watcher()
      Creates a watcher.
  • Method Details

    • watch

      public WatchHandle watch(Supplier<Optional<SecretValue>> fetch, Duration interval, WatchListener listener, WatchOptions opts)
      Starts polling. The first successful read is the baseline (no callback); later reads call the listener when the fingerprint (version, else SHA-256) changes, including deletion.
      Parameters:
      fetch - reads the current value
      interval - polling interval (positive)
      listener - change callback
      opts - error callback
      Returns:
      the handle
      Throws:
      IllegalArgumentException - when the interval is not positive
      CancelledException - after close()
    • active

      public int active()
      Returns the number of running watches.
      Returns:
      active watch count
    • close

      public void close()
      Stops every watch and the polling thread. Idempotent.
      Specified by:
      close in interface AutoCloseable