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

@ChristopherDavenport ChristopherDavenport 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
Copy link
Member

@rossabaker rossabaker left a comment

Looks good, one dumb question.

Loading

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))
Copy link
Member

@rossabaker rossabaker Aug 9, 2019

Choose a reason for hiding this comment

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

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?

Loading

Copy link
Member Author

@ChristopherDavenport ChristopherDavenport Aug 9, 2019

Choose a reason for hiding this comment

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

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

Loading

@ChristopherDavenport ChristopherDavenport merged commit 3b72e74 into http4s:series/0.20 Aug 11, 2019
2 checks passed
Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants