vulcain-corejs
Version:
Vulcain micro-service framework
50 lines (48 loc) • 4.18 kB
JavaScript
"use strict";
const conventions_1 = require('./../../utils/conventions');
const system_1 = require('../../configurations/globals/system');
let HystrixPropertiesNames = {
HYSTRIX_HEALTH_SNAPSHOT_IN_MS: "hystrix.health.snapshot.validityInMilliseconds",
HYSTRIX_FORCE_CIRCUIT_OPEN: "hystrix.force.circuit.open",
HYSTRIX_FORCE_CIRCUIT_CLOSED: "hystrix.force.circuit.closed",
HYSTRIX_CIRCUIT_ENABLED: "hystrix.circuit.enabled",
HYSTRIX_CIRCUIT_SLEEP_WINDOW_IN_MS: "hystrix.circuit.sleepWindowInMilliseconds",
HYSTRIX_CIRCUIT_ERROR_THRESHOLD_PERCENTAGE: "hystrix.circuit.errorThresholdPercentage",
HYSTRIX_CIRCUIT_VOLUME_THRESHOLD: "hystrix.circuit.volumeThreshold",
HYSTRIX_EXECUTION_TIMEOUT_IN_MS: "hystrix.execution.timeoutInMilliseconds",
HYSTRIX_METRICS_STATISTICAL_WINDOW_IN_MS: "hystrix.metrics.statistical.window.timeInMilliseconds",
HYSTRIX_METRICS_STATISTICAL_WINDOW_BUCKETS: "hystrix.metrics.statistical.window.bucketsNumber",
HYSTRIX_METRICS_PERCENTILE_WINDOW_IN_MS: "hystrix.metrics.percentile.window.timeInMilliseconds",
HYSTRIX_METRICS_PERCENTILE_WINDOW_BUCKETS: "hystrix.metrics.percentile.window.bucketsNumber",
HYSTRIX_FALLBACK_VOLUME_REJECTION_THRESHOLD: "hystrix.isolation.semaphore.maxConcurrentRequests",
HYSTRIX_REQUEST_VOLUME_REJECTION_THRESHOLD: "hystrix.fallback.semaphore.maxConcurrentRequests"
};
class CommandProperties {
constructor(commandName, commandGroup, config) {
this.commandName = commandName;
this.commandGroup = commandGroup;
if (!commandName) {
throw new Error("Please provide a unique command key for the metrics.");
}
this.commandGroup = this.commandGroup || "hystrix";
this.metricsRollingPercentileWindowBuckets = this.get(HystrixPropertiesNames.HYSTRIX_METRICS_PERCENTILE_WINDOW_BUCKETS);
this.circuitBreakerForceClosed = this.get(HystrixPropertiesNames.HYSTRIX_FORCE_CIRCUIT_CLOSED, config.circuitBreakerForceClosed);
this.circuitBreakerForceOpen = this.get(HystrixPropertiesNames.HYSTRIX_FORCE_CIRCUIT_OPEN, config.circuitBreakerForceOpened);
this.circuitBreakerSleepWindowInMilliseconds = this.get(HystrixPropertiesNames.HYSTRIX_CIRCUIT_SLEEP_WINDOW_IN_MS, config.circuitBreakerSleepWindowInMilliseconds);
this.circuitBreakerErrorThresholdPercentage = this.get(HystrixPropertiesNames.HYSTRIX_CIRCUIT_ERROR_THRESHOLD_PERCENTAGE, config.circuitBreakerErrorThresholdPercentage);
this.circuitBreakerRequestVolumeThreshold = this.get(HystrixPropertiesNames.HYSTRIX_CIRCUIT_VOLUME_THRESHOLD, config.circuitBreakerRequestVolumeThreshold);
this.executionTimeoutInMilliseconds = this.get(HystrixPropertiesNames.HYSTRIX_EXECUTION_TIMEOUT_IN_MS, config.executionTimeoutInMilliseconds);
this.metricsRollingStatisticalWindowBuckets = this.get(HystrixPropertiesNames.HYSTRIX_METRICS_STATISTICAL_WINDOW_BUCKETS, config.statisticalWindowNumberOfBuckets);
this.metricsRollingStatisticalWindowInMilliseconds = this.get(HystrixPropertiesNames.HYSTRIX_METRICS_STATISTICAL_WINDOW_IN_MS, config.metricsRollingStatisticalWindowInMilliseconds);
this.metricsRollingPercentileWindowInMilliseconds = this.get(HystrixPropertiesNames.HYSTRIX_METRICS_PERCENTILE_WINDOW_IN_MS, config.metricsRollingPercentileWindowInMilliseconds);
this.executionIsolationSemaphoreMaxConcurrentRequests = this.get(HystrixPropertiesNames.HYSTRIX_REQUEST_VOLUME_REJECTION_THRESHOLD);
this.fallbackIsolationSemaphoreMaxConcurrentRequests = this.get(HystrixPropertiesNames.HYSTRIX_FALLBACK_VOLUME_REJECTION_THRESHOLD);
// this.metricsHealthSnapshotIntervalInMilliseconds = this.get<number>(HystrixPropertiesNames.HYSTRIX_FALLBACK_VOLUME_REJECTION_THRESHOLD);
this.circuitBreakerEnabled = this.get(HystrixPropertiesNames.HYSTRIX_CIRCUIT_ENABLED, config.circuitEnabled);
}
get(name, defaultValue) {
return system_1.System.createServiceConfigurationProperty(this.commandName + "." + name, defaultValue || conventions_1.Conventions.instance.hystrix[name]);
}
}
exports.CommandProperties = CommandProperties;
//# sourceMappingURL=commandProperties.js.map