Class AsyncIterablePublisher<T>
java.lang.Object
org.reactivestreams.example.unicast.AsyncIterablePublisher<T>
- All Implemented Interfaces:
Publisher<T>
- Direct Known Subclasses:
HelperPublisher, InfiniteHelperPublisher, InfiniteIncrementNumberPublisher, NumberIterablePublisher
AsyncIterablePublisher is an implementation of Reactive Streams `Publisher`
which executes asynchronously, using a provided `Executor` and produces elements
from a given `Iterable` in a "unicast" configuration to its `Subscribers`.
NOTE: The code below uses a lot of try-catches to show the reader where exceptions can be expected, and where they are forbidden.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enum(package private) static final class(package private) static enum(package private) static interface(package private) static enum(package private) final class -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAsyncIterablePublisher(Iterable<T> elements, int batchSize, Executor executor) AsyncIterablePublisher(Iterable<T> elements, Executor executor) -
Method Summary
Modifier and TypeMethodDescriptionvoidsubscribe(Subscriber<? super T> s) RequestPublisherto start streaming data.
-
Field Details
-
DEFAULT_BATCHSIZE
private static final int DEFAULT_BATCHSIZE- See Also:
-
elements
-
executor
-
batchSize
private final int batchSize
-
-
Constructor Details
-
AsyncIterablePublisher
-
AsyncIterablePublisher
-
-
Method Details
-
subscribe
Description copied from interface:PublisherRequestPublisherto start streaming data.This is a "factory method" and can be called multiple times, each time starting a new
Subscription.Each
Subscriptionwill work for only a singleSubscriber.A
Subscribershould only subscribe once to a singlePublisher.If the
Publisherrejects the subscription attempt or otherwise fails it will signal the error viaSubscriber.onError(Throwable).- Specified by:
subscribein interfacePublisher<T>- Parameters:
s- theSubscriberthat will consume signals from thisPublisher
-