Skip to content
This repository was archived by the owner on Mar 11, 2022. It is now read-only.

Commit 1c99a7f

Browse files
author
Veronika
committed
- Extend README.md with singleton usage suggestion
1 parent 35dbb08 commit 1c99a7f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@ style is that `Cloudant` (upper-case) is the **package** you load; whereas
145145
`cloudant` (lower-case) is your **connection** to your database (i.e. the result of
146146
calling `Cloudant()`).
147147

148+
The `cloudant` client connection utilizes an agent with a configurable [HTTP
149+
connection pool](#pool-size-and-open-sockets). As such the performance of the
150+
client is improved when re-using the `cloudant` client connection throughout
151+
an application instead of repeatedly re-instantiating. It is important to
152+
instantiate the `cloudant` _connection_ **only once** during the application
153+
lifetime to reduce the overheads of memory usage and other resources such as
154+
unused connections.
155+
148156
You can initialize your client in _one_ of the following ways:
149157

150158
#### 1. Using a URL:
@@ -396,6 +404,8 @@ var cloudant = Cloudant({ url: myurl, maxAttempt: 5, plugins: [ { iamauth: { iam
396404
397405
1. `cookieauth`
398406
407+
If there is no plugin specified this will be the default plugin.
408+
399409
This plugin will automatically exchange your Cloudant credentials for a
400410
cookie. It will handle the authentication and ensure that the cookie is
401411
refreshed as required.
@@ -415,6 +425,11 @@ var cloudant = Cloudant({ url: myurl, maxAttempt: 5, plugins: [ { iamauth: { iam
415425
If you don't specify a username and password during the client construction
416426
then cookie authentication is disabled.
417427
428+
You can turn off automatically refreshing cookie with the following configuration:
429+
```js
430+
var cloudant = Cloudant({ url: 'https://user:[email protected]', plugins: [ { cookieauth: { autoRenew: false } } ] });
431+
```
432+
418433
2. `iamauth`
419434
420435
IBM Cloud Identity & Access Management enables you to securely authenticate
@@ -446,6 +461,11 @@ var cloudant = Cloudant({ url: myurl, maxAttempt: 5, plugins: [ { iamauth: { iam
446461
447462
See [IBM Cloud Identity and Access Management](https://cloud.ibm.com/docs/services/Cloudant/guides?topic=cloudant-ibm-cloud-identity-and-access-management-iam-) for more information.
448463
464+
You can turn off automatically refreshing token with the following configuration:
465+
```js
466+
var cloudant = Cloudant({ url: 'https://user:[email protected]', plugins: [ { iamauth: { iamApiKey: 'xxxxxxxxxx', autoRenew: false } } ] });
467+
```
468+
449469
3. `retry`
450470
451471
This plugin will retry requests on error (e.g. connection reset errors) or on

0 commit comments

Comments
 (0)