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

Adding docs on using tokio task_local to share state #2769

Merged
merged 2 commits into from
Aug 13, 2024

Conversation

Gaelik-git
Copy link
Contributor

I stumbled upon this discussion for using tokio task_local to share state between handlers and middleware.

Is it okay to add some docs, would you prefer to have some test or example to show the behaviour ?

@Gaelik-git Gaelik-git force-pushed the blm/adding_docs_on_task_local_usage branch 3 times, most recently from 8ae5f21 to b2fea34 Compare June 5, 2024 09:46
Copy link
Member

@jplatte jplatte left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I think it makes sense to showcase this in the docs, but in addition to the small improvement suggestions below, there are two more general things:

  • I think this documentation belongs in the main documentation, in the "Sharing state with handlers" section
  • To me, the real important aspect about this is that unlike other state sharing mechanisms, this one actually also works to share state with IntoResponse impls; I think the docs should call this out

axum/src/docs/middleware.md Outdated Show resolved Hide resolved
axum/src/docs/middleware.md Outdated Show resolved Hide resolved
axum/src/docs/middleware.md Outdated Show resolved Hide resolved
@jplatte
Copy link
Member

jplatte commented Aug 9, 2024

Hey @Gaelik-git, are you still interested in getting back to this?

@Gaelik-git Gaelik-git force-pushed the blm/adding_docs_on_task_local_usage branch from b2fea34 to fd15ff5 Compare August 12, 2024 17:05
@Gaelik-git
Copy link
Contributor Author

Gaelik-git commented Aug 12, 2024

Yep sorry for the late response, I moved and modified the example for it to include the IntoReponse implementation
But my example does not make much sense though, devs will still get the point I think but if you have other suggestion do not hesitate

@Gaelik-git Gaelik-git force-pushed the blm/adding_docs_on_task_local_usage branch from fd15ff5 to 442f658 Compare August 12, 2024 17:09
@Gaelik-git Gaelik-git force-pushed the blm/adding_docs_on_task_local_usage branch from 442f658 to dee22b9 Compare August 12, 2024 17:17
Copy link
Member

@jplatte jplatte left a comment

Choose a reason for hiding this comment

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

Thanks again!

axum/src/lib.rs Outdated Show resolved Hide resolved
axum/src/lib.rs Outdated Show resolved Hide resolved
@jplatte jplatte enabled auto-merge (squash) August 13, 2024 21:41
@jplatte jplatte merged commit 35c6f11 into tokio-rs:main Aug 13, 2024
18 checks passed
@Gaelik-git Gaelik-git deleted the blm/adding_docs_on_task_local_usage branch August 14, 2024 09:56
@Gaelik-git
Copy link
Contributor Author

glad I could contribute

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.

2 participants