Skip to content

AsyncApacheHttp5Client : Proposal to make creating the callback FutureCallback<SimpleHttpResponse>> through a public factory method #2439

Open
@predatoralpha

Description

@predatoralpha

Hello,
I was faced with the problem to save thread-dependent data from the request-thread in an asynchronous httpclient-dispatch thread, for correctly output the necessary information in the Slf4jLogger logs, for example parentRequestId
The point of intersection of these threads is creation FutureCallback> - here thread-dependent information from request-thread can be stored in the callback for an asynchronous thread
I make workaround - I implemented this by proxying the class CloseableHttpAsyncClient and reflectively replacing the callback to its wrapper, with the necessary information from the request-thread to async
However, it would be convenient to have a public factory in the class with the ability to replace this factory to your own, for more convenient creation of a wrapper over a callback.
I suggest this code:
https://github.com/predatoralpha/AsyncApacheHttp5Client_proposal/blob/main/AsyncApacheHttp5Client.java
Here the factory is implemented via BiFunction<Request, CompletableFuture, FutureCallback>

Metadata

Metadata

Assignees

No one assigned

    Labels

    proposalProposed Specification or API change

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions