Closed Jack-Works closed 4 years ago
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?
The raised concern is that
AsyncLocalStorage
may not be analogous toAsyncLocal
orThreadLocal
in cases. IIUC, eitherAsyncLocal
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.
Thank you all for your ideas! Proposal text has been updated, closing.
Maybe
AsyncContext
? The nameAsyncLocalStorage
might let developers misunderstood it is the async version of localStorage.