26 lines
1.1 KiB
TypeScript
26 lines
1.1 KiB
TypeScript
// mosquitto's events entrypoint, loaded by the per-node tool host (the provisioner container runs
|
|
// ./provisioner separately). The topic lifecycle events are EMITTED from the provisioner, where the
|
|
// lifecycle actually happens (novox/hq ADR 0041/0042):
|
|
// module.mosquitto.topic.provisioned — a consumer's client + scoped role was created
|
|
// module.mosquitto.topic.deprovisioned — that client was removed
|
|
// Here in the tool host we react to them, keeping a lightweight audit trail of who was granted a
|
|
// topic namespace and who lost one — observability the provider itself is best placed to log.
|
|
|
|
import { on } from "@novox/mesh-sdk/events";
|
|
|
|
interface TopicEvent {
|
|
consumer: string;
|
|
username: string;
|
|
topicPrefix?: string;
|
|
}
|
|
|
|
await on<TopicEvent>("module.mosquitto.topic.provisioned", async (e) => {
|
|
console.log(`[mosquitto] topic provisioned for ${e.body.consumer} (client ${e.body.username})`);
|
|
});
|
|
|
|
await on<TopicEvent>("module.mosquitto.topic.deprovisioned", async (e) => {
|
|
console.log(`[mosquitto] topic deprovisioned for ${e.body.consumer} (client ${e.body.username})`);
|
|
});
|
|
|
|
console.log("[mosquitto] auditing topic lifecycle events");
|