Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

983 B
Raw Blame
export interface BatchWritingStoreFlushStats {
    dirtyEntryCount: number
    referencedBatchCount: number
    cacheEntryCount: number
}

export interface BatchWritingStore<TFlushResult = unknown> {
    /*
     * Returns a point-in-time summary of entries that would be captured by
     * flush(), plus the batch IDs that currently reference those dirty entries.
     */
    getFlushStats(): BatchWritingStoreFlushStats

    /*
     * Flushes all batch data that needs to be written
     * Returns Kafka messages that need to be sent
     */
    flush(): Promise<TFlushResult[]>

    /*
     * Releases cache entries associated with the given batch ID.
     * Uses reference counting so entries shared across concurrent batches
     * are only evicted when all referencing batches have completed.
     */
    releaseBatch(batchId: number): void

    /*
     * Stops background work and flushes remaining metrics. Called on graceful shutdown.
     */
    shutdown(): Promise<void>
}