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

Refactor StyxHostHttpClient #338

Merged
merged 4 commits into from
Nov 12, 2018

Conversation

mikkokar
Copy link
Contributor

@mikkokar mikkokar commented Nov 9, 2018

Move functionality up into StyxBackendServiceClient:

  • Origin ID header attachment
  • Application name in the exceptions

Rationale: to make it easier to expose StyxHostHttpClient as a reusable component for 3rd party projects. Specifically, this improvement removes classes like Origin from the API and removes Styx proxy specific functionality like attaching origin IDs to HTTP responses.

- Origin ID header attachment
- Application name in the exceptions
Remove unnecessary NoAvailableHostsException mapping from StyxBackendServiceClient.
Address code review comments.
if (connection != null && connectionPool.isPresent()) {
connectionPool.get().returnConnection(connection);
}
private synchronized void returnIfConnected(ConnectionPool connectionPool, Connection connection) {
Copy link
Contributor

@dvlato dvlato Nov 12, 2018

Choose a reason for hiding this comment

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

Don't we ever need to synchronize on something different than the current object? In that case, do we actually need to set 'closeIfConnected' and/or 'returnIfConnected' as synchronized methods or should we try to ensure they are idempotent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey David. There is no longer need to synchronise on anything. I realised myself the synchronized modifiers were left in the methods. They should have been removed already. Perhaps you have commented an outdated version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thinking about it, perhaps I should remove these methods altogether.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh, sure, I see your commit now right before my comment. You can remove them but I don't see too much of a difference between both options to be honest... I don't dislike the 'extra indirection' myself.

.apply();
});
}

private synchronized void closeIfConnected(Optional<ConnectionPool> connectionPool, Connection connection) {
if (connection != null && connectionPool.isPresent()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Have we confirmed that the connections are never null? It would make sense, but thought it worth checking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A null value wouldn't be emitted under any circumstances (that would be a bug elsewhere in styx).

Note that the Reactive Streams specification specifically forbids null values as events (Rule 2.13 https://github.com/reactive-streams/reactive-streams-jvm/blob/v1.0.2/README.md). Although we are still in RxJava 1.0, our intention is to fully migrate to reactive-streams compatible implementation (Flux), ensuring it cannot be null.

@mikkokar mikkokar merged commit b744a77 into ExpediaGroup:master Nov 12, 2018
@mikkokar mikkokar deleted the simplify-styx-host-http-client branch November 12, 2018 16:20
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.

3 participants