Package com.tnsai.reliability
Class InMemoryProgressSink
java.lang.Object
com.tnsai.reliability.InMemoryProgressSink
- All Implemented Interfaces:
ProgressSink
Process-local
ProgressSink (TNS-299). Maintains a per-run
CopyOnWriteArrayList of subscribers and dispatches each
publish synchronously on the publisher's thread.
Concurrency
Subscribers may register and cancel from any thread. Publish iterates the COW list snapshot, so subscribers added or removed mid-publish don't break the iteration. A subscriber that throws is logged and skipped — one bad listener never starves the others.Replay
This sink does NOT replay events to late subscribers. Subscribers see only events published after theirsubscribe(java.lang.String, java.util.function.Consumer<com.tnsai.reliability.Progress>) call.
Operators that need history should query the CheckpointStore
directly or wire a buffering sink in front.- Since:
- 0.10.0 (TNS-299)
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.tnsai.reliability.ProgressSink
ProgressSink.Subscription -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidBroadcasteventto every subscriber registered forrunId.Registerlistenerfor events onrunId.intsubscriberCount(String runId) Test helper: count of active (non-cancelled) subscribers for a run.
-
Constructor Details
-
InMemoryProgressSink
public InMemoryProgressSink()
-
-
Method Details
-
publish
Description copied from interface:ProgressSinkBroadcasteventto every subscriber registered forrunId. Returns once delivery has been queued — does not block on slow subscribers (implementations decide their queueing / back-pressure strategy).- Specified by:
publishin interfaceProgressSink
-
subscribe
Description copied from interface:ProgressSinkRegisterlistenerfor events onrunId. The returnedProgressSink.Subscriptionmust be cancelled when the consumer is done; not cancelling leaks subscriber state.The listener may be invoked concurrently with itself for different events — implementations don't serialize calls.
- Specified by:
subscribein interfaceProgressSink
-
subscriberCount
Test helper: count of active (non-cancelled) subscribers for a run.
-