Interface ContextManager<Context>

Context manager interface

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

interface ContextManager<Context> {
    active(): Context;
    fromMetadata(activeContext, metadata): Context;
    getMetadata(context): string;
    with<A>(context, fn): ReturnType<A>;
}

Type Parameters

  • Context = any

Methods

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

    Parameters

    • activeContext: Context
    • metadata: string

    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

    Returns string

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

    Type Parameters

    • A extends ((...args) => any)

    Parameters

    Returns ReturnType<A>

Generated using TypeDoc