@graphql-hive/core
Version:
64 lines • 2.4 kB
TypeScript
export default Status;
/**
* Tracks execution status for a given {@link CircuitBreaker}.
* A Status instance is created for every {@link CircuitBreaker}
* and does not typically need to be created by a user.
*
* A Status instance will listen for all events on the {@link CircuitBreaker}
* and track them in a rolling statistical window. The window duration is
* determined by the `rollingCountTimeout` option provided to the
* {@link CircuitBreaker}. The window consists of an array of Objects,
* each representing the counts for a {@link CircuitBreaker}'s events.
*
* The array's length is determined by the {@link CircuitBreaker}'s
* `rollingCountBuckets` option. The duration of each slice of the window
* is determined by dividing the `rollingCountTimeout` by
* `rollingCountBuckets`.
*
* @class Status
* @extends EventEmitter
* @param {Object} options for the status window
* @param {Number} options.rollingCountBuckets number of buckets in the window
* @param {Number} options.rollingCountTimeout the duration of the window
* @param {Boolean} options.rollingPercentilesEnabled whether to calculate
* percentiles
* @param {Object} options.stats object of previous stats
* @example
* // Creates a 1 second window consisting of ten time slices,
* // each 100ms long.
* const circuit = circuitBreaker(fs.readFile,
* { rollingCountBuckets: 10, rollingCountTimeout: 1000});
*
* // get the cumulative statistics for the last second
* circuit.status.stats;
*
* // get the array of 10, 1 second time slices for the last second
* circuit.status.window;
* @fires Status#snapshot
* @see CircuitBreaker#status
*/
declare class Status extends EventEmitter<[never]> {
constructor(options: any);
rollingPercentilesEnabled: boolean;
enableSnapshots: boolean;
rotateBucketController: any;
rotateBucket: (_: any) => void;
/**
* Get the cumulative stats for the current window
* @type {Object}
*/
get stats(): Object;
/**
* Gets the stats window as an array of time-sliced objects.
* @type {Array}
*/
get window(): any[];
increment(property: any, latencyRunTime: any): void;
open(): void;
close(): void;
shutdown(): void;
removeRotateBucketControllerListener(): void;
startListeneningForRotateEvent(): void;
}
import EventEmitter from 'events';
//# sourceMappingURL=status.d.ts.map