Class Watcher
java.lang.Object
codes.grow.packages.awssecretsmanager.secrets.Watcher
- All Implemented Interfaces:
AutoCloseable
Polls secrets for changes on one daemon thread (created on the first watch).
close()
stops every watch.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintactive()Returns the number of running watches.voidclose()Stops every watch and the polling thread.watch(Supplier<Optional<SecretValue>> fetch, Duration interval, WatchListener listener, WatchOptions opts) Starts polling.
-
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 valueinterval- polling interval (positive)listener- change callbackopts- error callback- Returns:
- the handle
- Throws:
IllegalArgumentException- when the interval is not positiveCancelledException- afterclose()
-
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:
closein interfaceAutoCloseable
-