mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-15 17:39:40 +02:00
Replace 21 separate NestJS Matrix bot processes (~2.1 GB RAM, ~4.2 GB Docker images) with a single Go binary using plugin architecture (8.6 MB binary, ~30 MB RAM). New services: - services/mana-matrix-bot/ — Go Matrix bot with 21 plugins (mautrix-go, Redis sessions) - services/mana-api-gateway-go/ — Go API gateway (rate limiting, API keys, credit billing) Deleted: - 21 services/matrix-*-bot/ directories - packages/bot-services/ and packages/matrix-bot-common/ - Legacy deploy scripts and CI build jobs Updated: - docker-compose.macmini.yml: new Go services, legacy bots removed - CI/CD: change detection + build jobs for Go services - Root package.json: new dev:matrix, build:matrix, test:matrix scripts Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
29 lines
719 B
Go
29 lines
719 B
Go
package plugin
|
|
|
|
import "fmt"
|
|
|
|
var registry = make(map[string]func() Plugin)
|
|
|
|
// Register adds a plugin factory to the registry.
|
|
// Called from each plugin's init() function or explicitly in main.
|
|
func Register(name string, factory func() Plugin) {
|
|
if _, exists := registry[name]; exists {
|
|
panic(fmt.Sprintf("plugin %q already registered", name))
|
|
}
|
|
registry[name] = factory
|
|
}
|
|
|
|
// All returns all registered plugin factories.
|
|
func All() map[string]func() Plugin {
|
|
result := make(map[string]func() Plugin, len(registry))
|
|
for k, v := range registry {
|
|
result[k] = v
|
|
}
|
|
return result
|
|
}
|
|
|
|
// Get returns a plugin factory by name.
|
|
func Get(name string) (func() Plugin, bool) {
|
|
f, ok := registry[name]
|
|
return f, ok
|
|
}
|