• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mongodb-js / mongodb-mcp-server / 16194572196

10 Jul 2025 12:03PM UTC coverage: 74.831% (-0.8%) from 75.613%
16194572196

Pull #343

github

web-flow
Merge bf41f0d84 into 5ac06d0fb
Pull Request #343: fix: turn atlas-connect-cluster async

356 of 564 branches covered (63.12%)

Branch coverage included in aggregate %.

33 of 51 new or added lines in 3 files covered. (64.71%)

2 existing lines in 1 file now uncovered.

863 of 1065 relevant lines covered (81.03%)

56.78 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

69.23
/src/telemetry/eventCache.ts
1
import { LRUCache } from "lru-cache";
2
import { BaseEvent } from "./types.js";
3

4
/**
5
 * Singleton class for in-memory telemetry event caching
6
 * Provides a central storage for telemetry events that couldn't be sent
7
 * Uses LRU cache to automatically drop oldest events when limit is exceeded
8
 */
9
export class EventCache {
10
    private static instance: EventCache;
11
    private static readonly MAX_EVENTS = 1000;
36✔
12

13
    private cache: LRUCache<number, BaseEvent>;
14
    private nextId = 0;
38✔
15

16
    constructor() {
17
        this.cache = new LRUCache({
38✔
18
            max: EventCache.MAX_EVENTS,
19
            // Using FIFO eviction strategy for events
20
            allowStale: false,
21
            updateAgeOnGet: false,
22
        });
23
    }
24

25
    /**
26
     * Gets the singleton instance of EventCache
27
     * @returns The EventCache instance
28
     */
29
    public static getInstance(): EventCache {
30
        if (!EventCache.instance) {
34✔
31
            EventCache.instance = new EventCache();
29✔
32
        }
33
        return EventCache.instance;
34✔
34
    }
35

36
    /**
37
     * Gets a copy of the currently cached events
38
     * @returns Array of cached BaseEvent objects
39
     */
40
    public getEvents(): BaseEvent[] {
41
        return Array.from(this.cache.values());
33✔
42
    }
43

44
    /**
45
     * Appends new events to the cached events
46
     * LRU cache automatically handles dropping oldest events when limit is exceeded
47
     * @param events - The events to append
48
     */
49
    public appendEvents(events: BaseEvent[]): void {
50
        for (const event of events) {
×
51
            this.cache.set(this.nextId++, event);
×
52
        }
53
    }
54

55
    /**
56
     * Clears all cached events
57
     */
58
    public clearEvents(): void {
59
        this.cache.clear();
×
60
        this.nextId = 0;
×
61
    }
62
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc