@nwire/bus
v0.7.1
Published
Nwire — cross-service event bus contract. EventBus interface + InMemoryEventBus default. Production adapters land as @nwire/bus-nats, @nwire/bus-redis, @nwire/bus-kafka.
Readme
@nwire/bus
Cross-service event bus contract — pub/sub for events that leave one service and reach another.
What it does
Defines EventBus, the publish-subscribe contract used to fan domain events across deployable services. Within one service the runtime fans events to in-process actors/projections/reactions; across services those same events flow through this bus (NATS in production, in-memory in tests). Ships InMemoryEventBus for dev/tests; swap in @nwire/bus-nats (or any other adapter) by config.
Install
pnpm add @nwire/busQuick start
import { InMemoryEventBus } from "@nwire/bus";
import { learnflowApp } from "@amit/learnflow";
const bus = new InMemoryEventBus();
const app = learnflowApp.create({ bus, publishToBus: true });
await app.start();
// Cross-service subscribers can now react to `learnflow.StudentWasEnrolled` etc.API surface
EventBus—publish(message)+subscribe(eventName, handler) => unsubscribe.InMemoryEventBus— in-process default for tests / single-service deployments.BusEventMessage/BusSubscriber— wire types.
When to use
When the system is deployed as more than one process (split services, microservices).
Within nwire-app
For developers using this package as part of the Nwire stack — register it via app.use(...) or it auto-wires when you compose createApp({ modules }).
import { createApp } from "@nwire/forge";
const app = createApp({
/* ...config... */
});
// Adapter/plugin wiring happens here when applicable.