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

Refactor client into algebra #2102

Merged
merged 11 commits into from Sep 27, 2018

Conversation

Projects
None yet
4 participants
@rossabaker
Member

rossabaker commented Sep 22, 2018

  • DisposableResponse is gone
  • Client is a trait with no concrete methods
  • DefaultClient implements them all in terms of a run: Request[F] => Resource[F, Response[F]]
  • Client no longer has a shutdown: we create clients as Resources.
@rossabaker

Note that almost every middleware is expressed in terms of client.run on the wrapped client. That means that even if we do override a method for efficiency, the override will be lost as soon as it's wrapped. This may be an argument for the original final class Client[F](run: Request => F[Response[F]]) encoding.

def go[A](r: Resource[F, A]): F[(A, F[Unit])] = r match {
case Resource.Allocate(r) =>
r.map { case (a, release) => (a, release(ExitCase.Completed)) }
case Resource.Bind(r, f) =>

This comment has been minimized.

@rossabaker

rossabaker Sep 22, 2018

Member

I am sleepy and this feels dangerous. Please be extra careful reviewing this.

This comment has been minimized.

@ChristopherDavenport

This comment has been minimized.

@rossabaker

rossabaker Sep 24, 2018

Member

It probably pays to go back and understand why Resource has this ADT instead of being a wrapper around Allocate's value, because we're basically reconstructing that.

(This is also a suggestion for myself.)

This comment has been minimized.

@rossabaker

rossabaker added some commits Sep 22, 2018

@rossabaker

This comment has been minimized.

Member

rossabaker commented Sep 22, 2018

I have not tried the metrics, I have only compiled them.

This is going to cause a merge conflict with #2094, so we need to give one of them the right of way.

@rossabaker

The diff is a little smaller if you ignore whitespace.

@rossabaker rossabaker modified the milestones: 0.19.0-M3, 0.19.0 Sep 23, 2018

@rossabaker

This comment has been minimized.

Member

rossabaker commented Sep 23, 2018

Similar to, and supersedes, #1772.

@aeons

Looks good. DisposableResponse never really tasted right :)

rossabaker added some commits Sep 26, 2018

Significantly changed toHttpApp

@rossabaker rossabaker requested a review from SystemFw Sep 26, 2018

@rossabaker rossabaker modified the milestones: 0.19.0, 0.19.0-M3 Sep 26, 2018

case (a, rel) =>
stack match {
case Nil => F.pure(a -> release.guarantee(rel(ExitCase.Completed)))
case f0 :: xs => continue(f0(a), xs, release.guarantee(rel(ExitCase.Completed)))

This comment has been minimized.

@rossabaker

rossabaker Sep 26, 2018

Member

We release in reverse order, so I think these guarantees are both backward? We don't yet have a test that exposes this.

@rossabaker rossabaker referenced this pull request Sep 27, 2018

Merged

Release v0.19.0-M3 #2125

3 of 4 tasks complete

@aeons aeons merged commit 18a7520 into http4s:master Sep 27, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

aeons added a commit that referenced this pull request Sep 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment