-
Notifications
You must be signed in to change notification settings - Fork 267
refactor(client): migrates CompletableFuture to reactive patterns for HttpClientSseClientTransport #128
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
base: main
Are you sure you want to change the base?
Conversation
9a72b0f
to
a34ca8b
Compare
d5b00c9
to
55c5310
Compare
.doOnError(err -> logger.error("Error sending message", err)) | ||
.then(); | ||
|
||
}).retryWhen(Retry.fixedDelay(3, Duration.ofSeconds(3)).filter(err -> messageEndpoint.get() == null)); |
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.
See another PR with this same pattern. 3/3 retry. Maybe place this in a constant place.
} | ||
|
||
private void logIfNotOk(final HttpResponse<?> response) { | ||
if (response.statusCode() != 200 && response.statusCode() != 201 && response.statusCode() != 202 |
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.
Maybe use constants somewhere or check for entire 2xx series.
return state.get(); | ||
} | ||
|
||
// Enum to manage transport states |
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.
Not trying to be judgemental but the comment doesn't add anything.
|
||
String lastId = lastEventId.get(); | ||
if (lastId != null) { | ||
builder.header("Last-Event-ID", lastId); |
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.
Should be a constant shared across the java projects.
55c5310
to
fcd0d8f
Compare
fcd0d8f
to
f72e92b
Compare
Replaced CompletableFuture with Mono from the reactive programming paradigm for the HttpClientSseClientTransport class internally, ensuring a consistent concurrency model using reactive patterns.
Motivation and Context
This change was made to align with a more consistent and modern concurrency implementation, avoiding the mixing of different paradigms. By switching from CompletableFuture to Mono, we improving maintainability and consistency, while also simplifying the concurrency handling for SSE event processing. This PR is related to issue
How Has This Been Tested?
Breaking Changes
No breaking changes should be introduced. The internal concurrency implementation has changed, but it does not affect the end users. No code or configuration updates are needed for consumers of the HttpClientSseClientTransport class.
Types of changes
Checklist
Additional context
let me know if i missed something and need to add or if these changes don't make sense no problem just close this pr :-)