(backendId: number, update: TrafficUpdate)
| 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); |
no test coverage detected