bullmq - v5.52.2
    Preparing search index...

    Interface ContextManager<Context>

    Context manager interface

    The context manager is responsible for managing the context and propagating it across the application.

    interface ContextManager<Context = any> {
        active(): Context;
        fromMetadata(activeContext: Context, metadata: string): Context;
        getMetadata(context: Context): string;
        with<A extends (...args: any[]) => any>(
            context: Context,
            fn: A,
        ): ReturnType<A>;
    }

    Type Parameters

    • Context = any
    Index

    Methods

    • Creates a new context from a serialized version effectively linking the new context to the parent context.

      Parameters

      • activeContext: Context

        the current active context

      • metadata: string

        the serialized version of the context

      Returns Context

    • Returns a serialized version of the current context. The metadata is the mechanism used to propagate the context across a distributed application.

      Parameters

      • context: Context

        the current context

      Returns string

    • Creates a new context and sets it as active for the fn passed as last argument

      Type Parameters

      • A extends (...args: any[]) => any

      Parameters

      • context: Context

        the context to set as active

      • fn: A

        the function to execute with the context

      Returns ReturnType<A>