feat(server): add Server.Hooks() accessor for external hook authors#158
Merged
wind-c merged 1 commit intowind-c:mainfrom May 9, 2026
Merged
feat(server): add Server.Hooks() accessor for external hook authors#158wind-c merged 1 commit intowind-c:mainfrom
wind-c merged 1 commit intowind-c:mainfrom
Conversation
External hook authors and monitoring/observability tools currently have no read-only path to the registered hook bus. Reading state that hooks store (the session storage chain in particular) requires reaching into unexported fields, which is fragile. Adds a 7-line accessor that returns the hook bus pointer. No behavior change inside the broker; hooks already mutate their own state through this same pointer.
debsahu
added a commit
to debsahu/comqtt-dashboard
that referenced
this pull request
May 8, 2026
Web dashboard add-on for comqtt MQTT broker, shipped as a separate Go module so stock comqtt stays focused on the broker. Originally proposed in wind-c/comqtt#151. Per maintainer preference, keeping comqtt lightweight, the dashboard moved here. This v0.1.0 covers single-mode broker only: - dashboard/ package: auth (HMAC-signed cookie sessions, file + Redis cred stores, lockout, CSRF, RBAC middleware), handlers, SSE pipeline (ring-buffered hub, mqtt-hook bridge, /dashboard/events handler), HTML templates, embedded static assets (htmx, htmx-sse, tailwind.css, theme.js). - rest/ package: dashboard-specific REST endpoints layered on top of upstream comqtt /api/v1/mqtt/* (paginated client list with prefix search, subscriptions, topics tree, retained list with payload preview, sessions; plus DELETE for unsubscribe / clear-retained / disconnect-session). - cmd/comqtt-dashboard: single-mode broker driver wiring upstream comqtt (storage, auth, bridge, listeners) + the dashboard. Drop-in replacement for upstream comqtt-single on the same flags. Build is fully self-contained: go build produces a 40 MB single binary including all dashboard assets. Tests: 151 pass under -race across dashboard and rest packages. Soft-fork note: go.mod uses a replace directive to pin comqtt at the same commit pushed in wind-c/comqtt#158 (Server.Hooks() accessor). The replace will be dropped once an upstream release includes the accessor. Deferred to v0.2.0: - Cluster-mode binary with cluster/rest mirrors for cross-node aggregation. - Helm chart (deploy/helm/comqtt-dashboard/). - CI workflows + Docker image publishing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a small read-only accessor to
*mqtt.Server:Rationale
External hook authors and monitoring tooling sometimes need to read state that hooks themselves store. The session storage chain is the concrete motivating case: a hook implementing
StoredClients,StoredSubscriptions,StoredRetainedMessages, etc. is the source of truth for offline session inspection, and there is currently no in-tree way to reach the hook bus to query it without unsafe access to unexported fields.The accessor is a getter for an existing pointer, not new behavior. Hooks already mutate state through
s.hooksinternally; this just exposes a read-only path for code outside the package.Scope
Context
Split out from #151 per maintainer feedback that the dashboard PR was too large to evaluate. The dashboard work itself will move to a separate add-on module (
debsahu/comqtt-dashboard) so comqtt remains focused on the broker. This accessor is the only upstream change that work needs from comqtt.