@sap-cloud-sdk/resilience
Advanced tools
Comparing version 3.0.1-20230301023900.0 to 3.0.1
@@ -17,4 +17,10 @@ import CircuitBreaker from 'opossum'; | ||
*/ | ||
export declare function circuitBreakerHttp<ArgumentT, ReturnT, ContextT extends MiddlewareContext<ArgumentT>>(): Middleware<ArgumentT, ReturnT, ContextT>; | ||
export declare function circuitBreaker<ArgumentT, ReturnT, ContextT extends MiddlewareContext<ArgumentT>>(): Middleware<ArgumentT, ReturnT, ContextT>; | ||
/** | ||
* @deprecated Since v3.0.1. Use `{@link circuitBreaker}` instead. | ||
* Helper method to build a circuit breaker middleware. | ||
* @returns The middleware adding a circuit breaker to the function. | ||
*/ | ||
export declare const circuitBreakerHttp: typeof circuitBreaker; | ||
/** | ||
* This is partially copied from CircuitBreaker.Options of `@types/opossum`. | ||
@@ -21,0 +27,0 @@ * @internal |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.circuitBreakerHttp = exports.circuitBreakerDefaultOptions = exports.circuitBreakers = void 0; | ||
exports.circuitBreakerHttp = exports.circuitBreaker = exports.circuitBreakerDefaultOptions = exports.circuitBreakers = void 0; | ||
const opossum_1 = __importDefault(require("opossum")); | ||
@@ -35,7 +35,13 @@ /** | ||
*/ | ||
function circuitBreakerHttp() { | ||
return circuitBreaker(circuitBreakerKeyBuilder, httpErrorFilter); | ||
function circuitBreaker() { | ||
return circuitBreakerGeneric(circuitBreakerKeyBuilder, httpErrorFilter); | ||
} | ||
exports.circuitBreakerHttp = circuitBreakerHttp; | ||
function circuitBreaker(keyBuilder, errorFilter) { | ||
exports.circuitBreaker = circuitBreaker; | ||
/** | ||
* @deprecated Since v3.0.1. Use `{@link circuitBreaker}` instead. | ||
* Helper method to build a circuit breaker middleware. | ||
* @returns The middleware adding a circuit breaker to the function. | ||
*/ | ||
exports.circuitBreakerHttp = circuitBreaker; | ||
function circuitBreakerGeneric(keyBuilder, errorFilter) { | ||
return (options) => fnArgument => getCircuitBreaker(keyBuilder(options.context), errorFilter).fire(options.fn, fnArgument); | ||
@@ -42,0 +48,0 @@ } |
@@ -8,5 +8,5 @@ /** | ||
export { retry } from './retry'; | ||
export { circuitBreakerHttp } from './circuit-breaker'; | ||
export { circuitBreakerHttp, circuitBreaker } from './circuit-breaker'; | ||
export type { Middleware, MiddlewareFunction } from './middleware'; | ||
export { MiddlewareOptions, MiddlewareContext } from './middleware'; | ||
export { ResilienceOptions, resilience } from './resilience'; |
@@ -8,3 +8,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.resilience = exports.circuitBreakerHttp = exports.retry = exports.timeout = void 0; | ||
exports.resilience = exports.circuitBreaker = exports.circuitBreakerHttp = exports.retry = exports.timeout = void 0; | ||
var timeout_1 = require("./timeout"); | ||
@@ -16,4 +16,5 @@ Object.defineProperty(exports, "timeout", { enumerable: true, get: function () { return timeout_1.timeout; } }); | ||
Object.defineProperty(exports, "circuitBreakerHttp", { enumerable: true, get: function () { return circuit_breaker_1.circuitBreakerHttp; } }); | ||
Object.defineProperty(exports, "circuitBreaker", { enumerable: true, get: function () { return circuit_breaker_1.circuitBreaker; } }); | ||
var resilience_1 = require("./resilience"); | ||
Object.defineProperty(exports, "resilience", { enumerable: true, get: function () { return resilience_1.resilience; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -8,3 +8,3 @@ import { MiddlewareContext } from './middleware'; | ||
/** | ||
* Option for Retry Middleware. | ||
* Option for retry middleware. | ||
* False by default. If set to true, the number of retries is 3. | ||
@@ -15,3 +15,3 @@ * Assign a different value to set custom number of reties. | ||
/** | ||
* Option for Timeout Middleware. | ||
* Option for timeout middleware. | ||
* True by default, with a 10000 milliseconds timeout. | ||
@@ -22,3 +22,3 @@ * Assign a different value to set a custom timeout. | ||
/** | ||
* Option for CircuitBreaker Middleware. | ||
* Option for circuit breaker middleware. | ||
* True by default. Set false to disable. | ||
@@ -30,3 +30,3 @@ */ | ||
* Return the resilience middleware functions as an array. | ||
* By default, Timeout and Circuit Breaker are enabled and Retry is disabled. | ||
* By default, timeout and circuit breaker are enabled and retry is disabled. | ||
* This behavior can be overridden by adjusting the resilience options {@link ResilienceOptions}. | ||
@@ -33,0 +33,0 @@ * @param options - Resilience Options. |
@@ -14,3 +14,3 @@ "use strict"; | ||
* Return the resilience middleware functions as an array. | ||
* By default, Timeout and Circuit Breaker are enabled and Retry is disabled. | ||
* By default, timeout and circuit breaker are enabled and retry is disabled. | ||
* This behavior can be overridden by adjusting the resilience options {@link ResilienceOptions}. | ||
@@ -30,3 +30,3 @@ * @param options - Resilience Options. | ||
if (resilienceOption.circuitBreaker) { | ||
middlewares.push((0, circuit_breaker_1.circuitBreakerHttp)()); | ||
middlewares.push((0, circuit_breaker_1.circuitBreaker)()); | ||
} | ||
@@ -33,0 +33,0 @@ if (typeof resilienceOption.timeout === 'number') { |
import { MiddlewareContext, Middleware } from './middleware'; | ||
/** | ||
* Helper method to build a retry middleware. | ||
* @param retryCount - Number of retry attempts. Default value is 3. | ||
* @param retries - Number of retry attempts. Default value is 3. | ||
* @returns The middleware adding a retry to the function. | ||
*/ | ||
export declare function retry<ArgumentType, ReturnType, ContextType extends MiddlewareContext<ArgumentType>>(retryCount?: number): Middleware<ArgumentType, ReturnType, ContextType>; | ||
export declare function retry<ArgumentType, ReturnType, ContextType extends MiddlewareContext<ArgumentType>>(retries?: number): Middleware<ArgumentType, ReturnType, ContextType>; |
@@ -33,11 +33,11 @@ "use strict"; | ||
}); | ||
const defaultRetryCount = 3; | ||
const defaultRetries = 3; | ||
/** | ||
* Helper method to build a retry middleware. | ||
* @param retryCount - Number of retry attempts. Default value is 3. | ||
* @param retries - Number of retry attempts. Default value is 3. | ||
* @returns The middleware adding a retry to the function. | ||
*/ | ||
function retry(retryCount = defaultRetryCount) { | ||
if (retryCount < 0) { | ||
throw new Error('Retry count value is invalid.'); | ||
function retry(retries = defaultRetries) { | ||
if (retries < 0) { | ||
throw new Error('Number of retries must be greater or equal to 0.'); | ||
} | ||
@@ -62,3 +62,3 @@ return function (options) { | ||
} | ||
}, { retries: retryCount }); | ||
}, { retries }); | ||
}; | ||
@@ -65,0 +65,0 @@ } |
@@ -17,3 +17,3 @@ "use strict"; | ||
if (timeoutValue <= 0) { | ||
throw new Error('Timeout value is invalid.'); | ||
throw new Error('Timeout must be greater than 0.'); | ||
} | ||
@@ -20,0 +20,0 @@ if (timeoutValue < 10) { |
{ | ||
"name": "@sap-cloud-sdk/resilience", | ||
"version": "3.0.1-20230301023900.0", | ||
"version": "3.0.1", | ||
"description": "SAP Cloud SDK for JavaScript resilience", | ||
@@ -43,3 +43,3 @@ "homepage": "https://sap.github.io/cloud-sdk/docs/js/overview", | ||
"opossum": "^7.1.0", | ||
"@sap-cloud-sdk/util": "^3.0.1-20230301023900.0", | ||
"@sap-cloud-sdk/util": "^3.0.1", | ||
"@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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
30153
26
464
0
23
47
5
298
+ Added@sap-cloud-sdk/util@3.25.0(transitive)
- Removed@sap-cloud-sdk/util@3.24.0(transitive)
Updated@sap-cloud-sdk/util@^3.0.1