forked from TrueCloudLab/frostfs-node
engine: initialize shards in parallel
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
90b4820ee0
commit
e0e4f1f7ee
1 changed files with 18 additions and 2 deletions
|
@ -3,7 +3,9 @@ package engine
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
|
@ -16,9 +18,23 @@ func (e *StorageEngine) open() error {
|
|||
e.mtx.RLock()
|
||||
defer e.mtx.RUnlock()
|
||||
|
||||
var wg sync.WaitGroup
|
||||
var errCh = make(chan error, len(e.shards))
|
||||
for id, sh := range e.shards {
|
||||
if err := sh.Open(); err != nil {
|
||||
return fmt.Errorf("could not open shard %s: %w", id, err)
|
||||
wg.Add(1)
|
||||
go func(id string, sh *shard.Shard) {
|
||||
defer wg.Done()
|
||||
if err := sh.Open(); err != nil {
|
||||
errCh <- fmt.Errorf("could not open shard %s: %w", id, err)
|
||||
}
|
||||
}(id, sh.Shard)
|
||||
}
|
||||
wg.Wait()
|
||||
close(errCh)
|
||||
|
||||
for err := range errCh {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue