1.1.0 • Published 2 years ago

@totalsoft/correlation v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

correlation

This package provides core correlation functionality. The correlation manager allows opening a correlation scope that is propagated across async/await calls.

Installation

npm i @totalsoft/correlation

or

yarn add @totalsoft/correlation

Usage

import { correlationManager } from '@totalsoft/correlation'

// Open a correlation scope and set a correlation id. Set the correlation id to null to use an auto-generated one.
correlationManager.useCorrelationId('b48f6511-2f45-46c8-b9a5-655856712f32', async () => {
    await inner()
})

// function that uses the correlation id from the context
async function inner() {
    const correlationId = correlationManager.getCorrelationId()
}