Skip to content
New issue

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

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

Already on GitHub? # to your account

Investigate reusing HttpClient between requests #441

Closed
dakrone opened this issue Mar 14, 2018 · 10 comments
Closed

Investigate reusing HttpClient between requests #441

dakrone opened this issue Mar 14, 2018 · 10 comments

Comments

@dakrone
Copy link
Owner

dakrone commented Mar 14, 2018

It may not need to be created every time, instead, it could be reused.

Related to #371

@dakrone
Copy link
Owner Author

dakrone commented Mar 14, 2018

@serioga please check out 98885eb and let me know if that works for you!

dakrone added a commit that referenced this issue Mar 14, 2018
This commit adds the `:http-client` parameter in the response. This is the
HttpClient that was used for the request. An http client can also be passed in
with `:http-client`.

Note that an :http-client may only be specified when a reusable connection
manager is used, otherwise an exception will be thrown.

This also adds docs and naming clarification for the helpers in the `core`
namespace to create regular and async http clients.

Resolves #441
@serioga
Copy link

serioga commented Mar 14, 2018

@dakrone do you want me to check before releasing or clojars or I can wait for release?
The commit looks promising :-)

@dakrone
Copy link
Owner Author

dakrone commented Mar 14, 2018

@serioga if the commit looks like it will provide what you need that's good enough for me, it'll go out in the 3.9.0 release. I just released 3.8.0 though, so it may be a little bit before another release

@serioga
Copy link

serioga commented Mar 15, 2018

@dakrone architecturally it looks perfect 👍

@dakrone
Copy link
Owner Author

dakrone commented Mar 21, 2018

Excellent, it'll be in the next release then!

@aleksandersumowski
Copy link

Any timeline for 3.9 release?

I'd like to instrument my clj-http calls with X-Ray and I understand this feature would allow me to pass TracedHttpClient[1] to clj-http.

[1] https://github.com/aws/aws-xray-sdk-java/blob/master/aws-xray-recorder-sdk-apache-http/src/main/java/com/amazonaws/xray/proxies/apache/http/TracedHttpClient.java

@dakrone
Copy link
Owner Author

dakrone commented Apr 25, 2018

Hi @aleksandersumowski I would expect a 3.9 release sometime in the next week or so, would that work for you?

@aleksandersumowski
Copy link

yes, that would work. thanks a lot for great work!

@serioga
Copy link

serioga commented Oct 19, 2018

Hello @dakrone

Following example looks a little bit confusing about :connection-manager key usage:

;; You can also build your own, using clj-http's helper or manually building it:
(let [cm (conn/make-reusable-conn-manager {})
      hclient (core/build-http-client {} cm "https://example.com" false)]
  (client/get "http://example.com/1"
              {:connection-manager cm :http-client hclient})
  (client/get "http://example.com/2"
              {:connection-manager cm :http-client hclient})
  (client/get "http://example.com/3"
              {:connection-manager cm :http-client hclient}))

a. Should we really specify :connection-manager after using it in core/build-http-client?

b. What happened if we use one conn-manager instance in core/build-http-client but another one as :connection-manager key?

@serioga
Copy link

serioga commented Oct 20, 2018

ah, and parameter order is wrong in (core/build-http-client {} cm "https://example.com" false)

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants