cls-q
Make your promises play nice with the continuation-local-storage module.
Last updated 7 years ago by othiym23 .
BSD-2-Clause · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install cls-q 
SYNC missed versions from official npm registry.

patch Q to work better with continuation-local storage

Certain kinds of asynchronous operations don't play nicely with Q and continuation-local storage. This shim was put together to make CLS and Q work better with node-redis; there may be other modules that are doing funky things with asynchronous execution that require it. All it does is bind callbacks passed to promise.then so that the active CLS contexts at the time then() was called are correctly set.

It only binds to one namespace at a time:

var cls = require('continuation-local-storage');
var ns = cls.createNamespace('NODESPACE');

var Q = require('q');

// load shim
var patchQ = require('cls-q');
patchQ(ns);

You can bind to more than one, but the overhead of doing so will start to add up quickly.

tests

The tests assume a Redis server is up and running on localhost on the standard port. Work is underway to find a test case that doesn't require any external dependencies.

Current Tags

  • 1.1.0                                ...           latest (7 years ago)

3 Versions

  • 1.1.0                                ...           7 years ago
  • 1.0.1                                ...           7 years ago
  • 1.0.0                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 5
Dependencies (1)
Dev Dependencies (2)

Copyright 2014 - 2016 © taobao.org |