Skip to content

Commit

Permalink
add example to README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
t3hnar committed Sep 18, 2023
1 parent 6973f36 commit 4492811
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,31 @@ Pool of cats-effect resources
* shuts down gracefully after completing accumulated tasks
* tolerates resource failures

## Example

```scala
import com.evolution.resourcepool.ResourcePool.implicits._

trait Connection {
def query(any: Any): IO[Any]
}

def connection: Resource[IO, Connection] = ???

connection
.toResourcePool( // you can convert any resource into the pool of resources
maxSize = 10, // it will create up to `maxSize` connections
expireAfter = 1.minute) // pool will release connection if it is not used for 1 minute
.use { connectionPool =>
connectionPool
.resource // this will get first available connection and there after release it when done
.use { connection =>
connection.query() // here you have access to the connection
}
}

```

## Setup

```scala
Expand Down

0 comments on commit 4492811

Please sign in to comment.