dashbitco / nimble_pool

A tiny resource-pool implementation for Elixir
347 stars 20 forks source link

Feature request: checkout and checkin functions #31

Closed hissssst closed 8 months ago

hissssst commented 1 year ago

Overview

Sometimes checkout!/4 function does not suit the needs of a program which wants to manually check resource in and out. Functions like checkin/4 and checkout/3 can solve this problem

Example

You want to take a resource and create a Stream which returns the resource back upon completion With functions like checkin/3 and checkout/3 this would be possible

Stream.resource(
  fn -> NimblePool.checkout(pool, :checkout, timeout) end,
  fn resource -> get_part(resource) end,
  fn resource -> NimblePool.checkin(pool, :checkin, resource, timeout) end
)
josevalim commented 1 year ago

Yes, I understand this is a need but ensuring correct execution in such cases is much harder. At the moment, I don't intend to focus on this feature, and a pool like poolboy may be a better fit.

hissssst commented 1 year ago

@josevalim I can implement the feature if you agree on the design

josevalim commented 8 months ago

Closing as there was no progress on this for a year.