-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Anonymous namespaces #52
Comments
Since the point of CLS is to communicate across components in the same way that thread-local storage does (where the lookup is based on the thread itself), because it's not safe to assume that you're the only user of CLS within a given application, and because some applications of CLS do fancy things with the namespaces they create, the API requires that you give each namespace a name. It doesn't require it to be a good name – I've seen a lot of people simply using 'ns' or 'namespace' – but it does have to be there. I'd be happy to land a patch that documents the motivation for the requirement, but I think adding a namespace name generator is superfluous, given that it's very rare that any application would need to generate more than a small handful of namespaces (which is good, because each one gets its own |
That would be the wrong approach. The intention would be to be able to treat a CLS as anonymous/unnamed. You would only be able to access a particular CLS pool if you had a reference to its defining object. See the following behavior for comparing object references. I am able to determine if two handles are the same or not without having to name them. I’d like the same behavior from continuation-local-storage:
Why must I come up with a string to identify a namespace? Naming things should only be necessary when trying to do something like IPC or when defining an interface that needs to be decoupled (such as look for a JSON key named X or pass a GET parameter Y). It shouldn’t be necessary when all parties needing to cooperate can exchange object references… |
Just to clarify, I would implement this with |
Hi, I’m looking into using Sequelize’s continuation-local-storage support. I don’t want to have to decide on a name for the namespace because I don’t like coming up with names and I would probably choose something stupid and generic which might conflict with code which I haven’t written.
I have no need to ever call
getNamespace()
. I can access the return value ofcreateNamespace()
from all code where the README would suggest I should callgetNamespace()
, so what’s the point of that function when I have an object reference available?I would like to be able to something like the following to get automatic transaction binding through Promise chains whenever I use the
sequelize
object:but this fails with
AssertionError: namespace must be given a name!
thrown by [email protected]. I don’t get it—what insurmountable technical obstacle to supporting anonymous namespaces requires me to use a name here? Could that be documented along with a workaround (i.e., a way reliably generate unique namespace names) if it isn’t going to be fixed?The text was updated successfully, but these errors were encountered: