mirror of
https://github.com/InazumaV/Ratte.git
synced 2026-02-04 04:30:09 +00:00
feat: use wire
This commit is contained in:
72
boot/wire_gen.go
Normal file
72
boot/wire_gen.go
Normal file
@@ -0,0 +1,72 @@
|
||||
// Code generated by Wire. DO NOT EDIT.
|
||||
|
||||
//go:generate go run -mod=mod github.com/google/wire/cmd/wire
|
||||
//go:build !wireinject
|
||||
// +build !wireinject
|
||||
|
||||
package boot
|
||||
|
||||
import (
|
||||
"github.com/InazumaV/Ratte/conf"
|
||||
"github.com/google/wire"
|
||||
)
|
||||
|
||||
// Injectors from boot.go:
|
||||
|
||||
func InitBoot(c *conf.Conf) (*Boot, error) {
|
||||
v := c.Acme
|
||||
acmeGroup := initAcme(v)
|
||||
plugins := c.Plugin
|
||||
v2 := plugins.Core
|
||||
coreGroup, err := initCores(v2)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
v3 := plugins.Panel
|
||||
panelGroup, err := initPanels(v3)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
v4 := c.Node
|
||||
nodeGroup, err := initNode(v4, acmeGroup, coreGroup, panelGroup)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
boot := &Boot{
|
||||
Acmes: acmeGroup,
|
||||
Cores: coreGroup,
|
||||
Panels: panelGroup,
|
||||
Node: nodeGroup,
|
||||
}
|
||||
return boot, nil
|
||||
}
|
||||
|
||||
// boot.go:
|
||||
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user