@data-loom/postgrest-js
Version:
Isomorphic PostgREST client
45 lines • 1.19 kB
TypeScript
/**
* TraceIdGenerator
*
* A singleton class for generating auto-incrementing trace IDs within a process.
* Each call to next() returns a unique, incremented number.
*
* @example
* const traceId = traceIdGenerator.next();
*/
declare class TraceIdGenerator {
/**
* The singleton instance of TraceIdGenerator.
*/
private static instance;
/**
* The current trace id value.
*/
private counter;
private constructor();
/**
* Get the singleton instance of TraceIdGenerator.
* @returns {TraceIdGenerator}
*/
static getInstance(): TraceIdGenerator;
/**
* Get the next trace id (auto-increment).
* @returns {number} The next trace id.
*/
next(): number;
/**
* Get the current trace id (without increment).
* @returns {number} The current trace id.
*/
getCurrent(): number;
/**
* Reset the trace id counter to 1. (For testing or special use only)
*/
reset(): void;
}
/**
* The singleton instance for trace id generation.
*/
declare const traceIdGenerator: TraceIdGenerator;
export { TraceIdGenerator, traceIdGenerator };
//# sourceMappingURL=trace-id.d.ts.map