Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace rxjava with reactor #541

Merged

Conversation

OwenLindsell
Copy link
Contributor

No description provided.

OwenLindsell and others added 13 commits November 18, 2019 11:12
…o replace-rxjava-with-reactor

# Conflicts:
#	components/client/src/main/java/com/hotels/styx/client/Connection.java
#	components/client/src/main/java/com/hotels/styx/client/StyxHttpClient.java
#	components/client/src/main/java/com/hotels/styx/client/connectionpool/ExpiringConnection.java
#	components/client/src/main/java/com/hotels/styx/client/connectionpool/stubs/StubConnectionFactory.java
#	components/client/src/main/java/com/hotels/styx/client/netty/connectionpool/HttpRequestOperation.java
#	components/client/src/main/java/com/hotels/styx/client/netty/connectionpool/NettyConnection.java
#	components/client/src/main/java/com/hotels/styx/client/netty/connectionpool/NettyToStyxResponsePropagator.java
#	components/client/src/test/unit/java/com/hotels/styx/client/StyxHostHttpClientTest.java
#	components/client/src/test/unit/java/com/hotels/styx/client/netty/connectionpool/NettyToStyxResponsePropagatorTest.java
Create an exception lazily only when necessary.
* Fixed Java unit tests so they run along with Kotlin tests in the components/proxy module
* Removed tests containing System.exit(); as Surefire does not support tests calling System.exit().
Copy link
Contributor

@mikkokar mikkokar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @OwenLindsell.

Only question though, and therefore requesting changes: What happened to pushesHttpContentOnChannelReadComplete test?

IIRC this is testing an important corner case in Netty/Styx interaction. If not correctly handled leads to hanging responses.

Otherwise everything looks good.

*/
Observable<LiveHttpResponse> write(LiveHttpRequest request);
Flux<LiveHttpResponse> write(LiveHttpRequest request);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could convert this to Mono. But that would be a separate increment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to have Flux (or Mono) in the signature here? I see an advantage of "Mono" as it depicts there's only going to be 0..1 events, but otherwise I would try to expose Reactive-streams types instead of the one from reactor-core.

Mono.from(RxReactiveStreams.toPublisher(
connection.write(networkRequest)
.doOnTerminate(connection::close)))
Mono.from(connection.write(networkRequest)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the record:

As discussed, Publisher<LiveHttpResponse> cancel event could occur whilst connection is being used in flatMap operator. In this case the connection needs to be closed.

Let's look into this as a separate improvement.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use doFinally() here instead of having to include doOnComplete, doOnError, doOnCancel ...?

StepVerifier.create(response.body())
.then(channel::runPendingTasks) // Execute onSubscribe in FSM
.then(() -> channel.pipeline().fireExceptionCaught(new RuntimeException())) // Will emmit BadHttpResponseException
.then(() -> channel.pipeline().fireChannelInactive()) // Will emmit TransportLostException
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in word emmit.

@OwenLindsell OwenLindsell merged commit 2b7075c into ExpediaGroup:master Nov 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants