Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions book/pool.nim
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ Norm offers a simple thread-safe connection pool implementation. It can be used
**Important** Connection pooling requires `--mm:orc`.

To use connection pool:
1. create a [`Pool`](/apidocs/norm/pool.html#Pool) instance by calling [`newPool`](/apidocs/norm/pool.html#newPool,Positive)
2. wrap your DB calls in a [`withDb`](/apidocs/norm/pool.html#withDb.t,Pool,untyped)
1. create a [`Pool`](/norm/apidocs/norm/pool.html#Pool) instance by calling [`newPool`](/norm/apidocs/norm/pool.html#newPool,Positive)
2. wrap your DB calls in a [`withDb`](/norm/apidocs/norm/pool.html#withDb.t,Pool,untyped)

`newPool` creates a pool of a given size with connections of type `DbConn` (either from [`sqlite`](/apidocs/norm/sqlite.html) or [`postgres`](/apidocs/norm/postgres.html)). The params for the connections are taken from the environment, similar to how `withDb` works (see [Configuration from Environment](/config.html)).
`newPool` creates a pool of a given size with connections of type `DbConn` (either from [`sqlite`](/norm/apidocs/norm/sqlite.html) or [`postgres`](/norm/apidocs/norm/postgres.html)). The params for the connections are taken from the environment, similar to how `withDb` works (see [Configuration from Environment](/config.html)).
"""

nbCode:
Expand Down Expand Up @@ -48,19 +48,19 @@ nbText: """
If the app requests more connections from the pool than it can give, we say the pool is exhausted.

There are two ways a pool can react to that:
1. raise a [`PoolExhaustedError`](/apidocs/norm/pool.html#PoolExhaustedError); this is the default policy
1. raise a [`PoolExhaustedError`](/norm/apidocs/norm/pool.html#PoolExhaustedError); this is the default policy
2. open an additional connection and extend the pool size

The policy is set during the pool creation by setting `poolExhaustedPolicy` param to either `pepRaise` or `pepExtend`.

To reset the pool back to its default size after it has been extended, call [`reset`](/apidocs/norm/pool.html#reset,Pool) proc on it.
To reset the pool back to its default size after it has been extended, call [`reset`](/norm/apidocs/norm/pool.html#reset,Pool) proc on it.


## Manual Pool Manipulation

You can borrow connections from the pool manually by calling [`pop`](/apidocs/norm/pool.html#add%2CPool%2CT) proc.
You can borrow connections from the pool manually by calling [`pop`](/norm/apidocs/norm/pool.html#add%2CPool%2CT) proc.

**Important** If you choose to get connections from the pool manually, you must care about putting the borrowed connections back byb calling [`add`](/apidocs/norm/pool.html#add,Pool,T).
**Important** If you choose to get connections from the pool manually, you must care about putting the borrowed connections back byb calling [`add`](/norm/apidocs/norm/pool.html#add,Pool,T).
"""

nbCode:
Expand All @@ -78,7 +78,7 @@ nbCode:
nbText: """
## Closing the Pool

When you no longer need the pool, for example, when your app exits or crashes, to avoid leaving hanging connections, close the pool by calling [`close`](/apidocs/norm/pool.html#close,Pool). This proc closes all connections in the pool and sets its size to 0.
When you no longer need the pool, for example, when your app exits or crashes, to avoid leaving hanging connections, close the pool by calling [`close`](/norm/apidocs/norm/pool.html#close,Pool). This proc closes all connections in the pool and sets its size to 0.
"""

nbCode:
Expand Down