ZPool

object ZPool
Companion:
class
class Object
trait Matchable
class Any
ZPool.type

Value members

Concrete methods

def fromIterable[A](iterable: => Iterable[A])(implicit trace: Trace): ZIO[Scope, Nothing, ZPool[Nothing, A]]

Creates a pool from a fixed number of pre-allocated items. This method should only be used when there is no cleanup or release operation associated with items in the pool. If cleanup or release is required, then the make constructor should be used instead.

Creates a pool from a fixed number of pre-allocated items. This method should only be used when there is no cleanup or release operation associated with items in the pool. If cleanup or release is required, then the make constructor should be used instead.

def make[R, E, A](get: => ZIO[R, E, A], size: => Int)(implicit trace: Trace): ZIO[R & Scope, Nothing, ZPool[E, A]]

Makes a new pool of the specified fixed size. The pool is returned in a Scope, which governs the lifetime of the pool. When the pool is shutdown because the Scope is closed, the individual items allocated by the pool will be released in some unspecified order.

Makes a new pool of the specified fixed size. The pool is returned in a Scope, which governs the lifetime of the pool. When the pool is shutdown because the Scope is closed, the individual items allocated by the pool will be released in some unspecified order.

def make[R, E, A](get: => ZIO[R, E, A], range: => Range, timeToLive: => Duration)(implicit trace: Trace): ZIO[R & Scope, Nothing, ZPool[E, A]]

Makes a new pool with the specified minimum and maximum sizes and time to live before a pool whose excess items are not being used will be shrunk down to the minimum size. The pool is returned in a Scope, which governs the lifetime of the pool. When the pool is shutdown because the Scope is used, the individual items allocated by the pool will be released in some unspecified order.

Makes a new pool with the specified minimum and maximum sizes and time to live before a pool whose excess items are not being used will be shrunk down to the minimum size. The pool is returned in a Scope, which governs the lifetime of the pool. When the pool is shutdown because the Scope is used, the individual items allocated by the pool will be released in some unspecified order.

ZIO.scoped {
 ZPool.make(acquireDbConnection, 10 to 20, 60.seconds).flatMap { pool =>
   ZIO.scoped {
     pool.get.flatMap {
       connection => useConnection(connection)
     }
   }
 }
}