Skip to content

Commit 10b078f

Browse files
authored
Merge pull request #645 from legoscia/pool-readme
Clarify that socket pools are used by default
2 parents bde17f1 + 1ef9af4 commit 10b078f

File tree

3 files changed

+42
-30
lines changed

3 files changed

+42
-30
lines changed

README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -337,26 +337,26 @@ LoopFun(LoopFun, ClientRef).
337337
338338
### Use the default pool
339339

340-
To reuse a connection globally in your application you can also use a
341-
socket pool. On startup, hackney launches a pool named default. To use it
342-
do the following:
340+
Hackney uses socket pools to reuse connections globally. By default,
341+
hackney uses a pool named `default`. You may want to use different
342+
pools in your application which allows you to maintain a group of
343+
connections. To use a different pool, do the following:
343344

344345
```erlang
345346

346347
Method = get,
347348
URL = <<"https://friendpaste.com">>,
348349
Headers = [],
349350
Payload = <<>>,
350-
Options = [{pool, default}],
351+
Options = [{pool, mypool}],
351352
{ok, StatusCode, RespHeaders, ClientRef} = hackney:request(Method, URL, Headers,
352353
Payload, Options).
353354
```
354355

355-
By adding the tuple `{pool, default}` to the options, hackney will use
356-
the connections stored in that pool.
357-
358-
You can also use different pools in your application which allows
359-
you to maintain a group of connections.
356+
By adding the tuple `{pool, mypool}` to the options, hackney will use
357+
the connections stored in that pool. The pool gets started automatically
358+
the first time it is used. You can also explicitly configure and start
359+
the pool like this:
360360

361361
```erlang
362362

@@ -379,7 +379,11 @@ hackney_pool:stop_pool(PoolName).
379379
> Note: Sometimes you want to disable the default pool in your app
380380
> without having to set the client option each time. You can now do this
381381
> by setting the hackney application environment key `use_default_pool`
382-
> to false.
382+
> to false. This means that hackney will not use socket pools unless
383+
> specifically requested using the `pool` option as described above.
384+
>
385+
> To disable socket pools for a single request, specify the option
386+
> `{pool, false}`.
383387
384388
### Use a custom pool handler.
385389

doc/README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -337,26 +337,26 @@ LoopFun(LoopFun, ClientRef).
337337
338338
### Use the default pool
339339

340-
To reuse a connection globally in your application you can also use a
341-
socket pool. On startup, hackney launches a pool named default. To use it
342-
do the following:
340+
Hackney uses socket pools to reuse connections globally. By default,
341+
hackney uses a pool named `default`. You may want to use different
342+
pools in your application which allows you to maintain a group of
343+
connections. To use a different pool, do the following:
343344

344345
```erlang
345346

346347
Method = get,
347348
URL = <<"https://friendpaste.com">>,
348349
Headers = [],
349350
Payload = <<>>,
350-
Options = [{pool, default}],
351+
Options = [{pool, mypool}],
351352
{ok, StatusCode, RespHeaders, ClientRef} = hackney:request(Method, URL, Headers,
352353
Payload, Options).
353354
```
354355

355-
By adding the tuple `{pool, default}` to the options, hackney will use
356-
the connections stored in that pool.
357-
358-
You can also use different pools in your application which allows
359-
you to maintain a group of connections.
356+
By adding the tuple `{pool, mypool}` to the options, hackney will use
357+
the connections stored in that pool. The pool gets started automatically
358+
the first time it is used. You can also explicitly configure and start
359+
the pool like this:
360360

361361
```erlang
362362

@@ -379,7 +379,11 @@ hackney_pool:stop_pool(PoolName).
379379
> Note: Sometimes you want to disable the default pool in your app
380380
> without having to set the client option each time. You can now do this
381381
> by setting the hackney application environment key `use_default_pool`
382-
> to false.
382+
> to false. This means that hackney will not use socket pools unless
383+
> specifically requested using the `pool` option as described above.
384+
>
385+
> To disable socket pools for a single request, specify the option
386+
> `{pool, false}`.
383387
384388
### Use a custom pool handler.
385389

doc/overview.edoc

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -339,24 +339,24 @@ LoopFun(LoopFun, ClientRef).</pre>
339339

340340
### Use the default pool
341341

342-
To reuse a connection globally in your application you can also use a
343-
socket pool. On startup, hackney launches a pool named default. To use it
344-
do the following:
342+
Hackney uses socket pools to reuse connections globally. By default,
343+
hackney uses a pool named `default'. You may want to use different
344+
pools in your application which allows you to maintain a group of
345+
connections. To use a different pool, do the following:
345346

346347
<pre lang="erlang">
347348
Method = get,
348349
URL = &lt;&lt;"https://friendpaste.com">>,
349350
Headers = [],
350351
Payload = &lt;&lt;>>,
351-
Options = [{pool, default}],
352+
Options = [{pool, mypool}],
352353
{ok, StatusCode, RespHeaders, ClientRef} = hackney:request(Method, URL, Headers,
353354
Payload, Options).</pre>
354355

355-
By adding the tuple `{pool, default}' to the options, hackney will use
356-
the connections stored in that pool.
357-
358-
You can also use different pools in your application which allows
359-
you to maintain a group of connections.
356+
By adding the tuple `{pool, mypool}' to the options, hackney will use
357+
the connections stored in that pool. The pool gets started automatically
358+
the first time it is used. You can also explicitly configure and start
359+
the pool like this:
360360

361361
<pre lang="erlang">
362362
PoolName = mypool,
@@ -376,7 +376,11 @@ To close a pool do:
376376
> Note: Sometimes you want to disable the default pool in your app
377377
> without having to set the client option each time. You can now do this
378378
> by setting the hackney application environment key `use_default_pool'
379-
> to false.
379+
> to false. This means that hackney will not use socket pools unless
380+
> specifically requested using the `pool' option as described above.
381+
>
382+
> To disable socket pools for a single request, specify the option
383+
> `{pool, false}'.
380384

381385
### Use a custom pool handler.
382386

0 commit comments

Comments
 (0)