add service install
add command app boot
This commit is contained in:
27
services/command.go
Normal file
27
services/command.go
Normal 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()
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user