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

built-in Governor compositions #8

Open
michaelficarra opened this issue Oct 6, 2024 · 1 comment · May be fixed by #9
Open

built-in Governor compositions #8

michaelficarra opened this issue Oct 6, 2024 · 1 comment · May be fixed by #9

Comments

@michaelficarra
Copy link
Member

Sometimes you have a process that depends on more than one limited resource. If you're invoking the Governor protocol yourself, you can just do this with Promise.all. But if you're passing it to an API that expects a Governor parameter, you'd have to re-wrap it up using the Governor interface. Similarly, if you want it to be usable with using, you'd have to implement the Explicit Resource Management protocol. We should provide a Governor composition function Governor.all.

What I've described is a product operation. Would a sum operation also be useful? I imagine so but probably not anywhere near as commonly.

@michaelficarra
Copy link
Member Author

I think this could also help in avoiding deadlocks? If you have two consumers both trying to acquire 2 resources, each of them could acquire 1, preventing the other conumer from acquiring the other resource. If the 2 governors for the resources were composed first, they could avoid this deadlock.

@michaelficarra michaelficarra linked a pull request Oct 25, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant