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

Add Coldswap class to manage concurrent resource access #53

Closed
istreeter opened this issue Jan 6, 2024 · 0 comments
Closed

Add Coldswap class to manage concurrent resource access #53

istreeter opened this issue Jan 6, 2024 · 0 comments

Comments

@istreeter
Copy link
Contributor

In some of our applications, it is helpful to close and re-open a resource during event processing. For example, in a warehouse loader we might need to close the event-loading channel while we alter the warehouse table to add a new column.

Cats Effect offers a Hotswap which manages a sequence of resources, and runs the resource finalizers in case of cancellation or error. However, it's not quite what we need, because a Hotswap.get returns a Resource[F, Option[R]] whereas we typically need it to return a Resource[F, R]. And because sometimes we need to guarantee that no Resource is opened for the duration of an IO -- A Hotswap has nothing to help with this.

We need our own resource manager... let's call it a Coldswap. We call it "cold" because (unlike a Hotswap) it always closes any previous Resources before acquiring the next one.

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

1 participant