Skip to content

Commit

Permalink
Merge pull request #5 from getoutreach/define_container
Browse files Browse the repository at this point in the history
feat: define container function
  • Loading branch information
pavelsmejkal authored Jun 19, 2024
2 parents dd8fb37 + 67416ba commit 2c8f225
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion container.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

package plumber

import "errors"
import (
"context"
"errors"
)

// Container represents a root dependency container
type Container struct {
Expand Down Expand Up @@ -34,3 +37,13 @@ func (c *Container) Close() error {
}
return errors.Join(errs...)
}

// DefineContainers defines supplied containers using given config and root container
func DefineContainers[C, CF any](ctx context.Context, cfg CF, root C, containers ...interface {
Define(context.Context, CF, C)
}) C {
for _, d := range containers {
d.Define(ctx, cfg, root)
}
return root
}

0 comments on commit 2c8f225

Please sign in to comment.