-
Notifications
You must be signed in to change notification settings - Fork 794
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
Port ok http client #4102
Conversation
There was a problem hiding this 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)) |
There was a problem hiding this comment.
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 delay
ed, at least.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]]] |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this 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.
No description provided.