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

50
boot/boot.go Normal file
View File

@@ -0,0 +1,50 @@
//go:build wireinject
package boot
import (
"github.com/InazumaV/Ratte/conf"
"github.com/google/wire"
)
var preSet = wire.NewSet(
wire.FieldsOf(new(*conf.Conf), "ACME", "Plugin"),
wire.FieldsOf(new(conf.Plugins), "Core", "Panel"),
initAcme,
initCores,
initPanels,
)
var mainSet = wire.NewSet(
wire.FieldsOf(new(*conf.Conf), "Node"),
initNode,
)
type Boot struct {
Acmes AcmeGroup
Cores CoreGroup
Panels PanelGroup
Node *NodeGroup
}
func (b *Boot) Start() error {
if err := b.Node.Start(); err != nil {
return err
}
return nil
}
func (b *Boot) Close() error {
b.Node.Close()
b.Cores.Close()
b.Panels.Close()
return nil
}
func InitBoot(c *conf.Conf) (*Boot, error) {
wire.Build(
preSet,
mainSet,
wire.Struct(new(Boot), "*"),
)
return nil, nil
}