restructure
This commit is contained in:
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"github.com/rogeecn/atom/utils/opt"
|
||||
"github.com/spf13/viper"
|
||||
"go.uber.org/dig"
|
||||
)
|
||||
|
||||
@@ -19,3 +21,20 @@ func init() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
type ProviderContainer struct {
|
||||
Provider func(...opt.Option) error
|
||||
Options []opt.Option
|
||||
}
|
||||
|
||||
type Providers []ProviderContainer
|
||||
|
||||
func (p Providers) Provide(config *viper.Viper) error {
|
||||
for _, provider := range p {
|
||||
provider.Options = append(provider.Options, opt.Config(config))
|
||||
if err := provider.Provider(provider.Options...); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user