docs: refresh explainers + adding-a-feature with full binder signature
di-explainer and data-flow-explainer narratives still showed the pre-ADR-014 1-arg bindProductionBlog(config) form. Updated both explainers to (config, tracer, logger, bus, queue), and adjusted the narrative arc so the production-swap step mentions the resolveEventsAndJobs* preamble. adding-a-feature's Step 16 sketch was the same 1-arg shape; replaced with the canonical 5-arg signature and a short note that the bus/queue params are accept-and-forward until gen event consume / gen job generators inject usage at the anchors. Pointer to a real feature's bind-production.ts for the complete reference. Final sweep is clean — no stale (container, config) or 1-arg bindProduction signatures remain in docs/.
This commit is contained in:
@@ -926,20 +926,44 @@ describe("CommentsRepository", () => {
|
||||
|
||||
### Step 16: `bind-production.ts`
|
||||
|
||||
The full canonical shape includes instrumentation (ADR-014) and the
|
||||
event-bus + job-queue parameters (ADR-015) — see any feature's
|
||||
`bind-production.ts` for a complete reference. Minimal sketch:
|
||||
|
||||
```typescript
|
||||
// src/di/bind-production.ts
|
||||
import type { SanitizedConfig } from "payload";
|
||||
import {
|
||||
withSpan,
|
||||
withCapture,
|
||||
type ITracer,
|
||||
type ILogger,
|
||||
} from "@repo/core-shared/instrumentation";
|
||||
import type { IEventBus } from "@repo/core-events";
|
||||
import type { IJobQueue } from "@repo/core-shared/jobs";
|
||||
import { commentsContainer } from "./container";
|
||||
import { COMMENTS_SYMBOLS } from "./symbols";
|
||||
import { CommentsRepository } from "../infrastructure/repositories/comments.repository";
|
||||
|
||||
export function bindProductionComments(config: SanitizedConfig): void {
|
||||
export function bindProductionComments(
|
||||
config: SanitizedConfig,
|
||||
tracer: ITracer,
|
||||
logger: ILogger,
|
||||
bus: IEventBus,
|
||||
queue: IJobQueue,
|
||||
): void {
|
||||
if (commentsContainer.isBound(COMMENTS_SYMBOLS.ICommentsRepository)) {
|
||||
commentsContainer.unbind(COMMENTS_SYMBOLS.ICommentsRepository);
|
||||
}
|
||||
const repo = new CommentsRepository(config, tracer, logger);
|
||||
commentsContainer
|
||||
.bind(COMMENTS_SYMBOLS.ICommentsRepository)
|
||||
.toConstantValue(new CommentsRepository(config));
|
||||
.toConstantValue(repo);
|
||||
// Use cases + controllers are wrapped with withSpan(withCapture(...))
|
||||
// at bind time. bus + queue are accept-and-forward until you add an
|
||||
// event handler or job — at which point the gen event consume / gen job
|
||||
// generators inject usage at the // <gen:event-handlers> / // <gen:jobs>
|
||||
// anchors at the end of the function body.
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user