Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .agents/rules/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ describe("Feature Name", () => {
describe("specific function/method", () => {
it("should do something specific", () => {
// GIVEN
const input = {
/* ... */
};
const input = {/* ... */};

// WHEN
const result = functionUnderTest(input);
Expand Down
52 changes: 13 additions & 39 deletions docs/guide/connection-sharing.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ const client = await TypedAmqpClient.create({
const worker = await TypedAmqpWorker.create({
contract,
urls: ["amqp://localhost"],
handlers: {
/* ... */
},
handlers: {/* ... */},
}).getOrThrow();

// Close components when done
Expand Down Expand Up @@ -115,9 +113,7 @@ const client = await TypedAmqpClient.create({
const worker = await TypedAmqpWorker.create({
contract,
urls: ["amqp://localhost"], // ← URLs match = shared connection
handlers: {
/* ... */
},
handlers: {/* ... */},
}).getOrThrow();

// Result: 1 connection, 2 channels ✅
Expand Down Expand Up @@ -150,17 +146,13 @@ const notificationClient = await TypedAmqpClient.create({
const orderWorker = await TypedAmqpWorker.create({
contract: orderContract,
urls: ["amqp://localhost"], // ← Same URLs
handlers: {
/* ... */
},
handlers: {/* ... */},
}).getOrThrow();

const notificationWorker = await TypedAmqpWorker.create({
contract: notificationContract,
urls: ["amqp://localhost"], // ← Same URLs
handlers: {
/* ... */
},
handlers: {/* ... */},
}).getOrThrow();

// All automatically share one connection with 4 separate channels
Expand Down Expand Up @@ -209,9 +201,7 @@ const worker = await TypedAmqpWorker.create({
contract,
urls: ["amqp://localhost"],
connectionOptions, // ← Same options = connection shared
handlers: {
/* ... */
},
handlers: {/* ... */},
}).getOrThrow();

// ✅ Also good: Omit options to use defaults
Expand All @@ -223,9 +213,7 @@ const client = await TypedAmqpClient.create({
const worker = await TypedAmqpWorker.create({
contract,
urls: ["amqp://localhost"], // ← No options = connection shared
handlers: {
/* ... */
},
handlers: {/* ... */},
}).getOrThrow();
```

Expand All @@ -252,9 +240,7 @@ const client = await TypedAmqpClient.create({
const worker = await TypedAmqpWorker.create({
contract: orderContract,
...AMQP_CONFIG,
handlers: {
/* ... */
},
handlers: {/* ... */},
}).getOrThrow();
```

Expand All @@ -274,9 +260,7 @@ const worker = await TypedAmqpWorker.create({
contract,
urls: ["amqp://localhost"],
connectionOptions: { heartbeatIntervalInSeconds: 60 }, // ← Options B (different)
handlers: {
/* ... */
},
handlers: {/* ... */},
}).getOrThrow();

// Result: 2 separate connections (different configurations)
Expand Down Expand Up @@ -357,9 +341,7 @@ const client = await TypedAmqpClient.create({
const worker = await TypedAmqpWorker.create({
contract,
urls: ["amqp://localhost"], // ← Same URLs = connection automatically shared
handlers: {
/* ... */
},
handlers: {/* ... */},
}).getOrThrow();

// No code changes needed - connection sharing just works!
Expand All @@ -383,9 +365,7 @@ Connection sharing is automatic when URLs and connection options match. If you s
const worker = await TypedAmqpWorker.create({
contract,
urls: ["amqp://localhost"], // Different URL!
handlers: {
/* ... */
},
handlers: {/* ... */},
}).getOrThrow();

// ✅ Same URLs = shared connection
Expand All @@ -397,9 +377,7 @@ Connection sharing is automatic when URLs and connection options match. If you s
const worker = await TypedAmqpWorker.create({
contract,
urls, // Same URL reference
handlers: {
/* ... */
},
handlers: {/* ... */},
}).getOrThrow();
```

Expand All @@ -416,9 +394,7 @@ Connection sharing is automatic when URLs and connection options match. If you s
contract,
urls: ["amqp://localhost"],
connectionOptions: { heartbeatIntervalInSeconds: 60 }, // Different!
handlers: {
/* ... */
},
handlers: {/* ... */},
}).getOrThrow();

// ✅ Same options = shared connection
Expand All @@ -432,9 +408,7 @@ Connection sharing is automatic when URLs and connection options match. If you s
contract,
urls: ["amqp://localhost"],
connectionOptions, // Same options reference
handlers: {
/* ... */
},
handlers: {/* ... */},
}).getOrThrow();
```

Expand Down
16 changes: 4 additions & 12 deletions docs/guide/defining-contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,8 @@ export const contract = defineContract({

```typescript
const contract = defineContract({
publishers: {
/* ... */
},
consumers: {
/* ... */
},
publishers: {/* ... */},
consumers: {/* ... */},
});
```

Expand Down Expand Up @@ -526,9 +522,7 @@ const contract = defineContract({
orderCreated: orderCreatedEvent,
orderUpdated: orderUpdatedPublisher,
},
consumers: {
/* ... */
},
consumers: {/* ... */},
});
```

Expand Down Expand Up @@ -751,9 +745,7 @@ const failedOrderEvent = defineEventPublisher(ordersDlx, orderMessage, {

// 5. Compose the contract - DLX exchange is auto-extracted from queue's deadLetter config
export const contract = defineContract({
publishers: {
/* ... */
},
publishers: {/* ... */},
consumers: {
processOrder: defineEventConsumer(orderCreatedEvent, orderProcessingQueue),
// DLX consumer: binds ordersDlxQueue to ordersDlx with routing key "order.failed"
Expand Down
4 changes: 1 addition & 3 deletions docs/guide/message-compression.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,7 @@ Unsupported encodings throw errors during consumption:
Test compression with your actual data:

```typescript
const testData = {
/* your typical message */
};
const testData = {/* your typical message */};
const json = JSON.stringify(testData);
console.log("Original size:", json.length, "bytes");

Expand Down
4 changes: 1 addition & 3 deletions examples/basic-order-processing-contract/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ const client = await TypedAmqpClient.create({
urls: ["amqp://localhost"],
}).getOrThrow();

await client.publish("orderCreated", {
/* fully typed */
});
await client.publish("orderCreated", {/* fully typed */});
```

## Patterns Demonstrated
Expand Down
Loading
Loading