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

mongodb-js / mongodb-mcp-server / 17657973871

11 Sep 2025 09:37PM UTC coverage: 81.59% (+0.4%) from 81.188%
17657973871

Pull #524

github

web-flow
Merge 7617674d0 into d6b84c7bd
Pull Request #524: chore: update smithery dockerfile to be closer to the official one

962 of 1279 branches covered (75.22%)

Branch coverage included in aggregate %.

4866 of 5864 relevant lines covered (82.98%)

46.3 hits per line

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

82.61
/src/telemetry/eventCache.ts
1
import { LRUCache } from "lru-cache";
2✔
2
import type { 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 {
2✔
10
    private static instance: EventCache;
11
    private static readonly MAX_EVENTS = 1000;
46✔
12

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

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

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

36
    /**
37
     * Gets the number of currently cached events
38
     */
39
    public get size(): number {
46✔
40
        return this.cache.size;
61✔
41
    }
61✔
42

43
    /**
44
     * Gets a copy of the currently cached events along with their ids
45
     * @returns Array of cached BaseEvent objects
46
     */
47
    public getEvents(): { id: number; event: BaseEvent }[] {
46✔
48
        return Array.from(this.cache.entries()).map(([id, event]) => ({ id, event }));
65✔
49
    }
65✔
50

51
    /**
52
     * Appends new events to the cached events
53
     * LRU cache automatically handles dropping oldest events when limit is exceeded
54
     * @param events - The events to append
55
     */
56
    public appendEvents(events: BaseEvent[]): void {
46✔
57
        for (const event of events) {
×
58
            this.cache.set(this.nextId++, event);
×
59
        }
×
60
    }
×
61

62
    /**
63
     * Removes cached events by their ids
64
     */
65
    public removeEvents(ids: number[]): void {
46✔
66
        for (const id of ids) {
65!
67
            this.cache.delete(id);
×
68
        }
×
69
    }
65✔
70
}
46✔
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

© 2025 Coveralls, Inc