@accordkit/tracer - v0.2.1
    Preparing search index...

    Interface BufferedSink

    Extended sink interface that supports buffering and explicit cleanup.

    Buffered sinks can improve performance by batching events before writing to the underlying storage. They also provide explicit control over flushing and cleanup.

    • Consider implementing this interface for network or disk-based sinks
    • Ensure proper cleanup in application shutdown scenarios
    • Document any size/time limits on buffering
    // Usage in a Node.js application with a sink like FileSink
    import { FileSink } from './fileSink'; // Assuming FileSink implements BufferedSink

    const sink = new FileSink({ delivery: 'buffered' });

    // In your application logic...
    // sink.write('session-abc', event1);
    // sink.write('session-abc', event2);

    // On application shutdown, ensure all buffered events are written.
    async function onShutdown() {
    if (sink.close) {
    await sink.close();
    }
    process.exit(0);
    }

    process.on('SIGINT', onShutdown);
    process.on('SIGTERM', onShutdown);
    interface BufferedSink {
        write(sessionId: string, e: TracerEvent): void | Promise<void>;
        flush(): Promise<void>;
        close?(): Promise<void>;
    }

    Hierarchy (View Summary)

    Implemented by

    Index

    Methods

    • Persist a single event for a session.

      Parameters

      • sessionId: string

        Unique identifier for grouping related events. Used for partitioning and log file naming.

      • e: TracerEvent

        The trace event to persist. See TracerEvent for structure.

      Returns void | Promise<void>

      Void or Promise for async implementations.

      Implementations should:

      • Handle errors gracefully without throwing
      • Consider batching for performance if needed
      • Maintain order of events within a session
      • Be thread-safe if used in concurrent environments
    • Flush any buffered events to the underlying storage.

      Returns Promise<void>

      Promise that resolves when all buffered events are persisted

    • Optional cleanup method for releasing resources.

      Returns Promise<void>

      Promise that resolves when cleanup is complete

      Implementations should:

      • Flush any remaining buffered events
      • Close network connections or file handles
      • Release any other held resources