add service install

add command app boot
This commit is contained in:
yanghao05
2023-05-12 11:45:18 +08:00
parent ed2c7a8b98
commit 7bbf6c1684
7 changed files with 111 additions and 0 deletions

27
services/command.go Normal file
View File

@@ -0,0 +1,27 @@
package services
import (
"github.com/rogeecn/atom/container"
"go.uber.org/dig"
)
type CommandService interface {
Register()
Execute() error
}
type Command struct {
dig.In
Commands []CommandService `group:"command_services"`
}
func ServeCommand(f func() error) error {
return container.Container.Invoke(func(command Command) error {
for _, cmd := range command.Commands {
cmd.Register()
}
return f()
})
}