Conversation
232f1cd to
8a07116
Compare
|
Awesome! I hope to try it today/tomorrow 🙂 |
|
Hey @alexandre-daubois, I gave this a quick try, and got a very basic version working retrieving some info from my CrowdSec bouncer. Will need some more time to make it look good now. But at least the foundation looks OK 🙂 Some initial remarks:
Below a few nice to haves that came to mind:
Thanks for this so far, and will do some more hacking 😄 |
55d4e49 to
9e907ee
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces a compile-time plugin system for Ember to allow third-party modules to add custom TUI tabs and/or contribute Prometheus metrics to Ember’s /metrics endpoint, addressing the request in Issue #3 (supporting additional Caddy modules).
Changes:
- Add public plugin API (
pkg/plugin) with registration, lifecycle hooks, TUI rendering, and metrics exporting interfaces. - Extract/introduce reusable Prometheus parsing + metric snapshot types into a public
pkg/metricspackage for plugin authors. - Integrate plugins into TUI + daemon flows (tab rendering, key forwarding, help overlay integration, and
/metricsexport integration).
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents plugin system and links to plugin guide. |
| pkg/plugin/registry.go | Adds global plugin registry with name validation/collision checks. |
| pkg/plugin/plugin.go | Defines plugin interfaces, config structs, and panic-safe fetch helper. |
| pkg/plugin/plugin_test.go | Adds unit tests for plugin registry, interfaces, and SafeFetch. |
| pkg/metrics/types.go | Introduces exported snapshot/metric types for reuse by plugins. |
| pkg/metrics/parse.go | Adds exported Prometheus text parser used by core and plugins. |
| internal/ui/tabbar.go | Extends tab labeling to support plugin-provided tab names. |
| internal/ui/tabbar_test.go | Updates tests for new tabbar function signature. |
| internal/ui/plugin_bridge.go | Bridges plugin interfaces into the UI runtime with panic safety. |
| internal/ui/plugin_bridge_test.go | Adds tests for plugin bridge behavior and safety wrappers. |
| internal/ui/help.go | Extends help overlay to include plugin keybindings. |
| internal/ui/help_test.go | Updates tests for help overlay signature change. |
| internal/ui/app.go | Integrates plugins into main TUI app loop (tabs, fetch, view, key routing). |
| internal/ui/app_test.go | Adds tests for plugin tab behavior, key forwarding, and fetch handling. |
| internal/fetcher/prometheus.go | Switches core Prometheus parsing to pkg/metrics and keeps test wrappers. |
| internal/fetcher/fetcher.go | Re-exports snapshot/types as aliases to pkg/metrics types. |
| internal/exporter/exporter.go | Adds plugin metric exports to /metrics handler with panic protection. |
| internal/exporter/exporter_test.go | Adds tests ensuring plugin metrics render and panics are isolated. |
| internal/app/tui.go | Wires plugins into TUI startup and stores plugin exports for /metrics. |
| internal/app/run.go | Initializes/cleans up plugins and reads plugin env options. |
| internal/app/run_test.go | Adds tests for plugin init, env options parsing, and closer cleanup. |
| internal/app/daemon.go | Adds daemon-side plugin fetching/subscription + export wiring. |
| internal/app/daemon_test.go | Adds tests for daemon plugin wiring, concurrency fetch, and subscriptions. |
| ember.go | Adds public ember package entrypoint for custom binaries (blank-import plugins). |
| docs/plugins.md | Adds comprehensive plugin development guide and interface reference. |
| docs/index.md | Links plugin documentation from docs index. |
| cmd/ember/main.go | Switches CLI binary to use the new public ember entrypoint. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
a5e769f to
9d70151
Compare
|
Super valuable feedback, thank you so much @hslatman! I've pushed changes that should address most of your points:
import (
"github.com/alexandre-daubois/ember"
_ "github.com/myorg/my-plugin"
)
func main() { ember.Run() }
Everything is documented in the updated Let me know if this covers your needs! |
This is working great.
This is close, but doesn't fully support my use case. In my CrowdSec module I'm working on adding additional metrics that are registered with Caddy's core metrics, so that consumers only need to hit a single
Looking good!
I believe the It would be great if the key of the tab could be taken into account. In my use case I have the core module, with some optional functionality that would be shown best in its own tab. If the optional functionality is not enabled, I would like to disable that tab, but not the core tab.
👍 |
I addressed this concern in 3ec07a9
It would be great if the key of the tab could be taken into account. In my use case I have the core module, with some optional functionality that would be shown best in its own tab. If the optional functionality is not enabled, I would like to disable that tab, but not the core tab. And this one in 8f0646a. Let me know if this helps! |
30072d6 to
1ec4f4c
Compare
This adds a plugin system to Ember. Fix #3
Ping @hslatman, would you like to try this and see if it offers the possibilities you have in mind? Docs are up-to-date in the PR with a complete example to guide you on how you can create a plugin.
If it doesn't match your needs, let's discuss how this implementation could be improved!