Manual checkouts and checkins of resources
Current implementation do not provide manual control over checkins and checkouts of the resources, which could be helpful in some situations where resource is checked out for longer periods (for example process lifetime).
Hi 👋🏻
Please provide an example of where it might be needed.
Now, in my opinion, you can use run in every case instead of checkout / checkin.
Unfortunately, I cannot. The thing is that I am working on DB pooler similar to the pgBouncer. There I am checking out the DB connection for a duration of TCP connection, which mean that I am checking out a connection at the start of the connection and I keep it open for the whole lifetime of the process. There is no single function call that I can wrap in run nor I cannot wrap each query independently, because I need to reuse the same connection for the duration of the whole connection (and that connection must be checked out for sole use of this process).
There are other use cases that I can think of, but in general - long checkouts that are happening in GenServer or gen_statem processes are the situation where "manual checkouts" are must-have.
Thank you very much for this example! I need some time to think about it.
In other words, if we don't speak about implementation with "checkin" and "checkout", you need to have a guarantee that the current process will take the same worker from the pool, right?
Yes, but at the same time I need to ensure that no one else will checkout that process in the meantime. Which in the end means exactly the same thing as manual checkouts.
Okay, I understood 👍