UNPKG

vulcain-corejs

Version:
65 lines (63 loc) 4.9 kB
"use strict"; const vulcain_configurations_1 = require('@sovinty/vulcain-configurations'); 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" }; let defaults = { "hystrix.health.snapshot.validityInMilliseconds": 500, "hystrix.force.circuit.open": false, "hystrix.force.circuit.closed": false, "hystrix.circuit.enabled": true, "hystrix.circuit.sleepWindowInMilliseconds": 5000, "hystrix.circuit.errorThresholdPercentage": 50, "hystrix.circuit.volumeThreshold": 10, "hystrix.execution.timeoutInMilliseconds": 1500, "hystrix.metrics.statistical.window.timeInMilliseconds": 60000, "hystrix.metrics.statistical.window.bucketsNumber": 30, "hystrix.metrics.percentile.window.timeInMilliseconds": 60000, "hystrix.metrics.percentile.window.bucketsNumber": 6, "hystrix.isolation.semaphore.maxConcurrentRequests": 10, "hystrix.fallback.semaphore.maxConcurrentRequests": 10 }; 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 vulcain_configurations_1.DynamicConfiguration.asChainedProperty(defaultValue || defaults[name], this.commandName + "." + name, name); } } exports.CommandProperties = CommandProperties; //# sourceMappingURL=commandProperties.js.map