simple-oracledb
Advanced tools
Comparing version 0.1.19 to 0.1.20
@@ -53,3 +53,3 @@ ## Classes | ||
* [#update(sql, bindParams, options, callback)](#Connection+update) | ||
* [#release([callback])](#Connection+release) | ||
* [#release([options], [callback])](#Connection+release) | ||
* [#commit(callback)](#Connection+commit) | ||
@@ -215,5 +215,5 @@ * [#rollback([callback])](#Connection+rollback) | ||
<a name="Connection+release"></a> | ||
### Connection#release([callback]) | ||
### Connection#release([options], [callback]) | ||
This function modifies the existing connection.release function by enabling the input | ||
callback to be an optional parameter.<br> | ||
callback to be an optional parameter and providing ability to auto retry in case of any errors during release.<br> | ||
Since there is no real way to release a connection that fails to be released, all that you can do in the callback | ||
@@ -225,5 +225,8 @@ is just log the error and continue.<br> | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| [callback] | <code>function</code> | An optional release callback function (see oracledb docs) | | ||
| Param | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| [options] | <code>object</code> | | Optional options used to define error handling (retry is enabled only if options are provided) | | ||
| [options.retryCount] | <code>number</code> | <code>10</code> | Optional number of retries in case of any error during the release | | ||
| [options.retryInterval] | <code>number</code> | <code>250</code> | Optional interval in millies between retries | | ||
| [callback] | <code>function</code> | | An optional release callback function (see oracledb docs) | | ||
@@ -240,2 +243,18 @@ **Example** | ||
}); | ||
//retry release in case of errors is enabled if options are provided | ||
connection.release({ | ||
retryCount: 20, //retry max 20 times in case of errors (default is 10 if not provided) | ||
retryInterval: 1000 //retry every 1 second (default is 250 millies if not provided) | ||
}); | ||
//you can provide both retry options and callback (callback will be called only after all retries are done or in case connection was released) | ||
connection.release({ | ||
retryCount: 10, | ||
retryInterval: 250 | ||
}, function onRelease(error) { | ||
if (error) { | ||
//now what? | ||
} | ||
}); | ||
``` | ||
@@ -242,0 +261,0 @@ <a name="Connection+commit"></a> |
@@ -279,3 +279,3 @@ 'use strict'; | ||
* This function modifies the existing connection.release function by enabling the input | ||
* callback to be an optional parameter.<br> | ||
* callback to be an optional parameter and providing ability to auto retry in case of any errors during release.<br> | ||
* Since there is no real way to release a connection that fails to be released, all that you can do in the callback | ||
@@ -288,2 +288,5 @@ * is just log the error and continue.<br> | ||
* @public | ||
* @param {object} [options] - Optional options used to define error handling (retry is enabled only if options are provided) | ||
* @param {number} [options.retryCount=10] - Optional number of retries in case of any error during the release | ||
* @param {number} [options.retryInterval=250] - Optional interval in millies between retries | ||
* @param {function} [callback] - An optional release callback function (see oracledb docs) | ||
@@ -300,8 +303,56 @@ * @example | ||
* }); | ||
* | ||
* //retry release in case of errors is enabled if options are provided | ||
* connection.release({ | ||
* retryCount: 20, //retry max 20 times in case of errors (default is 10 if not provided) | ||
* retryInterval: 1000 //retry every 1 second (default is 250 millies if not provided) | ||
* }); | ||
* | ||
* //you can provide both retry options and callback (callback will be called only after all retries are done or in case connection was released) | ||
* connection.release({ | ||
* retryCount: 10, | ||
* retryInterval: 250 | ||
* }, function onRelease(error) { | ||
* if (error) { | ||
* //now what? | ||
* } | ||
* }); | ||
* ``` | ||
*/ | ||
Connection.prototype.release = function (callback) { | ||
callback = callback || this.noop; | ||
Connection.prototype.release = function () { | ||
var self = this; | ||
this.baseRelease(callback); | ||
var args = Array.prototype.slice.call(arguments); | ||
var callback = self.noop; | ||
var options; | ||
if (args.length) { | ||
if (args.length === 2) { | ||
options = args[0]; | ||
callback = args[1]; | ||
} else if (args.length === 1) { | ||
if (typeof args[0] === 'function') { | ||
callback = args[0]; | ||
} else { | ||
options = args[0]; | ||
} | ||
} | ||
if (options) { | ||
options.retryCount = Math.max(options.retryCount || 10, 1); | ||
options.retryInterval = Math.max(options.retryInterval || 250, 1); | ||
} | ||
} | ||
if (options) { | ||
asyncLib.retry({ | ||
times: options.retryCount, | ||
interval: options.retryInterval | ||
}, function attemptRelease(asyncCallback) { | ||
self.baseRelease(asyncCallback); | ||
}, callback); | ||
} else { | ||
self.baseRelease(callback); | ||
} | ||
}; | ||
@@ -308,0 +359,0 @@ |
{ | ||
"name": "simple-oracledb", | ||
"version": "0.1.19", | ||
"version": "0.1.20", | ||
"description": "Extend capabilities of oracledb with simplified API for quicker development.", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -459,2 +459,3 @@ # simple-oracledb | ||
| ----------- | ------- | ----------- | | ||
| 2016-02-09 | v0.1.20 | connection.release now supports retry options | | ||
| 2016-02-02 | v0.1.19 | Maintenance | | ||
@@ -461,0 +462,0 @@ | 2016-01-22 | v0.1.18 | Fixed missing call to resultset.close after done reading | |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
418340
9149
492