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

[RFC] feat: scoped requests #3229

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jgranstrom
Copy link
Contributor

@jgranstrom jgranstrom commented Dec 3, 2024

/fixes #3197
/claim #3197

RFC Adds support for per-request Scopes at server level.

Adds the ability to run a server that provides a scope for each request. This is to not add any overhead or overly complicate the existing path that does not provide request-bound scopes.

I have not added tests or similar yet as I need some feedback on the idea of this as a solution first.
(Edit: also only implemented with the Netty driver for the above reason)

Copy link

algora-pbc bot commented Dec 3, 2024

💵 To receive payouts, sign up on Algora, link your Github account and connect with Stripe.

@jgranstrom jgranstrom force-pushed the feat-scoped-requests branch from 375bc68 to a8df79e Compare December 3, 2024 16:26
@jgranstrom jgranstrom changed the title feat: scoped requests [RFC] feat: scoped requests Dec 3, 2024
@jgranstrom jgranstrom force-pushed the feat-scoped-requests branch from a8df79e to 87329b7 Compare December 4, 2024 06:12
handler.apply
case Right(scopedHandler) =>
val handler = scopedHandler.toHandler
(req: Request) => ZIO.scoped(handler(req))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@guersam
Copy link
Contributor

guersam commented Dec 9, 2024

Thanks for tackling this issue! My two cents:

I think the Scope env could be resolved by the handler via something like Handler.scoped. It reflects the locality of each scope more precisely by not leaking the requirement, and it's more consistent with ZLayer.scoped.

@jgranstrom
Copy link
Contributor Author

Thanks for tackling this issue! My two cents:

I think the Scope env could be resolved by the handler via something like Handler.scoped. It reflects the locality of each scope more precisely by not leaking the requirement, and it's more consistent with ZLayer.scoped.

Yeah I went with that initially but it gets fairly convoluted to thread that through everything, so I thought of a less invasive option to just fork it top-level, but also agree that it would be cleaner for the outside to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants