Size / Priority
- Size: S (~40 lines)
- Category: C.1 Pattern-Matching.
- Risk: low.
Affected files
src/io/broker/MqttActor.ts:240-251 — onReceive's cmd-kind dispatch.
Background
MqttActor is the MQTT 5.0 broker actor. Its command dispatch handles:
'publish' — emit a PUBLISH packet.
'subscribe' — emit a SUBSCRIBE packet.
'unsubscribe' — emit UNSUBSCRIBE.
- (potentially more, including user-property variants — verify during implementation).
Same pattern as #232 (JetStream): an if/else chain over discriminator strings. Adding a new cmd silently falls through without compile error.
Target code
import { match } from 'ts-pattern';
override onReceive(cmd: MqttCmd): void {
match(cmd)
.with({ kind: 'publish' }, (c) => this.handlePublish(c))
.with({ kind: 'subscribe' }, (c) => this.handleSubscribe(c))
.with({ kind: 'unsubscribe' }, (c) => this.handleUnsubscribe(c))
.exhaustive();
}
Integration / risk
Test plan
- Regression — MQTT 5.0 test suite passes.
- Compile-time — new variant in the union produces error.
- MQTT integration — message round-trip through the broker still works.
Acceptance criteria
Size / Priority
Affected files
src/io/broker/MqttActor.ts:240-251—onReceive's cmd-kind dispatch.Background
MqttActor is the MQTT 5.0 broker actor. Its command dispatch handles:
'publish'— emit a PUBLISH packet.'subscribe'— emit a SUBSCRIBE packet.'unsubscribe'— emit UNSUBSCRIBE.Same pattern as #232 (JetStream): an if/else chain over discriminator strings. Adding a new cmd silently falls through without compile error.
Target code
Integration / risk
match).Test plan
Acceptance criteria
onReceiveusesmatch().exhaustive().