-
Notifications
You must be signed in to change notification settings - Fork 0
Description
There was mention at the November 2025 plenary of the possibility of accepting an optional (somewhat free-form) argument to acquire. This argument could be used to specify priority (cf. #11) or anything else.
Exploring a little further below:
Obviously since the details would be specific to individual Governor implementations, there's a whole can of worms making sure the correct type of argument is passed. TypeScript might want to parametrize the type to enforce correct usage, though that would likely get messy pretty quickly and it's not clear (to me) that it's worth the ugliness.
Making the argument optional is a good start to at least clear up some built-in APIs to not need to worry about parameters. In the case where someone wants to ensure that (e.g.) an async iterator helper consistently passes a certain argument to all its governor.acquire calls, I see two reasonable approaches: (1) add an additional extra argument to all helper calls, which (if Governor is a parametrized type), would make the type signatures of these helpers even worse, or (2) provide a convenient combinator to wrap a parametrized Governor into a nullary instance that always passes a given parameter to the underlying instance, e.g. asyncIter.map(fn, priorityGovernor.withParam(1)). I prefer the second option since it keeps the complex type parameters more cleanly separated.