/** * Copyright 2019, 2023 Optimizely * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { Managed } from './managed'; export declare type EventQueueSink = (buffer: K[]) => Promise; export interface EventQueue extends Managed { enqueue(event: K): void; } export interface EventQueueFactory { createEventQueue(config: { sink: EventQueueSink; flushInterval: number; maxQueueSize: number; }): EventQueue; } declare class Timer { private timeout; private callback; private timeoutId?; constructor({ timeout, callback }: { timeout: number; callback: () => void; }); start(): void; refresh(): void; stop(): void; } export declare class SingleEventQueue implements EventQueue { private sink; constructor({ sink }: { sink: EventQueueSink; }); start(): void; stop(): Promise; enqueue(event: K): void; } export declare class DefaultEventQueue implements EventQueue { timer: Timer; private buffer; private maxQueueSize; private sink; private closingSink?; private batchComparator; private started; constructor({ flushInterval, maxQueueSize, sink, closingSink, batchComparator, }: { flushInterval: number; maxQueueSize: number; sink: EventQueueSink; closingSink?: EventQueueSink; batchComparator: (eventA: K, eventB: K) => boolean; }); start(): void; stop(): Promise; enqueue(event: K): void; flush(): void; } export {};