bundleFor method
Returns the open bundle if initialize has been called for
atSign and the bundle is not closed; otherwise null.
Useful for code paths that should be no-ops when persistence
is not yet wired (e.g. metrics on a not-yet-started secondary).
Implementation
@override
AtPersistenceBundle? bundleFor(String atSign) {
final bundle = _bundles[atSign];
if (bundle == null) return null;
if (bundle.isClosed) {
// Lazy cleanup: a caller closed the bundle directly. Drop the
// stale entry so subsequent `initialize` / `bundleFor` calls
// see a clean slate.
_bundles.remove(atSign);
return null;
}
return bundle;
}