forked from TrueCloudLab/frostfs-node
Initial commit
Initial public review release v0.10.0
This commit is contained in:
commit
dadfd90dcd
276 changed files with 46331 additions and 0 deletions
35
lib/fix/module/module.go
Normal file
35
lib/fix/module/module.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package module
|
||||
|
||||
import (
|
||||
"go.uber.org/dig"
|
||||
)
|
||||
|
||||
type (
|
||||
// Module type
|
||||
Module []*Provider
|
||||
|
||||
// Provider struct
|
||||
Provider struct {
|
||||
Constructor interface{}
|
||||
Options []dig.ProvideOption
|
||||
}
|
||||
)
|
||||
|
||||
// Append module to target module and return new module
|
||||
func (m Module) Append(mods ...Module) Module {
|
||||
var result = m
|
||||
for _, mod := range mods {
|
||||
result = append(result, mod...)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// Provide set providers functions to DI container
|
||||
func Provide(dic *dig.Container, providers Module) error {
|
||||
for _, p := range providers {
|
||||
if err := dic.Provide(p.Constructor, p.Options...); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue