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

Port ok http client #4102

Merged
merged 3 commits into from
Jan 2, 2021
Merged

Port ok http client #4102

merged 3 commits into from
Jan 2, 2021

Conversation

ashwinbhaskar
Copy link
Collaborator

No description provided.

Copy link
Member

@rossabaker rossabaker left a comment

Choose a reason for hiding this comment

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

This looks like a good start, but we'll want a CE3 expert as well.

@@ -89,12 +84,11 @@ sealed abstract class OkHttpBuilder[F[_]] private (
private def run(req: Request[F]) =
Resource.suspend(F.async[Resource[F, Response[F]]] { cb =>
okHttpClient.newCall(toOkHttpRequest(req)).enqueue(handler(cb))
()
F.delay(Option(F.unit))
Copy link
Member

Choose a reason for hiding this comment

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

This is really an F[Option[F[Unit]]?

It looks pure instead of delayed, at least.

Copy link
Member

Choose a reason for hiding this comment

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

The easiest way to migrate old uncancelable async code, is to use async_ , which has the same signature of the old async. The old code didn't shift back after async, whereas with ce3 it will, fyi.

extends BackendBuilder[F, Client[F]] {
private[this] val logger = getLogger

private def invokeCallback[F[_]](logger: Logger)(f: => Unit)(implicit
F: Sync[F]): Unit =
F.blocking(f).unsafeRunSync
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a Dispatcher floating around that I don't see? Also does this need to be blocking?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added the dispatcher and made a few changes.

Copy link
Member

@rossabaker rossabaker left a comment

Choose a reason for hiding this comment

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

This is looking good to me. Let's see if the CE3 people see anything else.

*
* @define WHYNOSHUTDOWN It is assumed that the OkHttp client is
* passed to us as a Resource, or that the caller will shut it down, or
* that the caller is comfortable letting OkHttp's resources expire on
* their own.
*
* @param okHttpClient the underlying OkHttp client.
* @param blockingExecutionContext $BLOCKINGEC
* @param dispatcher $BLOCKINGEC
Copy link
Member

Choose a reason for hiding this comment

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

I think the reference needs to be changed to $DISPATCHER here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

extends BackendBuilder[F, Client[F]] {
private[this] val logger = getLogger

type Result[F[_]] = Either[Throwable, Resource[F, Response[F]]]
Copy link
Member

Choose a reason for hiding this comment

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

Can this alias be private to reduce API liability?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@ashwinbhaskar ashwinbhaskar changed the title WIP Port ok http client Port ok http client Dec 31, 2020
Copy link
Member

@rossabaker rossabaker left a comment

Choose a reason for hiding this comment

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

This looks good to me.

@rossabaker rossabaker merged commit a7e820c into http4s:cats-effect-3 Jan 2, 2021
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.

4 participants