@relaybus/core 0.0.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +42 -3
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -2,13 +2,52 @@
2
2
 
3
3
  The relaybus engine: transactional publishing, per-handler deliveries, leased
4
4
  dispatching, retries with jitter, dead letters, ordering keys and transport
5
- routing. Framework-free; use [`@relaybus/nestjs`](../nestjs) for NestJS.
5
+ routing. Most applications install it together with a store and, for NestJS,
6
+ the module:
6
7
 
7
8
  ```sh
8
- pnpm add @relaybus/core
9
+ pnpm add @relaybus/core @relaybus/nestjs @relaybus/postgres pg
9
10
  ```
10
11
 
11
- ## Quick start
12
+ | Package | Use it for |
13
+ | ------------------------------------------------------------------------ | ------------------------------------------------------------- |
14
+ | [`@relaybus/nestjs`](https://www.npmjs.com/package/@relaybus/nestjs) | `RelayBusModule` and the `@Subscribe` decorator |
15
+ | [`@relaybus/postgres`](https://www.npmjs.com/package/@relaybus/postgres) | PostgreSQL store (pg, Prisma, TypeORM, Knex, Kysely, Drizzle) |
16
+ | [`@relaybus/mongodb`](https://www.npmjs.com/package/@relaybus/mongodb) | MongoDB store (driver or Mongoose sessions) |
17
+ | [`@relaybus/kafka`](https://www.npmjs.com/package/@relaybus/kafka) | Kafka transport between services |
18
+ | [`@relaybus/rabbitmq`](https://www.npmjs.com/package/@relaybus/rabbitmq) | RabbitMQ transport between services |
19
+ | [`@relaybus/testing`](https://www.npmjs.com/package/@relaybus/testing) | Contract suite, fake clock, in-memory transport |
20
+
21
+ ## With NestJS
22
+
23
+ ```ts
24
+ // order.events.ts
25
+ export class OrderPlaced extends defineEvent<{ orderId: string }>('order.placed.v1') {}
26
+
27
+ // app.module.ts
28
+ @Module({ imports: [RelayBusModule.forRoot({ store: new PostgresEventStore({ pool }) })] })
29
+ export class AppModule {}
30
+
31
+ // shipping.handlers.ts: consume with a decorator
32
+ @Injectable()
33
+ export class ShippingHandlers {
34
+ @Subscribe(OrderPlaced, { retry: { attempts: 5 } })
35
+ async ship(event: EventEnvelope<{ orderId: string }>) {
36
+ /* runs after the order transaction commits */
37
+ }
38
+ }
39
+
40
+ // order.service.ts: produce inside your transaction
41
+ await this.bus.transaction(async () => {
42
+ await this.orders.insert(order);
43
+ await this.bus.publish(new OrderPlaced({ orderId: order.id }), { key: order.id });
44
+ });
45
+ ```
46
+
47
+ See the [project README](https://github.com/berkcansavur/relaybus#readme) for
48
+ guarantees and architecture.
49
+
50
+ ## Without a framework
12
51
 
13
52
  ```ts
14
53
  import { InMemoryEventStore, RelayBus, defineEvent } from '@relaybus/core';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@relaybus/core",
3
- "version": "0.0.0",
3
+ "version": "0.1.0",
4
4
  "description": "Reliable, storage-agnostic event bus: transactional outbox, per-handler deliveries, retries with jitter, dead letters and ordering keys.",
5
5
  "license": "MIT",
6
6
  "author": "Berkcan Şavur <berkcansavur@gmail.com>",