Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/davidgregory084/pool
A generic resource pooling library for Scala
https://github.com/davidgregory084/pool
connection-pool connection-pooling monix pool pooling scala
Last synced: 16 days ago
JSON representation
A generic resource pooling library for Scala
- Host: GitHub
- URL: https://github.com/davidgregory084/pool
- Owner: DavidGregory084
- License: apache-2.0
- Created: 2017-08-25T12:15:44.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-09-06T01:10:36.000Z (over 7 years ago)
- Last Synced: 2024-10-30T04:29:02.341Z (2 months ago)
- Topics: connection-pool, connection-pooling, monix, pool, pooling, scala
- Language: Scala
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## pool
**pool** is a Scala port of Bryan O'Sullivan's excellent Haskell resource-pooling library [bos/pool](https://github.com/bos/pool).
**pool** makes extensive use of the facilities provided by the [Monix](https://monix.io/) library.
### Example
```scala
implicit val scheduler = Scheduler.io(
name = "pool-test",
reporter = UncaughtExceptionReporter(
logger.error(s"pool-test: Uncaught exception in IO scheduler", _)))// Run a `Pool[Unit] => Task[Unit]`
val usePool = Pool.withPool[Unit, Unit](
name = "test",
create = Task.eval(logger.info("Creating entry")),
destroy = a => Task.eval(logger.info(s"Destroying entry $a")),
minIdle = 5,
maxEntries = 10,
idleTimeout = 60.seconds,
creatorDelay = 1.second,
creatorInterval = 1.second,
reaperDelay = 1.second,
reaperInterval = 1.second
) { pool =>pool.withResource(a => Task.fork(Task.eval(Thread.sleep(5000))))
}Await.result(usePool.runAsync, Duration.Inf)
```