Skip to content

Propagate user thread locals into thenEventually/thenContinually coroutine dispatches #220

Description

@paul-brooks

Checks inside thenEventually { } / thenContinually { } run on Dispatchers.IO, so user-owned ThreadLocals (e.g. a tracking id holder) are unset there. KensaThreadContextElement only carries Kensa's own contexts and there is no extension point.

Add withCoroutineContextProviders(vararg providers: () -> CoroutineContext) to KensaConfigurator. kensaThreadContext() invokes each provider on the test thread and folds the elements into the polling context, so ThreadLocal.asContextElement() captures the current value at poll start.

Kensa.configure().withCoroutineContextProviders(TrackingContext::asContextElement)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions