Skip to content

Access task locals from asynchronous database accesses #1794

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

Merged
merged 21 commits into from
Jul 19, 2025

Conversation

groue
Copy link
Owner

@groue groue commented Jul 17, 2025

As discussed in #1793, users want to access task locals from within async database accesses. This PR aims at fulfilling this feature request.

let dbQueue = try DatabaseQueue()

@TaskLocal var myLocal = 0
try await $myLocal.withValue(42) {
  try await dbQueue.read { db in
    print(myLocal) // prints 42
  }
}

@groue groue force-pushed the dev/actor-access branch 2 times, most recently from 257dce1 to ff1566b Compare July 19, 2025 09:41
@groue groue force-pushed the dev/actor-access branch 2 times, most recently from 9eb4cec to 2184cf6 Compare July 19, 2025 13:04
@groue groue force-pushed the dev/actor-access branch from 2184cf6 to 7a1e65b Compare July 19, 2025 13:29
@groue groue merged commit 3f928bc into development Jul 19, 2025
8 checks passed
@groue groue deleted the dev/actor-access branch July 19, 2025 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant