MCPcopy
hub / github.com/scality/cloudserver / startCleanupJob

Function startCleanupJob

lib/api/apiUtils/rateLimit/cleanup.js:30–47  ·  view source on GitHub ↗

* Start periodic cleanup of expired rate limit counters and cached configs * * Runs every 10 seconds to: * - Remove expired GCRA counters (where emptyAt <= now) * - Remove expired cached rate limit configs (where TTL expired) * - Remove expired cached bucket owners (where TTL expired) * * Thi

(log, options = {})

Source from the content-addressed store, hash-verified

28 * This prevents memory leaks from accumulating expired entries.
29 */
30function startCleanupJob(log, options = {}) {
31 if (cleanupTimer) {
32 log.warn('Rate limit cleanup job already running');
33 return;
34 }
35
36 log.info('Starting rate limit cleanup job', {
37 interval: rateLimitCleanupInterval,
38 });
39
40 cleanupTimer = setTimeout(() => cleanupJob(log, options), rateLimitCleanupInterval);
41
42 // Prevent cleanup job from keeping process alive
43 // Skip unref() in test environment to work with sinon fake timers
44 if (!options.skipUnref) {
45 cleanupTimer.unref();
46 }
47}
48
49/**
50 * Stop the periodic cleanup job

Callers 2

initiateStartupMethod · 0.85
cleanup.jsFile · 0.85

Calls 3

cleanupJobFunction · 0.85
warnMethod · 0.80
infoMethod · 0.80

Tested by

no test coverage detected