Skip to content

Access task locals from asynchronous database accesses#1794

Merged
groue merged 21 commits intodevelopmentfrom
dev/actor-access
Jul 19, 2025
Merged

Access task locals from asynchronous database accesses#1794
groue merged 21 commits intodevelopmentfrom
dev/actor-access

Conversation

@groue
Copy link
Copy Markdown
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