Function createSimpleEventBroker

Creates a local event broker configured with domain event handlers.

The broker automatically wires each handler to its source topic and propagates resulting events. Includes default error handling with console logging.

const broker = createSimpleEventBroker([
createArvoOrchestrator(...),
createArvoEventHandler(...)
]);

await broker.publish(createArvoEvent({
type: 'com.openai.completion',
data: {...}
}));
  • Parameters

    • eventHandlers: AbstractArvoEventHandler[]

      Array of event handlers to register with the broker

    • Optionaloptions: {
          onDomainedEvents?: ((param: {
              broker: SimpleEventBroker;
              events: Record<string, ArvoEvent<Record<string, any>, Record<string,
                  | null
                  | string
                  | number
                  | boolean>, string>[]>;
          }) => void);
          onError?: ((error: Error, event: ArvoEvent<Record<string, any>, Record<string,
              | null
              | string
              | number
              | boolean>, string>) => void);
      }

      Configuration options

      • OptionalonDomainedEvents?: ((param: {
            broker: SimpleEventBroker;
            events: Record<string, ArvoEvent<Record<string, any>, Record<string,
                | null
                | string
                | number
                | boolean>, string>[]>;
        }) => void)

        Callback for handling domain-specific events

          • (param): void
          • Parameters

            • param: {
                  broker: SimpleEventBroker;
                  events: Record<string, ArvoEvent<Record<string, any>, Record<string,
                      | null
                      | string
                      | number
                      | boolean>, string>[]>;
              }
              • broker: SimpleEventBroker
              • events: Record<string, ArvoEvent<Record<string, any>, Record<string,
                    | null
                    | string
                    | number
                    | boolean>, string>[]>

            Returns void

      • OptionalonError?: ((error: Error, event: ArvoEvent<Record<string, any>, Record<string,
            | null
            | string
            | number
            | boolean>, string>) => void)

        Custom error handler for broker errors

          • (error, event): void
          • Parameters

            • error: Error
            • event: ArvoEvent<Record<string, any>, Record<string,
                  | null
                  | string
                  | number
                  | boolean>, string>

            Returns void

    Returns SimpleEventBroker

    Configured SimpleEventBroker instance with handlers subscribed