MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / add

Method add

packages/db/src/buffers/event-buffer.ts:88–111  ·  view source on GitHub ↗
(event: IClickhouseEvent)

Source from the content-addressed store, hash-verified

86 }
87
88 add(event: IClickhouseEvent) {
89 // Event-buffer's add() is synchronous (in-memory push). Measured anyway
90 // for consistency with the other buffers' add-latency tracking.
91 const start = performance.now();
92 this.pendingEvents.push(event);
93
94 if (this.pendingEvents.length >= this.microBatchMaxSize) {
95 this.flushLocalBuffer();
96 } else if (!this.flushTimer) {
97 this.flushTimer = setTimeout(() => {
98 this.flushTimer = null;
99 this.flushLocalBuffer();
100 }, this.microBatchIntervalMs);
101 }
102
103 try {
104 this.addObserver?.({
105 buffer: this.name,
106 durationMs: performance.now() - start,
107 });
108 } catch {
109 // never break add on observer failure
110 }
111 }
112
113 /** Number of events buffered locally in process memory, before Redis. */
114 public getPendingLocalCount(): number {

Callers 1

bulkAddMethod · 0.95

Calls 2

flushLocalBufferMethod · 0.95
pushMethod · 0.45

Tested by

no test coverage detected