@sap-cloud-sdk/resilience
Advanced tools
Comparing version 3.0.0-20221221165657.0 to 3.0.0-20221223102207.0
@@ -14,3 +14,4 @@ import CircuitBreaker from 'opossum'; | ||
/** | ||
* @internal | ||
* Helper method to build a circuit breaker middleware. | ||
* @returns The middleware adding a circuit breaker to the function. | ||
*/ | ||
@@ -17,0 +18,0 @@ export declare function circuitBreakerHttp<ReturnT, ContextT extends Context>(): Middleware<ReturnT, ContextT>; |
@@ -35,3 +35,4 @@ "use strict"; | ||
/** | ||
* @internal | ||
* Helper method to build a circuit breaker middleware. | ||
* @returns The middleware adding a circuit breaker to the function. | ||
*/ | ||
@@ -38,0 +39,0 @@ function circuitBreakerHttp() { |
@@ -8,4 +8,6 @@ /** | ||
export { retry } from './retry'; | ||
export { circuitBreakerHttp } from './circuit-breaker'; | ||
export type { Middleware, MiddlewareOut } from './middleware'; | ||
export { MiddlewareIn, Context, HttpMiddlewareContext, SkipNext } from './middleware'; | ||
export { ResilienceOptions, resilience } from './resilience'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -8,3 +8,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.retry = exports.timeout = void 0; | ||
exports.resilience = exports.circuitBreakerHttp = exports.retry = exports.timeout = void 0; | ||
var timeout_1 = require("./timeout"); | ||
@@ -14,2 +14,6 @@ Object.defineProperty(exports, "timeout", { enumerable: true, get: function () { return timeout_1.timeout; } }); | ||
Object.defineProperty(exports, "retry", { enumerable: true, get: function () { return retry_1.retry; } }); | ||
var circuit_breaker_1 = require("./circuit-breaker"); | ||
Object.defineProperty(exports, "circuitBreakerHttp", { enumerable: true, get: function () { return circuit_breaker_1.circuitBreakerHttp; } }); | ||
var resilience_1 = require("./resilience"); | ||
Object.defineProperty(exports, "resilience", { enumerable: true, get: function () { return resilience_1.resilience; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -5,2 +5,3 @@ export * from './timeout'; | ||
export * from './circuit-breaker'; | ||
export * from './resilience'; | ||
//# sourceMappingURL=internal.d.ts.map |
@@ -21,2 +21,3 @@ "use strict"; | ||
__exportStar(require("./circuit-breaker"), exports); | ||
__exportStar(require("./resilience"), exports); | ||
//# sourceMappingURL=internal.js.map |
@@ -40,2 +40,5 @@ "use strict"; | ||
function retry(retryCount = defaultRetryCount) { | ||
if (retryCount < 0) { | ||
throw new Error('Retry count value is invalid.'); | ||
} | ||
return function (options) { | ||
@@ -42,0 +45,0 @@ return () => asyncRetry.default(async (bail) => { |
import { Context, Middleware } from './middleware'; | ||
/** | ||
* Helper method to build a timeout middleware. | ||
* @param timeoutValue - Timeout in milliseconds. Default value are 10 seconds. | ||
* @param timeoutValue - Timeout in milliseconds. Default value is 10000. | ||
* @returns The middleware adding a timeout to the function. | ||
@@ -6,0 +6,0 @@ */ |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.timeout = void 0; | ||
const util_1 = require("@sap-cloud-sdk/util"); | ||
const defaultTimeout = 10000; | ||
const logger = (0, util_1.createLogger)({ | ||
package: 'resilience', | ||
messageContext: 'timeout' | ||
}); | ||
/** | ||
* Helper method to build a timeout middleware. | ||
* @param timeoutValue - Timeout in milliseconds. Default value are 10 seconds. | ||
* @param timeoutValue - Timeout in milliseconds. Default value is 10000. | ||
* @returns The middleware adding a timeout to the function. | ||
*/ | ||
function timeout(timeoutValue = defaultTimeout) { | ||
if (timeoutValue <= 0) { | ||
throw new Error('Timeout value is invalid.'); | ||
} | ||
if (timeoutValue < 10) { | ||
logger.warn(`The timeout of ${timeoutValue} ms is too low. Make sure this is not intentional.`); | ||
} | ||
return function (options) { | ||
@@ -12,0 +23,0 @@ const message = `Request to URL: ${options.context.uri} ran into a timeout after ${timeoutValue}ms.`; |
{ | ||
"name": "@sap-cloud-sdk/resilience", | ||
"version": "3.0.0-20221221165657.0", | ||
"version": "3.0.0-20221223102207.0", | ||
"description": "SAP Cloud SDK for JavaScript resilience", | ||
@@ -43,3 +43,3 @@ "homepage": "https://sap.github.io/cloud-sdk/docs/js/overview-cloud-sdk-for-javascript", | ||
"opossum": "^7.0.1", | ||
"@sap-cloud-sdk/util": "^3.0.0-20221221165657.0", | ||
"@sap-cloud-sdk/util": "^3.0.0-20221223102207.0", | ||
"@types/async-retry": "^1.4.5", | ||
@@ -46,0 +46,0 @@ "async-retry": "^1.3.3", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
32475
32
490