Skip to content

Commit

Permalink
Add retry_strategy option
Browse files Browse the repository at this point in the history
  • Loading branch information
KazuhiroItoh committed Mar 3, 2021
1 parent 3de3899 commit 8ba151b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
18 changes: 10 additions & 8 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ contextStorage: {
This plugin exposes some options defined in [node_redis](https://github.com/NodeRedis/node_redis) as itself options.
It needs following configuration options:

| Options | Description |
| -------- | ----------------------------------------------------------------------------------------------------------- |
| host | The IP address of the Redis server. `Default: "127.0.0.1"` |
| port | The port of the Redis server. `Default: 6379` |
| db | The Redis logical database to connect. `Default: 0` |
| prefix | If set, the string used to prefix all used keys. |
| password | If set, the plugin will run Redis AUTH command on connect. *Note: the password will be sent as plaintext.* |
| tls | An object containing options to pass to tls.connect to set up a TLS connection to the server. |
| Options | Description |
| -------------- | ----------------------------------------------------------------------------------------------------------- |
| host | The IP address of the Redis server. `Default: "127.0.0.1"` |
| port | The port of the Redis server. `Default: 6379` |
| db | The Redis logical database to connect. `Default: 0` |
| prefix | If set, the string used to prefix all used keys. |
| password | If set, the plugin will run Redis AUTH command on connect. *Note: the password will be sent as plaintext.* |
| tls | An object containing options to pass to tls.connect to set up a TLS connection to the server. |
| retry_strategy | Specifies a function to reconnect if the connection to Redis is lost. |
| | `default: undefined (Use the default retry strategy)` |

see https://github.com/NodeRedis/node_redis#options-object-properties

Expand Down
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
* // default: undefined
* tls: // An object containing options to pass to tls.connect to set up a TLS connection to Redis
* // default: undefined
* retry_strategy: // Specifies a function to reconnect if the connection to Redis is lost.
* // default: undefined (Use the default retry strategy)
* }
*
* This plugin prefixes all used keys with context scope.
Expand Down Expand Up @@ -175,8 +177,7 @@ function Redis(config) {
db: config.db || 0,
password: config.password,
tls: config.tls,
//Do not try to reconnect, throw an error
retry_strategy: () => undefined
retry_strategy: config.retry_strategy || undefined
};
this.client = null;
this.knownCircularRefs = {};
Expand Down

0 comments on commit 8ba151b

Please sign in to comment.