# Class EventBus

In-memory event bus with bounded circular buffer.

Events are stored in a circular buffer. When the buffer is full, the oldest events are evicted. Subscribers receive events that match their filter. Handler errors are caught and logged.

#### Implements

- IEventBus

- Defined in packages/nexus-agents/src/pipeline/event-bus.ts:53

##### Index

### Constructors

constructor

### Accessors

totalEmitted
bufferSize
subscriptionCount

### Methods

emit
subscribe
query

## Constructors

### constructor

- new EventBus(options?: EventBusOptions): EventBus

  #### Parameters

  - `Optional` options: EventBusOptions

  #### Returns EventBus

  - Defined in packages/nexus-agents/src/pipeline/event-bus.ts:59

## Accessors

### totalEmitted

- get totalEmitted(): number

  Total events emitted (including evicted).

  #### Returns number

  Implementation of IEventBus.totalEmitted

  - Defined in packages/nexus-agents/src/pipeline/event-bus.ts:63

### bufferSize

- get bufferSize(): number

  Current buffer size.

  #### Returns number

  Implementation of IEventBus.bufferSize

  - Defined in packages/nexus-agents/src/pipeline/event-bus.ts:67

### subscriptionCount

- get subscriptionCount(): number

  Number of active subscriptions (for observability/testing).

  #### Returns number

  - Defined in packages/nexus-agents/src/pipeline/event-bus.ts:72

## Methods

### emit

- emit(event: PipelineEvent): void

  Emit an event. Handlers must not throw.

  #### Parameters

  - event: PipelineEvent

  #### Returns void

  Implementation of IEventBus.emit

  - Defined in packages/nexus-agents/src/pipeline/event-bus.ts:76

### subscribe

- subscribe(filter: EventFilter, handler: EventHandler): Unsubscribe

  Subscribe to events matching filter. Returns unsubscribe function.

  #### Parameters

  - filter: EventFilter
  - handler: EventHandler

  #### Returns Unsubscribe

  Implementation of IEventBus.subscribe

  - Defined in packages/nexus-agents/src/pipeline/event-bus.ts:82

### query

- query(filter: EventFilter, limit?: number): readonly PipelineEvent[]

  Query recent events (bounded buffer).

  #### Parameters

  - filter: EventFilter
  - `Optional` limit: number

  #### Returns readonly PipelineEvent[]

  Implementation of IEventBus.query

  - Defined in packages/nexus-agents/src/pipeline/event-bus.ts:91