feat: use wire

This commit is contained in:
Yuzuki616
2025-05-07 17:22:29 +09:00
parent 05a1e586ed
commit 9e18c06199
14 changed files with 418 additions and 222 deletions

40
boot/panel.go Normal file
View File

@@ -0,0 +1,40 @@
package boot
import (
"fmt"
"github.com/InazumaV/Ratte-Interface/panel"
"github.com/InazumaV/Ratte/conf"
log "github.com/sirupsen/logrus"
"os/exec"
)
type PanelGroup map[string]*panel.PluginClient
func (p *PanelGroup) Get(name string) *panel.PluginClient {
if pl, ok := (*p)[name]; ok {
return pl
}
return nil
}
func (p *PanelGroup) Close() error {
for _, pl := range *p {
err := pl.Close()
if err != nil {
log.WithError(err).Warn()
}
}
return nil
}
func initPanels(panelsP []conf.Plugin) (PanelGroup, error) {
panels := make(PanelGroup, len(panelsP))
for _, p := range panelsP {
pn, err := panel.NewClient(nil, exec.Command(p.Path))
if err != nil {
return nil, fmt.Errorf("new panel error: %w", err)
}
panels[p.Name] = pn
}
return panels, nil
}