@dudousxd/nestjs-telescope
Version:
Laravel Telescope-style observability console for NestJS — core: watchers, recorder, correlation, SQLite store, headless API.
48 lines • 2.77 kB
TypeScript
import type { Entry } from '../entry/entry.js';
import type { RollupBucket, RollupDelta, RollupStore } from '../rollup/rollup-store.js';
import type { BoundedPruneCapable, BoundedPruneResult, BoundedPruneScope, EntryQuery, EntryWithBatch, LeaseCapableStorage, Page, PruneScope, TagCount, TagQuery } from './storage-provider.js';
/**
* Process-local store. Used as a test double and as a zero-dependency option
* for single-instance/serverless setups. Newest-first ordering by createdAt
* then id; cursor is an opaque keyset (createdAt-ms, id) position.
*
* Declared against {@link BoundedPruneCapable} and {@link LeaseCapableStorage}
* (both of which extend `StorageProvider`) so dropping either capability from
* this class is a compile error rather than a silent fall back to unbounded,
* unlocked pruning.
*/
export declare class InMemoryStorageProvider implements BoundedPruneCapable, LeaseCapableStorage, RollupStore {
private entries;
/** Materialized rollups keyed `${metric}|${bucketStart}`. */
private rollups;
/**
* Process-local lease table. Only ever exclusive WITHIN this process, which is
* exactly right: an in-memory store is not shared between replicas, so there is
* no fleet to coordinate — this exists so the lock path behaves identically on
* every provider rather than being a special case.
*/
private readonly leases;
store(entries: Entry[]): Promise<void>;
update(id: string, patch: Partial<Entry>): Promise<void>;
find(id: string): Promise<EntryWithBatch | null>;
get(query: EntryQuery): Promise<Page<Entry>>;
batch(batchId: string): Promise<Entry[]>;
tags(prefix?: string, query?: TagQuery): Promise<TagCount[]>;
prune(olderThan: Date, keepLast?: number): Promise<number>;
pruneScoped(input: PruneScope): Promise<number>;
pruneScopedBatch(input: BoundedPruneScope): Promise<BoundedPruneResult>;
tryAcquireLease(key: string, owner: string, ttlMs: number, nowMs: number): Promise<boolean>;
releaseLease(key: string, owner: string): Promise<void>;
clear(): Promise<void>;
/** Last-seen wall time (ms) per error family, backing the shared new-exception
* dedup. In a single process this is exactly the per-replica behaviour; the
* real cross-pod win comes from the SQLite/Redis providers that share a store. */
private readonly seenFamilies;
markFamilySeen(familyHash: string, nowMs: number, windowMs: number): Promise<boolean>;
recordRollups(deltas: RollupDelta[]): Promise<void>;
queryRollups(metrics: string[], fromBucket: number, toBucket: number): Promise<RollupBucket[]>;
private matches;
private newestFirst;
private oldestFirst;
}
//# sourceMappingURL=in-memory-storage-provider.d.ts.map