UNPKG

vulcain-corejs

Version:
50 lines (48 loc) 4.33 kB
"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, "number"); this.circuitBreakerForceClosed = this.get(HystrixPropertiesNames.HYSTRIX_FORCE_CIRCUIT_CLOSED, "boolean", config.circuitBreakerForceClosed); this.circuitBreakerForceOpen = this.get(HystrixPropertiesNames.HYSTRIX_FORCE_CIRCUIT_OPEN, "boolean", config.circuitBreakerForceOpened); this.circuitBreakerSleepWindowInMilliseconds = this.get(HystrixPropertiesNames.HYSTRIX_CIRCUIT_SLEEP_WINDOW_IN_MS, "number", config.circuitBreakerSleepWindowInMilliseconds); this.circuitBreakerErrorThresholdPercentage = this.get(HystrixPropertiesNames.HYSTRIX_CIRCUIT_ERROR_THRESHOLD_PERCENTAGE, "number", config.circuitBreakerErrorThresholdPercentage); this.circuitBreakerRequestVolumeThreshold = this.get(HystrixPropertiesNames.HYSTRIX_CIRCUIT_VOLUME_THRESHOLD, "number", config.circuitBreakerRequestVolumeThreshold); this.executionTimeoutInMilliseconds = this.get(HystrixPropertiesNames.HYSTRIX_EXECUTION_TIMEOUT_IN_MS, "number", config.executionTimeoutInMilliseconds); this.metricsRollingStatisticalWindowBuckets = this.get(HystrixPropertiesNames.HYSTRIX_METRICS_STATISTICAL_WINDOW_BUCKETS, "number", config.statisticalWindowNumberOfBuckets); this.metricsRollingStatisticalWindowInMilliseconds = this.get(HystrixPropertiesNames.HYSTRIX_METRICS_STATISTICAL_WINDOW_IN_MS, "number", config.metricsRollingStatisticalWindowInMilliseconds); this.metricsRollingPercentileWindowInMilliseconds = this.get(HystrixPropertiesNames.HYSTRIX_METRICS_PERCENTILE_WINDOW_IN_MS, "number", config.metricsRollingPercentileWindowInMilliseconds); this.executionIsolationSemaphoreMaxConcurrentRequests = this.get(HystrixPropertiesNames.HYSTRIX_REQUEST_VOLUME_REJECTION_THRESHOLD, "number"); this.fallbackIsolationSemaphoreMaxConcurrentRequests = this.get(HystrixPropertiesNames.HYSTRIX_FALLBACK_VOLUME_REJECTION_THRESHOLD, "number"); // this.metricsHealthSnapshotIntervalInMilliseconds = this.get<number>(HystrixPropertiesNames.HYSTRIX_FALLBACK_VOLUME_REJECTION_THRESHOLD); this.circuitBreakerEnabled = this.get(HystrixPropertiesNames.HYSTRIX_CIRCUIT_ENABLED, "boolean", config.circuitEnabled); } get(name, schema, defaultValue) { return system_1.System.createServiceConfigurationProperty(this.commandName + "." + name, defaultValue || conventions_1.Conventions.instance.hystrix[name]); } } exports.CommandProperties = CommandProperties; //# sourceMappingURL=commandProperties.js.map