MCPcopy
hub / github.com/foru17/neko-master / add

Method add

apps/collector/src/modules/collector/batch-buffer.ts:95–123  ·  view source on GitHub ↗
(backendId: number, update: TrafficUpdate)

Source from the content-addressed store, hash-verified

93 private logCounter = 0;
94
95 add(backendId: number, update: TrafficUpdate) {
96 const minuteKey = toMinuteKey(update.timestampMs);
97 const fullChain = update.chains.join(" > ");
98 const key = [
99 backendId,
100 minuteKey,
101 update.domain,
102 update.ip,
103 update.chain,
104 fullChain,
105 update.rule,
106 update.rulePayload,
107 update.sourceIP || "",
108 ].join(":");
109 const existing = this.buffer.get(key);
110 const connections = normalizeConnections(update.connections);
111
112 if (existing) {
113 existing.upload += update.upload;
114 existing.download += update.download;
115 existing.connections =
116 normalizeConnections(existing.connections) + connections;
117 if ((update.timestampMs ?? 0) > (existing.timestampMs ?? 0)) {
118 existing.timestampMs = update.timestampMs;
119 }
120 } else {
121 this.buffer.set(key, { ...update, connections });
122 }
123 }
124
125 addGeoResult(result: GeoIPResult) {
126 this.geoQueue.push(result);

Callers 15

createCollectorFunction · 0.95
createSurgeCollectorFunction · 0.95
flushMethod · 0.80
createAppFunction · 0.80
recordTrafficMethod · 0.80
mergeTopDomainsMethod · 0.80
mergeTopIPsMethod · 0.80
mergeIPStatsPaginatedMethod · 0.80
mergeProxyDomainsMethod · 0.80
mergeProxyIPsMethod · 0.80
mergeDeviceDomainsMethod · 0.80

Calls 2

normalizeConnectionsFunction · 0.85
toMinuteKeyFunction · 0.70

Tested by

no test coverage detected