import { BaseCheck } from '../base_check.ts'; import type { HealthCheckResult } from '../types.ts'; /** * Checks the memory heap size and reports warning or error after a * certain threshold is exceeded. Thresholds can be defined as absolute * byte values or as percentages of the maximum V8 heap size limit * * @example * ```typescript * // Using byte thresholds * const heapCheckBytes = new MemoryHeapCheck() * .as('Heap memory usage check (bytes)') * .warnWhenExceeds('200 mb') * .failWhenExceeds('300 mb') * .cacheFor('30s') * * // Using percentage thresholds * const heapCheckPercentage = new MemoryHeapCheck() * .as('Heap memory usage check (percentage)') * .warnWhenExceedsPercentage(80) // Warning at 80% of max heap * .failWhenExceedsPercentage(90) // Error at 90% of max heap * .cacheFor('30s') * * const resultBytes = await heapCheckBytes.run() * console.log(resultBytes.status) // 'ok' | 'warning' | 'error' * * const resultPercentage = await heapCheckPercentage.run() * console.log(resultPercentage.status) // 'ok' | 'warning' | 'error' * ``` */ export declare class MemoryHeapCheck extends BaseCheck { #private; /** * The name of the memory heap check */ name: string; /** * Defines the heap threshold after which a warning * should be created. This method sets a byte-based threshold * * The value should be either a number in bytes or a value expression string * * @param value - The threshold value as bytes (number) or string expression (e.g., '200 mb') * * @example * ```typescript * const check = new MemoryHeapCheck().warnWhenExceeds('200 mb') * // or * const check2 = new MemoryHeapCheck().warnWhenExceeds(209715200) // 200 MB in bytes * ``` */ warnWhenExceeds(value: string | number): this; /** * Defines the heap threshold after which an error * should be created. This method sets a byte-based threshold * * The value should be either a number in bytes or a value expression string * * @param value - The threshold value as bytes (number) or string expression (e.g., '500 mb') * * @example * ```typescript * const check = new MemoryHeapCheck().failWhenExceeds('500 mb') * // or * const check2 = new MemoryHeapCheck().failWhenExceeds(524288000) // 500 MB in bytes * ``` */ failWhenExceeds(value: string | number): this; /** * Defines the percentage threshold after which a warning * should be created. This method sets a percentage-based threshold * relative to the V8 heap size limit * * @param valueInPercentage - The percentage threshold for warnings (0-100) * * @example * ```typescript * const check = new MemoryHeapCheck().warnWhenExceedsPercentage(80) * ``` */ warnWhenExceedsPercentage(valueInPercentage: number): this; /** * Defines the percentage threshold after which an error * should be created. This method sets a percentage-based threshold * relative to the V8 heap size limit * * @param valueInPercentage - The percentage threshold for errors (0-100) * * @example * ```typescript * const check = new MemoryHeapCheck().failWhenExceedsPercentage(90) * ``` */ failWhenExceedsPercentage(valueInPercentage: number): this; /** * Defines a custom callback to compute the heap size. Defaults to * using the "process.memoryUsage()" method call * * @param callback - Function that returns memory usage information * * @example * ```typescript * const heapCheck = new MemoryHeapCheck() * .compute(() => { * // Custom memory computation logic * const usage = process.memoryUsage() * return { ...usage, heapUsed: usage.heapUsed * 0.8 } // Custom adjustment * }) * ``` */ compute(callback: () => NodeJS.MemoryUsage): this; /** * Executes the heap memory usage check */ run(): Promise; }