mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 07:22:44 +00:00
refactor: unify inbound debounce policy and split gateway/models helpers
This commit is contained in:
@@ -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));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user