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

Add .resourceUsingClient to HttpClient backends. #1619

Merged
merged 3 commits into from
Nov 15, 2022

Conversation

kamilkloch
Copy link
Contributor

Rationale:
I am trying to migrate away from the deprecated AsyncHttpClientFs2Backend and am struggling to reproduce the functionality with

.
HttpClientFs2Backend.resource has a default http client baked in, HttpClientFs2Backend.usingClient has hard-coded flag closeClient = false. I am missing something akin to HttpClientFs2Backend.resourceUsingClient, which would allow me to customize the client and at the same time get back the resource.

@adamw
Copy link
Member

adamw commented Nov 8, 2022

Sure, sounds good :) Maybe we could add similar methods to other HttpClient backend variants (where it makes sense)

@kamilkloch
Copy link
Contributor Author

I added methods to 2 other client variants. Surprisingly, ZIO backend already contains HttpClientZioBackend.layerUsingClient, but its implementation calls usingClient, which sets closeClient flag to false. Is that the desired behavior? (HttpClientZioBackend.layer sets the flag to true).

@adamw
Copy link
Member

adamw commented Nov 15, 2022

@kamilkloch Yes, in ZIO the equivalent would be scopedUsingClient. A layer is just a description of how to create an object, lifted into ZIO-land. Scope is ZIO's Resource, where closing happens.

@kamilkloch
Copy link
Contributor Author

kamilkloch commented Nov 15, 2022

@adamw I understand. However, the flag closeClient is flipped (Scope vs Resource). Why is that?
My bad, now I see (scope vs layer)

@kamilkloch kamilkloch changed the title Add HttpClientFs2Backend.resourceUsingClient. Add .resourceUsingClient to HttpClient backends. Nov 15, 2022
@adamw adamw marked this pull request as ready for review November 15, 2022 19:31
@adamw adamw merged commit 1d09e8b into softwaremill:master Nov 15, 2022
@adamw
Copy link
Member

adamw commented Nov 15, 2022

Thank you :)

@kamilkloch
Copy link
Contributor Author

Do we want to update the documentstion as well, or leave out this flavor?

@adamw
Copy link
Member

adamw commented Nov 16, 2022

Ah the docs - yes of course :)

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.

None yet

2 participants