import { BaseCheck } from '../base_check.ts'; import type { HealthCheckResult } from '../types.ts'; /** * Checks the memory RSS 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 total system memory * * @example * ```typescript * // Using byte thresholds * const rssCheckBytes = new MemoryRSSCheck() * .as('RSS memory usage check (bytes)') * .warnWhenExceeds('300 mb') * .failWhenExceeds('400 mb') * .cacheFor('1 minute') * * // Using percentage thresholds * const rssCheckPercentage = new MemoryRSSCheck() * .as('RSS memory usage check (percentage)') * .warnWhenExceedsPercentage(70) // Warning at 70% of total system RAM * .failWhenExceedsPercentage(85) // Error at 85% of total system RAM * .cacheFor('1 minute') * * const resultBytes = await rssCheckBytes.run() * console.log(resultBytes.status) // 'ok' | 'warning' | 'error' * * const resultPercentage = await rssCheckPercentage.run() * console.log(resultPercentage.status) // 'ok' | 'warning' | 'error' * ``` */ export declare class MemoryRSSCheck extends BaseCheck { #private; /** * The name of the memory RSS check */ name: string; /** * Defines the RSS 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 MemoryRSSCheck().warnWhenExceeds('300 mb') * // or * const check2 = new MemoryRSSCheck().warnWhenExceeds(314572800) // 300 MB in bytes * ``` */ warnWhenExceeds(value: string | number): this; /** * Defines the RSS 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 MemoryRSSCheck().failWhenExceeds('400 mb') * // or * const check2 = new MemoryRSSCheck().failWhenExceeds(419430400) // 400 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 total system memory * * @param valueInPercentage - The percentage threshold for warnings (0-100) * * @example * ```typescript * const check = new MemoryRSSCheck().warnWhenExceedsPercentage(70) * ``` */ 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 total system memory * * @param valueInPercentage - The percentage threshold for errors (0-100) * * @example * ```typescript * const check = new MemoryRSSCheck().failWhenExceedsPercentage(85) * ``` */ failWhenExceedsPercentage(valueInPercentage: number): this; /** * Defines a custom callback to compute the RSS size. Defaults to * using the "process.memoryUsage()" method call * * @param callback - Function that returns memory usage information * * @example * ```typescript * const rssCheck = new MemoryRSSCheck() * .compute(() => { * // Custom RSS computation logic * const usage = process.memoryUsage() * return { ...usage, rss: usage.rss * 0.9 } // Custom adjustment * }) * ``` */ compute(callback: () => NodeJS.MemoryUsage): this; /** * Executes the RSS memory usage check */ run(): Promise; }