mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	Use Map and Set
This commit is contained in:
		
							parent
							
								
									3cbbefff1d
								
							
						
					
					
						commit
						d16b17b2bd
					
				@ -15,16 +15,17 @@ type GaugeDefinition<T> = {
 | 
			
		||||
    map: MapResult<T>;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
type Task = () => Promise<void>;
 | 
			
		||||
export class DbMetricsMonitor {
 | 
			
		||||
    private tasks: (() => Promise<void>)[] = [];
 | 
			
		||||
    private gauges: Record<string, Gauge<string>> = {};
 | 
			
		||||
    private tasks: Set<Task> = new Set();
 | 
			
		||||
    private gauges: Map<string, Gauge<string>> = new Map();
 | 
			
		||||
 | 
			
		||||
    constructor() {}
 | 
			
		||||
 | 
			
		||||
    registerGaugeDbMetric<T>(definition: GaugeDefinition<T>) {
 | 
			
		||||
        const gauge = createGauge(definition);
 | 
			
		||||
        this.gauges[definition.name] = gauge;
 | 
			
		||||
        this.tasks.push(async () => {
 | 
			
		||||
        this.gauges.set(definition.name, gauge);
 | 
			
		||||
        this.tasks.add(async () => {
 | 
			
		||||
            const result = await definition.query();
 | 
			
		||||
            if (result) {
 | 
			
		||||
                const { count, labels } = definition.map(result);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user