How to use the async_hooks.createHook function in async_hooks

To help you get started, we’ve selected a few async_hooks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thlorenz / hookup / exercises / 02-init.timer-enable-late.js View on Github external
const asyncHooks = require('async_hooks')
const print = require('../lib/print')

function init(id, type, triggerAsyncId, resource) {
  print({ stage: 'init', id, type, triggerAsyncId })
}

const hook = asyncHooks.createHook({ init })
setTimeout(() => {}, 10)

// TODO:
// Here we don't see anything printed. Do you know why?
hook.enable()
github bmeurer / async-hooks-performance-impact / async-hook-init.js View on Github external
const async_hooks = require('async_hooks');
const hook = async_hooks.createHook({
    init(asyncId, type, triggerAsyncId) { }
});
hook.enable();
github guyguyon / node-request-context / index.js View on Github external
function createHooks(namespace) {
    function init(asyncId, type, triggerId, resource) {
        if (namespace.context[triggerId]) {
            namespace.context[asyncId] = namespace.context[triggerId];
        }
    }

    function destroy(asyncId) {
        delete namespace.context[asyncId];
    }

    const asyncHook = asyncHooks.createHook({ init, destroy });

    asyncHook.enable();
}
github atomist / automation-client / lib / internal / util / cls.ts View on Github external
function createHooks(nsp: Namespace): void {
    function init(asyncId, type, triggerId, resource) {
        if (nsp.context[triggerId]) {
            nsp.context[asyncId] = nsp.context[triggerId];
        }
    }

    function destroy(asyncId): void {
        delete nsp.context[asyncId];
    }

    const asyncHook = asyncHooks.createHook({ init, destroy });

    asyncHook.enable();
}
github moleculerjs / moleculer / src / async-storage.js View on Github external
constructor(broker) {
		this.broker = broker;

		this.hook = asyncHooks.createHook({
			init: this._init.bind(this),
			//before: this._before.bind(this),
			//after: this._after.bind(this),
			destroy: this._destroy.bind(this),
			promiseResolve: this._destroy.bind(this)
		});

		this.executionAsyncId = executionAsyncId;

		this.store = new Map();
	}

async_hooks

squat for node core module

Unknown
Latest version published 8 years ago

Package Health Score

39 / 100
Full package analysis

Similar packages