Skip to main content

Interface: EventBufferConfig

Gala Launchpad SDK 9.0.0-rc.5


Gala Launchpad SDK 9.0.0-rc.5 / index / EventBufferConfig

Interface: EventBufferConfig

Defined in: packages/launchpad-sdk/dist/utils/websocket-patterns.d.ts:552

Event Buffer with Auto-Cleanup

Buffers events with TTL (time-to-live) and max size limits. Old events are automatically expired and removed.

Features:

  • Configurable TTL per event
  • Max size enforcement (FIFO eviction when full)
  • Automatic expiration cleanup
  • Memory-efficient

Example​

// Test case: Event buffering with TTL and size limits
interface LogEvent { id: string; message: string }

const buffer = new EventBufferWithAutoCleanup<LogEvent>({
maxSize: 5,
defaultTtlMs: 2000
});

// Add events
buffer.push({ id: 'e1', message: 'Event 1' });
buffer.push({ id: 'e2', message: 'Event 2' });
console.assert(buffer.getAll().length === 2);

// Wait for TTL expiration
await new Promise(r => setTimeout(r, 2100));
// Manual cleanup (normally automatic)
buffer.clear(); // Or events auto-expire

// Max size enforcement
const buffer2 = new EventBufferWithAutoCleanup<LogEvent>({
maxSize: 3,
defaultTtlMs: 10000
});
buffer2.push({ id: 'a', message: 'A' });
buffer2.push({ id: 'b', message: 'B' });
buffer2.push({ id: 'c', message: 'C' });
buffer2.push({ id: 'd', message: 'D' }); // Oldest (a) is evicted
console.assert(buffer2.getAll().length === 3);
console.assert(!buffer2.getAll().some(e => e.id === 'a'));

Type Param​

TEvent

Event type being buffered

Since​

6.6.0

Properties​

defaultTtlMs?​

optional defaultTtlMs?: number

Defined in: packages/launchpad-sdk/dist/utils/websocket-patterns.d.ts:554


maxSize?​

optional maxSize?: number

Defined in: packages/launchpad-sdk/dist/utils/websocket-patterns.d.ts:553