Skip to content

Commit 7f8c526

Browse files
committed
Bump patch version.
1 parent b118aba commit 7f8c526

5 files changed

Lines changed: 81 additions & 3 deletions

File tree

context/getting-started.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Getting Started
2+
3+
This guide explains how to use the `async-pool` gem to manage connection pooling.
4+
5+
## Installation
6+
7+
Add this gem to your project:
8+
9+
~~~ bash
10+
$ bundle add async-pool
11+
~~~
12+
13+
## Core Concepts
14+
15+
- {ruby Async::Pool::Controller} provides support for both singleplex (one stream at a time) and multiplex resources (multiple streams at a time).
16+
- {ruby Async::Pool::Resource} is provided as an interface and to document how to use the pools. However, you wouldn't need to use this in practice and just implement the appropriate interface on your own objects.
17+
18+
## Simplex Usage
19+
20+
A simplex pool is one where each resource can only be used one at a time. This is the most common type of pool, where each resource represents a single connection, e.g. `HTTP/1`.
21+
22+
~~~ ruby
23+
pool = Async::Pool::Controller.new(Async::Pool::Resource)
24+
25+
pool.acquire do |resource|
26+
# resource is implicitly released when exiting the block.
27+
end
28+
29+
resource = pool.acquire
30+
31+
# Return the resource back to the pool:
32+
pool.release(resource)
33+
~~~
34+
35+
## Multiplex Usage
36+
37+
A multiplex pool is one where each resource can be used multiple times concurrently. This is useful for resources that can handle multiple connections at once, e.g. `HTTP/2`.
38+
39+
~~~ ruby
40+
pool = Async::Pool::Controller.wrap do
41+
# This resource can be used concurrently by up to 4 tasks:
42+
Async::Pool::Resource.new(2)
43+
end
44+
45+
resources = 4.times.map do
46+
# Acquire a resource from the pool:
47+
pool.acquire
48+
end
49+
50+
resources.each do |resource|
51+
# Return the resource back to the pool:
52+
pool.release(resource)
53+
end
54+
~~~
55+
56+
## Limit and Concurrency
57+
58+
There are two key parameters to consider when using a pool:
59+
60+
- `limit` is the maximum number of resources that can be acquired at once.
61+
- `concurrency` is the maximum number of resources that can be created concurrently.
62+
63+
If the pool does not have any resources available, and the number of resources is less than the limit, a new resource will be created, otherwise the task will wait until a resource is available.
64+
65+
Creating resources can take time, and if multiple tasks are waiting for resources, it may be beneficial to create resources concurrently. Simplex resources are probably better created concurrently, while multiplex resources may be better created serially, as after a resource is created, it can be used by multiple tasks.

context/index.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Automatically generated context index for Utopia::Project guides.
2+
# Do not edit then files in this directory directly, instead edit the guides and then run `bake utopia:project:agent:context:update`.
3+
---
4+
description: A singleplex and multiplex resource pool for implementing robust clients.
5+
metadata:
6+
documentation_uri: https://socketry.github.io/async-pool/
7+
funding_uri: https://github.com/sponsors/ioquatix/
8+
source_code_uri: https://github.com/socketry/async-pool.git
9+
files:
10+
- path: getting-started.md
11+
title: Getting Started
12+
description: This guide explains how to use the `async-pool` gem to manage connection
13+
pooling.

lib/async/pool/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55

66
module Async
77
module Pool
8-
VERSION = "0.11.1"
8+
VERSION = "0.11.2"
99
end
1010
end

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Please see the [project documentation](https://socketry.github.io/async-pool/) f
1414

1515
Please see the [project releases](https://socketry.github.io/async-pool/releases/index) for all releases.
1616

17-
### v0.11.0
17+
### v0.11.2
1818

1919
## Contributing
2020

releases.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Releases
22

3-
## Unreleased
3+
## v0.11.2

0 commit comments

Comments
 (0)