[#168] node: Refactor node config

Resolve containedctx linter for cfg

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2023-03-23 17:59:14 +03:00
parent 8426d25f4b
commit a7c79c773a
20 changed files with 93 additions and 83 deletions

View file

@ -1,6 +1,7 @@
package engine
import (
"context"
"errors"
"fmt"
"path/filepath"
@ -68,7 +69,7 @@ func (e *StorageEngine) open() error {
}
// Init initializes all StorageEngine's components.
func (e *StorageEngine) Init() error {
func (e *StorageEngine) Init(ctx context.Context) error {
e.mtx.Lock()
defer e.mtx.Unlock()
@ -79,7 +80,7 @@ func (e *StorageEngine) Init() error {
wg.Add(1)
go func(id string, sh *shard.Shard) {
defer wg.Done()
if err := sh.Init(); err != nil {
if err := sh.Init(ctx); err != nil {
errCh <- shardInitError{
err: err,
id: id,
@ -264,7 +265,7 @@ func (rCfg *ReConfiguration) AddShard(id string, opts []shard.Option) {
}
// Reload reloads StorageEngine's configuration in runtime.
func (e *StorageEngine) Reload(rcfg ReConfiguration) error {
func (e *StorageEngine) Reload(ctx context.Context, rcfg ReConfiguration) error {
type reloadInfo struct {
sh *shard.Shard
opts []shard.Option
@ -324,7 +325,7 @@ loop:
err = sh.Open()
if err == nil {
err = sh.Init()
err = sh.Init(ctx)
}
if err != nil {
_ = sh.Close()