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

Use zio-http Client instead of sttp3 #691

Merged
merged 5 commits into from
May 23, 2023

Conversation

IvanFinochenko
Copy link
Contributor

No description provided.

@IvanFinochenko IvanFinochenko requested a review from a team as a code owner May 23, 2023 11:17
@IvanFinochenko
Copy link
Contributor Author

ISSUE #687

@grouzen
Copy link
Contributor

grouzen commented May 23, 2023

Hey! Thanks for this amazing contribution! Gonna review it soon.

package object example {

type Backend = SttpBackend[Task, ZioStreams with WebSockets]
type Backend = zio.http.Client
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this one is redundant now. We needed this type alias before to hide the complexity of SttpBackend type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

ZLayer.scoped {
ZIO.acquireRelease(AsyncHttpClientZioBackend())(_.close().ignore)
}
private val httpBackendLayer: TaskLayer[Backend] = zio.http.Client.default
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as in opentelemetry:

I don't think we need this extra variable here anymore, it would be better to pass ZClient.default directly into .provide

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Comment on lines 26 to 28
status <- JsonDecoder[Status]
.decodeJsonStream(response.body.asStream.map(_.toChar))
.catchAll(_ => ZIO.succeed(Status.down("backend")))
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

package object example {

type Backend = SttpBackend[Task, ZioStreams with WebSockets]
type Backend = zio.http.Client
Copy link
Contributor

Choose a reason for hiding this comment

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

Same redundant type alias.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@grouzen
Copy link
Contributor

grouzen commented May 23, 2023

Overall, LGTM! Just a few minor comments to address!

It would be great to make sure that examples are working by following the instructions in the corresponding doc pages:

Thanks!

.safeApply(config.backend.host, config.backend.port)
.map(_.withPath("status"))
URL
.decode(s"http://${config.backend.host}/${config.backend.port}")
Copy link
Contributor

Choose a reason for hiding this comment

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

.decode(s"http://${config.backend.host}/${config.backend.port}")

Should be changed to (semicolon between host and port instead of a slash):

.decode(s"http://${config.backend.host}:${config.backend.port}")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

)
status = response.body.getOrElse(Status.down("backend"))
request = Request
.get(url)
Copy link
Contributor

Choose a reason for hiding this comment

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

url is missing the path:
.get(url.withPath("status"))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

)
status = response.body.getOrElse(Status.down("backend"))
request = Request
.get(url)
Copy link
Contributor

Choose a reason for hiding this comment

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

url is missing the path:
.get(url.withPath("status"))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@IvanFinochenko
Copy link
Contributor Author

I have tested opentelemetry example

image image

@IvanFinochenko
Copy link
Contributor Author

And I have tested opentracing. Also it correct works.

@IvanFinochenko
Copy link
Contributor Author

IvanFinochenko commented May 23, 2023

And I added zio http client to opentelemetry-instrumentation-example

@@ -67,7 +68,7 @@ object Dependencies {
Orgs.jaegertracing % "jaeger-client" % ExampleVersions.jaeger,
Orgs.jaegertracing % "jaeger-zipkin" % ExampleVersions.jaeger,
Orgs.softwaremillSttpClient3 %% "zio-json" % ExampleVersions.sttp3,
Orgs.d11 %% "zhttp" % ExampleVersions.zioHttp,
Orgs.d11 %% "zhttp" % ExampleVersions.zHttp,
Copy link
Contributor

Choose a reason for hiding this comment

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

I do believe we don't need this one anymore since we have just added a zio-http.

Copy link
Contributor

@grouzen grouzen left a comment

Choose a reason for hiding this comment

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

LGTM!

@grouzen grouzen linked an issue May 23, 2023 that may be closed by this pull request
3 tasks
@grouzen grouzen merged commit 6b197fd into zio:series/2.x May 23, 2023
16 checks passed
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.

Use zio-http Client instead of sttp3 one in examples
2 participants