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

andrzej-woof / stuntman / 8908932552

01 May 2024 11:48AM UTC coverage: 81.27%. Remained the same
8908932552

push

github

andrzej-woof
and again

611 of 668 branches covered (91.47%)

Branch coverage included in aggregate %.

2218 of 2813 relevant lines covered (78.85%)

13.32 hits per line

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

93.02
/packages/server/src/storage.ts
1
import { LRUCache } from 'lru-cache';
1✔
2
import type * as Stuntman from '@stuntman/shared';
1✔
3
import sizeof from 'object-sizeof';
1✔
4

1✔
5
const DNS_CACHE_OPTIONS: any = {
1✔
6
    max: 1000,
1✔
7
    ttl: 1000 * 60 * 15,
1✔
8
    allowStale: false,
1✔
9
    updateAgeOnGet: false,
1✔
10
    updateAgeOnHas: false,
1✔
11
};
1✔
12

1✔
13
const trafficStoreInstances: Record<string, LRUCache<string, Stuntman.LogEntry>> = {};
1✔
14
const dnsResolutionCacheInstances: Record<string, LRUCache<string, string>> = {};
1✔
15

1✔
16
export const getTrafficStore = (key: string, options?: Stuntman.StorageConfig) => {
1✔
17
    if (!(key in trafficStoreInstances)) {
18✔
18
        if (!options) {
16!
19
            throw new Error('initialize with options first');
×
20
        }
×
21
        trafficStoreInstances[key] = new LRUCache<string, Stuntman.LogEntry>({
16✔
22
            max: options.limitCount,
16✔
23
            maxSize: options.limitSize,
16✔
24
            ttl: options.ttl,
16✔
25
            allowStale: false,
16✔
26
            updateAgeOnGet: false,
16✔
27
            updateAgeOnHas: false,
16✔
28
            sizeCalculation: (value) => sizeof(value),
16✔
29
        });
16✔
30
    }
16✔
31
    return trafficStoreInstances[key]!;
18✔
32
};
18✔
33

1✔
34
export const getDnsResolutionCache = (key: string) => {
1✔
35
    if (!(key in dnsResolutionCacheInstances)) {
20✔
36
        dnsResolutionCacheInstances[key] = new LRUCache<string, string>(DNS_CACHE_OPTIONS);
20✔
37
    }
20✔
38
    return dnsResolutionCacheInstances[key]!;
20✔
39
};
20✔
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