Package eu.vstoyanov.natsy
Class SubscriptionHandle
-
- All Implemented Interfaces:
public final class SubscriptionHandle<T extends Object>One subscription, and the rendezvous that tells you it exists.
messages is cold and can be collected only once - a handle is a single subscription, not a factory for them, and a second collection throws IllegalStateException. Call NatsScope.subscribe again for a second subscriber; that is also how fan-out is expressed, a handle per collector.
val orders = subscribe<OrderEvent>("orders") launch { orders.messages.collect { ... } } orders.started() publish("orders", OrderEvent("no race"))
-
-
Method Summary
Modifier and Type Method Description final Flow<T>getMessages()final Unitstarted(Duration timeout)Suspends until this subscription is live on the server: until messages has been collected, registering the SUB, and until the server has acknowledged it.-
-
Method Detail
-
getMessages
final Flow<T> getMessages()
-
started
final Unit started(Duration timeout)
Suspends until this subscription is live on the server: until messages has been collected, registering the
SUB, and until the server has acknowledged it. Anything published after this returns reaches this subscriber - from any connection, not only this klient's.- Parameters:
timeout- How long to wait for the server to acknowledge the subscription.
-
-
-
-