Skip to content
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

Avoid name conflict with Web LocalStorage API #1

Closed
Jack-Works opened this issue May 22, 2020 · 3 comments
Closed

Avoid name conflict with Web LocalStorage API #1

Jack-Works opened this issue May 22, 2020 · 3 comments

Comments

@Jack-Works
Copy link
Member

Maybe AsyncContext? The name AsyncLocalStorage might let developers misunderstood it is the async version of localStorage.

@legendecas
Copy link
Member

legendecas commented May 27, 2020

The name of AsyncLocalStorage was proposed here by @puzpuzpuz.

AsyncLocal name doesn't meet with current API. In .NET it means a single variable available through async calls flow with analogy to ThreadLocal. Thus, it'll lead to users confusion.

So, I propose to call it AsyncLocalStorage, which seems to be a good fit for the API. WDYT?

The raised concern is that AsyncLocalStorage may not be analogous to AsyncLocal or ThreadLocal in cases. IIUC, either AsyncLocal in .NET or ThreadLocal doesn't mean they are single value store but there will be definitely single value visible in one particular context (an async context or thread context).

@puzpuzpuz may I have your opinion on this topic so that we can move forward on this?

@puzpuzpuz
Copy link

The raised concern is that AsyncLocalStorage may not be analogous to AsyncLocal or ThreadLocal in cases. IIUC, either AsyncLocal in .NET or ThreadLocal doesn't mean they are single value store but there will be definitely single value visible in one particular context (an async context or thread context).

Both ThreadLocal and AsyncLocal assume a single value per thread/async call chain. As there are usuay multiple threads and async chains, multiple values are associated with TL/AL simultaneously. So, that's correct.

Yet, their APIs are very simple and assume get()/set() methods which is different from getter and scoped run() method available in ALS. That's why AsyncLocal is a bad name for the API as it may lead to false associations.

On the other hand, ALS API was inspired by continuation-local-storage library which is the first popular Node.js user-land implementation of CLS API (hence, the CLS abbreviation). As the result, AsyncLocalStorage name is a hybrid of Continuation Local Storage and async_hooks, which also has a reference to AsyncLocal.

@puzpuzpuz may I have your opinion on this topic so that we can move forward on this?

As this discussion is wider than Node.js, I have no strong opinion. For me AsyncLocalStorage as the name gives more references than AsyncContext, but I may be biased here.

@legendecas
Copy link
Member

Thank you all for your ideas! Proposal text has been updated, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants