@@ -18,18 +18,17 @@ The main goal of this project is to explore basic features of
18
18
## definitions
19
19
Conceptual map:
20
20
* ** [ Flow.Publisher] ( https://docs.oracle.com/javase/9/docs/api/java/util/concurrent/Flow.Publisher.html ) ** -
21
- source of data.
21
+ source of data
22
22
* ** [ Flow.Subscriber] ( https://docs.oracle.com/javase/9/docs/api/java/util/concurrent/Flow.Subscriber.html ) ** -
23
- destination of data.
23
+ destination of data
24
24
* ** [ Flow.Subscription] ( https://docs.oracle.com/javase/9/docs/api/java/util/concurrent/Flow.Subscription.html ) ** -
25
25
message control linking a ` Flow.Publisher ` and ` Flow.Subscriber `
26
- (` Subscriber ` signal demand to ` Publisher ` ).
26
+ (` Subscriber ` signal demand to ` Publisher ` using ` Subscription ` )
27
27
* ** [ Flow.Processor] ( https://docs.oracle.com/javase/9/docs/api/java/util/concurrent/Flow.Processor.html ) ** -
28
28
a component that acts as both a ` Subscriber ` and ` Publisher ` (can
29
29
consume input and produce output).
30
30
* ** [ Flow.SubmissionPublisher] ( https://docs.oracle.com/javase/9/docs/api/java/util/concurrent/SubmissionPublisher.html ) ** -
31
- It's the only one implementation (in ` JDK ` ) of ` Flow.Publisher ` .
32
- Moreover - has ability to asynchronously issue submitted (non-null)
31
+ the only one implementation (in ` JDK ` ) of ` Flow.Publisher ` ; has ability to asynchronously issue submitted (non-null)
33
32
items to current subscribers until it is closed.
34
33
35
34
## data flow
@@ -40,28 +39,27 @@ We have two scenarios:
40
39
* ` Publisher ` is slow, ` Subscriber ` is fast (best scenario)
41
40
* ` Publisher ` is fast, ` Subscriber ` is slow (the ` Subscriber ` must deal
42
41
with excessive data - the most naive approach is just to drop all
43
- excessive data - so the data will be irrevitable).
42
+ excessive data - so the data will be irrevitable)
44
43
45
44
Note that if we have multiple ` subscribers ` and one ` publisher ` - they
46
45
are receiving elements in the same order.
47
46
48
47
## interaction steps
49
- 1 . Implement ` Flow.Publisher ` (useful, existing implementation that can be extended: ` SubmissionPublisher<T> ` )
50
- and ` Flow.Subscriber `
51
- 1 . The subscriber attempts to subscribe to the publisher by calling the
48
+ 1 . implement ` Flow.Publisher ` (using, for example ` SubmissionPublisher<T> ` ) and ` Flow.Subscriber `
49
+ 1 . the subscriber attempts to subscribe to the publisher by calling the
52
50
` subscribe(Flow.Subscriber<? super T> subscriber) `
53
51
method of the publisher
54
52
* success: the publisher asynchronously calls the ` onSubscribe(Flow.Subscription subscription) `
55
53
method of the subscriber
56
54
* failure: ` onError(Throwable throwable) ` method of the subscriber is called
57
55
with an ` IllegalStateException ` , and the interaction ends
58
- 1 . The subscriber sends a request to the publisher for ` N ` items calling the ` request(N) `
56
+ 1 . the subscriber sends a request to the publisher for ` N ` items calling the ` request(N) `
59
57
on the ` Subscription `
60
- 1 . Multiple requests are send regardless if earlier are already fulfilled (non-blocking)
61
- 1 . The publisher calls the ` onNext(T item) ` method of the subscriber and sends an item in each call
58
+ 1 . multiple requests are send regardless if earlier are already fulfilled (non-blocking)
59
+ 1 . the publisher calls the ` onNext(T item) ` method of the subscriber and sends an item in each call
62
60
* if there is no more items to send the publisher calls the ` onComplete() ` method of the subscriber to signal
63
61
the end of stream, and interaction ends
64
- * note that if subscriber requested ` Long.MAX_VALUE ` items, the stream becomes not reactive - it is
62
+ * note that if subscriber requests ` Long.MAX_VALUE ` items, the stream becomes not reactive - it is
65
63
effectively a push stream
66
64
1 . if the publisher encounters an error - calls ` onError(Throwable throwable) ` on subscriber
67
65
1 . the subscriber can cancel its subscription by calling the ` cancel() ` method on its subscription
0 commit comments