restructure

This commit is contained in:
yanghao05
2023-04-28 15:10:28 +08:00
parent 3a9d5492f8
commit ebcd25f776
6 changed files with 118 additions and 14 deletions

View File

@@ -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
}