question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Split streaming API from `WebClient`

See original GitHub issue

If a user receives a fully aggregated HTTP response, he or she should call aggregate():

WebClient client = ...;
CompleteFuture<AggregateHttpResponse> response = client.get("/some/path").aggregate();

It could be boilerplate to call aggregate() every time because most REST API returns a unary HTTP response. I think we can improve this API design by splitting WebClient and StreamWebClient. The original idea was suggested by @trustin.

WebClient client = ...;
// Returns an aggregated response directly
CompleteFuture<AggregatedHttpResponse> response = client.get("/some/path");

// Switch to a streaming client. 
StreamingWebClient streamingClient = client.streaming();
// Returns an HttpResponse that can be subscribed by a Reactive Streams `Subscriber`
HttpResponse response = streamingClient.get("/some/path");

Furthermore, we can also provide a blocking WebClient for blocking services and tests.

WebClient client = ...;
// Switch to a streaming client. 
BlockingWebClient blockingClient = client.blocking();
// Wait for an aggregated response until fully received.
AggregatedHttpResponse response = blockingClient.get("/some/path");

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
anuraagacommented, Jun 22, 2021

Sounds very familiar 😛 #2364

Don’t think it needs to wait for 2.0.0, can leave WebClient as is and convert it to the wrappers as per @trustin’s suggestion

0reactions
anuraagacommented, Jun 22, 2021

Another one or two years sounds better 😃 It is also a good reason to go with your proposed approach from #2364 I think as it does sound reasonable far off then (good thing).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Splitting a WebClient Post of a Streaming Flux into JSON Arrays
How do I POST in chunks of arrays? Use one of the variants of Flux.window to split the main flux into windowed fluxes,...
Read more >
Split WebClient into blocking / async versions? #2364 - GitHub
Streaming WebClient , always returns HttpResponse. I guess users either always use blocking, or always use async, so it can be annoying to ......
Read more >
Real Time Event Streaming using Spring WebFlux - Medium
Introduction. In this article, we'll explore Spring's new WebFlux Framework and build a real-time event streaming API using it.
Read more >
Simultaneous Spring WebClient Calls - Baeldung
Learn how to make simultaneous HTTP requests using The Spring WebClient.
Read more >
13 Using WebClient to make API calls - YouTube
In this video, we'll switch to using WebClient for making API calls. We'll explore how WebClient uses reactive programming constructs for ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found