Skip to content

Add SetTaskLocal service + layer #821

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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jplatte
Copy link
Contributor

@jplatte jplatte commented Apr 23, 2025

This allows sharing state if the request and response types don't have a mechanism for that like https request extensions. It's also slightly more type-safe way than request extensions¹.

This could certainly use some more docs, though I'm really not good at writing docs. Maybe just an example would be sufficient?

Also if you want I can add this to ServiceBuilder as well. I don't know how well in sync ServiceBuilder and ServiceExt are right now, and personally I would probably use the Layer directly but definitely never ServiceBuilder 🤷🏼

¹ can't accidentally have code adding Arc<Foo> as an extension, and some other code that tries to access just Foo; can still try to access state that's not available (due to the layer being applied in the wrong place / conditionally / not at all)

@jplatte jplatte marked this pull request as ready for review April 23, 2025 20:27
… and make it pass in a stupid way.
@jplatte jplatte marked this pull request as draft April 23, 2025 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant