@hexmon_tech/audit-buffer-disk
v2.0.0
Published
Disk-backed buffer for audit events with replay support.
Maintainers
Readme
@hexmon_tech/audit-buffer-disk
Disk-backed buffer for audit events in Node.js. Use this sink to persist events locally and replay them to another sink when it becomes available.
Install
pnpm add @hexmon_tech/audit-buffer-disk
npm install @hexmon_tech/audit-buffer-diskCompatibility
- Node.js >= 18
- Optimized for Linux/Unix filesystems with durable writes
Usage
import { createAuditLogger } from '@hexmon_tech/audit-core';
import { createDiskBuffer } from '@hexmon_tech/audit-buffer-disk';
import { createHttpAuditSink } from '@hexmon_tech/audit-sink-http';
const buffer = createDiskBuffer({
filePath: './tmp/audit-buffer.jsonl',
maxBufferBytes: 50 * 1024 * 1024,
});
const audit = createAuditLogger({
sinks: [buffer],
});
// Later (cron/background job) flush to a primary sink
const httpSink = createHttpAuditSink({ endpoint: 'https://audit.example.com/batch' });
await buffer.drain(httpSink, { batchSize: 200 });Notes
createDiskBufferreturns anAuditSinkplus adrainmethod for replay.- Draining is at-least-once; downstream sinks should de-duplicate by
eventId. maxBufferBytesprotects disk usage and rejects writes when exceeded.
