refactor: unify inbound debounce policy and split gateway/models helpers

This commit is contained in:
Peter Steinberger
2026-03-03 00:54:28 +00:00
parent 7de4204e57
commit 47083460ea
13 changed files with 415 additions and 192 deletions

View File

@@ -39,14 +39,16 @@ type DebounceBuffer<T> = {
debounceMs: number;
};
export function createInboundDebouncer<T>(params: {
export type InboundDebounceCreateParams<T> = {
debounceMs: number;
buildKey: (item: T) => string | null | undefined;
shouldDebounce?: (item: T) => boolean;
resolveDebounceMs?: (item: T) => number | undefined;
onFlush: (items: T[]) => Promise<void>;
onError?: (err: unknown, items: T[]) => void;
}) {
};
export function createInboundDebouncer<T>(params: InboundDebounceCreateParams<T>) {
const buffers = new Map<string, DebounceBuffer<T>>();
const defaultDebounceMs = Math.max(0, Math.trunc(params.debounceMs));