Skip to content

Commit 94e553f

Browse files
committed
connection pool documentation
1 parent 835e40f commit 94e553f

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,54 @@ Shopify.GraphQL.send("{ shop { name } }", access_token: "...", retry: Shopify.Gr
158158
The example above would retry a failed request after 250 milliseconds. By
159159
default `Shopify.GraphQL.Retry.Linear` will retry a request immediately if
160160
`:retry_in` has no value
161+
162+
## Connection Pooling
163+
164+
The out-of-the-box HTTP client, `Shopify.GraphQL.Client.Hackney`, uses hackney's `:default`
165+
connection pool. This pool has a maxiumum of `50` connections. You can tell
166+
`shopify_graphql` to use a different connection pool by specifying the pool name
167+
under http_client_opts in the config.
168+
169+
**Example**
170+
171+
Start a new hackney pool in `application.ex` on application startup:
172+
173+
```
174+
defmodule BigPool.Application do
175+
use Application
176+
177+
def start(_type, _args) do
178+
children = [
179+
...
180+
:hackney_pool.child_spec(:my_big_pool, timeout: 60_000, recv_timeout: 60_000, max_connections: 1000)
181+
...
182+
]
183+
184+
opts = [strategy: :one_for_one, name: BigPool.Supervisor]
185+
_result = Supervisor.start_link(children, opts)
186+
end
187+
end
188+
```
189+
190+
And then specify the new pool name in the request config:
191+
192+
```
193+
config = [
194+
...
195+
http_client_opts: [pool: :my_big_pool]
196+
...
197+
]
198+
199+
query =
200+
"""
201+
{
202+
shop {
203+
name
204+
}
205+
}
206+
"""
207+
208+
Shopify.GraphQL.send(query, config)
209+
210+
```
211+

0 commit comments

Comments
 (0)