@reclaimprotocol/attestor-core
Version:
<div> <div> <img src="https://raw.githubusercontent.com/reclaimprotocol/.github/main/assets/banners/Attestor-Core.png" /> </div> </div>
62 lines (61 loc) • 1.53 kB
TypeScript
/**
* Resource monitor for tracking resources and preventing leaks.
* Provides debugging capabilities and resource management.
*/
import type { Logger } from '../types';
export interface ResourceInfo {
id: string;
type: string;
createdAt: Date;
metadata?: any;
}
export declare class ResourceMonitor {
private static instance;
private resources;
private logger;
private constructor();
/**
* Get or create the singleton ResourceMonitor instance.
*/
static getInstance(logger: Logger): ResourceMonitor;
/**
* Track a new resource.
*/
trackResource(id: string, type: string, metadata?: any): void;
/**
* Untrack a resource.
*/
untrackResource(id: string): boolean;
/**
* Check if a resource is tracked.
*/
isTracked(id: string): boolean;
/**
* Get information about a specific resource.
*/
getResource(id: string): ResourceInfo | undefined;
/**
* Get all tracked resources.
*/
getAllResources(): ResourceInfo[];
/**
* Get resources by type.
*/
getResourcesByType(type: string): ResourceInfo[];
/**
* Get resources older than a specific age.
*/
getResourcesOlderThan(ageMs: number): ResourceInfo[];
/**
* Log resource statistics.
*/
logStats(): void;
/**
* Clear all tracked resources (for testing/cleanup).
*/
clear(): void;
/**
* Reset the singleton instance (for testing).
*/
static reset(): void;
}