-
Notifications
You must be signed in to change notification settings - Fork 79
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
Changes from 14 commits
4d226c9
b1e6c68
b5c714e
1bb5d24
487a8f7
a1bbc30
9e74ef2
8fdd81d
17d8451
44781c3
a9d4011
ed17f39
02e07fc
3248aa8
d385c92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,6 @@ | |
import com.hotels.styx.client.ssl.SslContextFactory; | ||
import io.netty.handler.ssl.SslContext; | ||
import reactor.core.publisher.Mono; | ||
import rx.RxReactiveStreams; | ||
|
||
import java.util.Optional; | ||
import java.util.concurrent.CompletableFuture; | ||
|
@@ -117,18 +116,23 @@ static Mono<LiveHttpResponse> sendRequestInternal(NettyConnectionFactory connect | |
|
||
SslContext sslContext = getSslContext(params.https(), params.tlsSettings()); | ||
|
||
Mono<LiveHttpResponse> responseObservable = connectionFactory.createConnection( | ||
return connectionFactory.createConnection( | ||
origin, | ||
new ConnectionSettings(params.connectTimeoutMillis()), | ||
sslContext | ||
).flatMap(connection -> | ||
Mono.from(RxReactiveStreams.toPublisher( | ||
connection.write(networkRequest) | ||
.doOnTerminate(connection::close))) | ||
Mono.from(connection.write(networkRequest) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the record: As discussed, Let's look into this as a separate improvement. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ...? |
||
.doOnComplete(connection::close) | ||
.doOnError(e -> connection.close()) | ||
.map(response -> response.newBuilder() | ||
.body(it -> | ||
it.doOnEnd(x -> connection.close()) | ||
.doOnCancel(() -> connection.close()) | ||
) | ||
.build() | ||
) | ||
) | ||
); | ||
|
||
return responseObservable; | ||
|
||
} | ||
|
||
private static LiveHttpRequest addUserAgent(String userAgent, LiveHttpRequest request) { | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.