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 MaxActiveRequest middleware #2776

Conversation

@ChristopherDavenport
Copy link
Member

commented Aug 8, 2019

Initial Code for a MaxActiveRequest middleware. That will immediately return the default response if all requests allowed are currently active.

Can get test code up tommorow.

@ChristopherDavenport ChristopherDavenport marked this pull request as ready for review Aug 9, 2019

@rossabaker
Copy link
Member

left a comment

Looks good, one dumb question.

Kleisli{a: Request[F] =>
Concurrent[OptionT[F, ?]].bracketCase(OptionT.liftF(sem.tryAcquire)){ bool =>
if (bool) http.run(a).map(resp => resp.copy(body = resp.body.onFinalize(sem.release)))
.orElseF(sem.release.as(None))

This comment has been minimized.

Copy link
@rossabaker

rossabaker Aug 9, 2019

Member

I'm getting to the stupid hours early today. Is there not something with ~> that DRYs up the two big implementations? Is this .as(None) indicative of the problem?

This comment has been minimized.

Copy link
@ChristopherDavenport

ChristopherDavenport Aug 9, 2019

Author Member

Exactly. The problem is we need to release on the None case specifically if we know its OptionT. So if we make it generic we would need OptionT[F, ?] ~> F which is not a transformation we can provide and get the correct semantics

@ChristopherDavenport ChristopherDavenport merged commit 3b72e74 into http4s:series/0.20 Aug 11, 2019

2 checks passed

Summary no rules match, no planned actions
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.