Closed isayme closed 5 years ago
nsid
is just an random, opaque value used to create a namespace. The underlying library cls-hooked
uses a string to create a namespace. I'm not sure what would happen if you passed a symbol. In any case, this library aims to abstract the internal cls-hooked
machinery. If you need more control over namespace IDs and such, you might want to consider consuming cls-hooked
directly.
Note that for other libraries that need access to the cls-hooked
namespace, it is available by doing:
var httpContext = require('express-http-context');
var namespace = httpContext.ns;
@skonves Thanks for your reply~
cls-hooked
internal use a object to keep the name
, a Symbol
as name is ok.
And if we use Symbol, no one will overwrite the namespace nsid
by accident.
However, the random, opaque value
is safe enough.
If we want a unique name for namespace, I would prefer a
Symbol
.