/// import Statistics from '../statistics'; import { EventEmitter } from 'events'; import { NodeLoad } from '../utils/profiler'; interface LoadDetection { highThreshold: number; /** if load > highThreshold, then scale up request */ lowThreshold: number; /** if load < lowThreshold, then scale down request */ desiredTxTime: number; /** max desired average time for the age of a TX. */ queueLimit: number; /** max desired TXs in queue. note TXs must spend a minimum 6 seconds in the before they can process*/ executeQueueLimit: number; /** max desired TXs in queue that will be executed on this node. note TXs must spend a minimum 6 seconds in the before they can process*/ statistics: Statistics; load: number; /** load is what matters for scale up or down. it is the max of scaledTimeInQueue and scaledQueueLength. */ nodeLoad: NodeLoad; /** this nodes perf related load. does not determine scale up/down, but can cause rate-limiting */ scaledTxTimeInQueue: number; /** 0-1 value on how close to desiredTxTime this nodes is (set to 0 if scaledQueueLength < lowThreshold) */ scaledQueueLength: number; /** 0-1 value on how close to queueLimit this nodes is */ scaledExecuteQueueLength: number; /** 0-1 value on how close to queueLimit this nodes is */ dbg: boolean; lastEmitCycle: number; /** the last cylce that we have sent load events on */ } declare class LoadDetection extends EventEmitter { constructor(config: any, statistics: any); configUpdated(): void; /** * Returns a number between 0 and 1 indicating the current load. */ updateLoad(): void; getCurrentLoad(): number; getCurrentNodeLoad(): NodeLoad; getQueueLoad(): { txTimeInQueue: number; queueLength: number; executeQueueLength: number; }; } export default LoadDetection;