1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-13 13:50:16 +00:00

Startup helper method

This commit is contained in:
Darren Shepherd
2017-11-28 18:58:13 -07:00
parent a0212e1d02
commit ee148b4d18

View File

@@ -11,6 +11,13 @@ type Starter interface {
Start(ctx context.Context, threadiness int) error Start(ctx context.Context, threadiness int) error
} }
func SyncThenSync(ctx context.Context, threadiness int, starters ...Starter) error {
if err := Sync(ctx, starters...); err != nil {
return err
}
return Start(ctx, threadiness, starters...)
}
func Sync(ctx context.Context, starters ...Starter) error { func Sync(ctx context.Context, starters ...Starter) error {
eg, _ := errgroup.WithContext(ctx) eg, _ := errgroup.WithContext(ctx)
for _, starter := range starters { for _, starter := range starters {