MCPcopy Create free account
hub / github.com/GCWing/BitFun / flush

Method flush

src/web-ui/src/flow_chat/services/EventBatcher.ts:170–196  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

168 }
169
170 private flush(): void {
171 if (this.buffer.size === 0) return;
172
173 const startTime = nowMs();
174 const bufferedEvents = Array.from(this.buffer.values());
175 const logPayload = getBatchedEventsLogPayload(bufferedEvents);
176 const { rawEventCount, mergedEventCount } = logPayload;
177
178 const events = bufferedEvents.map(({ key, payload }) => ({
179 key,
180 payload
181 }));
182
183 log.trace('Flushing batched events', logPayload);
184
185 this.buffer = new Map();
186 this.onFlush(events);
187
188 const durationMs = elapsedMs(startTime);
189 if (durationMs > 10) {
190 log.warn('Event batch processing took longer than expected', {
191 rawEventCount,
192 mergedEventCount,
193 durationMs,
194 });
195 }
196 }
197
198 flushNow(): void {
199 if (this.frameId !== null) {

Callers 2

scheduleFlushMethod · 0.95
flushNowMethod · 0.95

Calls 6

nowMsFunction · 0.90
elapsedMsFunction · 0.90
traceMethod · 0.80
warnMethod · 0.80
fromMethod · 0.45

Tested by

no test coverage detected