xmtop/docs/extensions.md

31 lines
1.3 KiB
Markdown
Raw Normal View History

2020-02-28 06:13:23 +08:00
% Plugins
# Current state
2020-02-28 06:13:23 +08:00
First, there were go plugins. This turned out to be impractical due to the limitations in plugins making them unsuitable for use outside of a small, strict, and (one could argue) useless use case.
2020-02-28 06:13:23 +08:00
Then I tried external static extensions. This approach used a trick to copy and modify the gotop main executable, which then imported it's own packages from upstream. This worked, but was awkward and required several steps to build.
Currently, as I've only written two modules since I started down this path, and there's no clean, practical solution yet in Go, I've folded the extensions into the main codebase. This means there's no programmatic extension mechanism for gotop.
# Devices
- Devices supply an `Init()` function that will call the appropriate
2020-02-28 06:13:23 +08:00
`Register\*()` functions in the `github.com/xxxserxxx/gotop/devices` package.
- `devices` will supply:
- RegisterCPU (opt)
- Counts (req)
- Percents (req)
- RegisterMem (opt)
- RegisterTemp (opt)
- RegisterShutdown (opt)
# gotop
- Command line -P, comma separated list of plugin .so
- gotop will look in `pwd` and then in \$XDG_CONFIG_HOME/gotop
- When loaded, gotop will call lib#Init()
When exited cleanly, gotop will call all registered shutdown functions.