docs(core-events): clarify subscribe consumerFeature + failFast drop
Code-quality review nits: IEventBus.subscribe docstring said "debug tag" but InMemoryEventBus actually ignores the param entirely. Also add a comment to InMemoryEventBus.publish noting that under failFast only the first rejection rethrows; other failures are intentionally dropped. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -11,8 +11,8 @@ export interface IEventBus {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscribe a handler. `consumerFeature` is the kebab-case name of the
|
* Subscribe a handler. `consumerFeature` is the kebab-case name of the
|
||||||
* subscribing feature (e.g., "marketing-pages"). InMemoryEventBus uses it
|
* subscribing feature (e.g., "marketing-pages"). It is unused by
|
||||||
* only as a debug tag; PayloadJobsEventBus uses it to name the fan-out task
|
* InMemoryEventBus; PayloadJobsEventBus uses it to name the fan-out task
|
||||||
* slug deterministically (`__events.<event>.<consumerFeature>`).
|
* slug deterministically (`__events.<event>.<consumerFeature>`).
|
||||||
*/
|
*/
|
||||||
subscribe<T>(
|
subscribe<T>(
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ export class InMemoryEventBus implements IEventBus {
|
|||||||
);
|
);
|
||||||
if (this.options.failFast) {
|
if (this.options.failFast) {
|
||||||
const failure = settled.find((s) => s.status === "rejected");
|
const failure = settled.find((s) => s.status === "rejected");
|
||||||
|
// Only the first rejection is rethrown. Other failures are intentionally
|
||||||
|
// dropped — `failFast` is a test-affordance, not a fault-tolerance design.
|
||||||
if (failure && failure.status === "rejected") throw failure.reason;
|
if (failure && failure.status === "rejected") throw failure.reason;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user