-
Notifications
You must be signed in to change notification settings - Fork 119
first() and all(): Add syntactic sugar to treat ServerStreamingCallables like UnaryCallables #444
first() and all(): Add syntactic sugar to treat ServerStreamingCallables like UnaryCallables #444
Conversation
Codecov Report
@@ Coverage Diff @@
## master #444 +/- ##
============================================
+ Coverage 71.48% 71.94% +0.45%
- Complexity 728 746 +18
============================================
Files 150 154 +4
Lines 3276 3329 +53
Branches 256 256
============================================
+ Hits 2342 2395 +53
Misses 837 837
Partials 97 97
Continue to review full report at Codecov.
|
import java.util.List; | ||
|
||
/** | ||
* A {@link ResponseObserver} that buffers the results from a {@link ServerStreamingCallable} in a |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
/** | ||
* Construct a {@link UnaryCallable} that will yield the first item in the stream and cancel it. | ||
* If the stream was empty, the item will be null. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
/** | ||
* Construct a {@link UnaryCallable} that will buffer the entire stream into memory before | ||
* completing. If the stream was empty, then the list will be empty. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
* | ||
* <pre>{@code | ||
* StreamingCallable<String> streamingCallable = // .. | ||
* List<String></String> theResult = streamingCallable.all().call(request); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
/** | ||
* Simple implementation of a future to prematurely interrupt the RPC before the first element is | ||
* received. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
87388a9
to
3560008
Compare
rebased |
|
||
@Override | ||
public void onError(Throwable t) { | ||
future.setException(t); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
LGTM |
This PR adds
first()
andall()
callables on top of ServerStreamingCallables. This allows for simple interaction with short server streams. Example usage: