Libraries
    Preparing search index...

    Production-grade batching wrapper for log sinks.

    Provides buffering, retry with exponential backoff, and circuit breaking. All network/file sinks use this internally.

    const sink = new BatchingSink({
    batchSize: 100,
    flushInterval: 2000,
    emit: async (batch) => {
    await fetch('/logs', { method: 'POST', body: JSON.stringify(batch) });
    },
    });

    Implements

    Index

    Constructors

    Methods

    Constructors

    Methods

    • Buffers events and triggers a background flush when the batch size threshold is reached. Returns immediately — callers are never blocked by network I/O.

      Parameters

      Returns Promise<void>

    • Flushes buffered events to the underlying sink.

      If a flush is already in progress, returns that same promise so that multiple concurrent callers share a single write rather than spawning concurrent network requests.

      Returns Promise<void>