-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
services: add new service for fetching blocks from NeoFS
Close #3496 Co-authored-by: Anna Shaleva <[email protected]> Signed-off-by: Ekaterina Pavlova <[email protected]>
- Loading branch information
1 parent
8180222
commit b1fb0c6
Showing
10 changed files
with
648 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package config | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"time" | ||
|
||
cid "github.com/nspcc-dev/neofs-sdk-go/container/id" | ||
) | ||
|
||
const ( | ||
DefaultTimeout = 1 * time.Minute | ||
DefaultOIDBatchSize = 8000 | ||
DefaultDownloaderWorkersCount = 500 | ||
) | ||
|
||
// NeoFSBlockFetcher represents the configuration for the NeoFS block fetcher service. | ||
type NeoFSBlockFetcher struct { | ||
InternalService `yaml:",inline"` | ||
Timeout time.Duration `yaml:"Timeout"` | ||
ContainerID string `yaml:"ContainerID"` | ||
Addresses []string `yaml:"Addresses"` | ||
OIDBatchSize int `yaml:"OIDBatchSize"` // valid only for SkipIndexFilesSearch = true | ||
BlockAttribute string `yaml:"BlockAttribute"` | ||
OidAttribute string `yaml:"OidAttribute"` | ||
HeaderAttribute string `yaml:"HeaderAttribute"` | ||
DownloaderWorkersCount int `yaml:"DownloaderWorkersCount"` | ||
BQueueSize int `yaml:"BQueueSize"` | ||
SkipIndexFilesSearch bool `yaml:"SkipIndexFilesSearch"` | ||
} | ||
|
||
// Validate checks NeoFSBlockFetcher for internal consistency and ensures | ||
// that all required fields are properly set. It returns an error if the | ||
// configuration is invalid or if the ContainerID cannot be properly decoded. | ||
func (cfg *NeoFSBlockFetcher) Validate() error { | ||
if !cfg.Enabled { | ||
return nil | ||
} | ||
if cfg.ContainerID == "" { | ||
return errors.New("container ID is not set") | ||
} | ||
var containerID cid.ID | ||
err := containerID.DecodeString(cfg.ContainerID) | ||
if err != nil { | ||
return fmt.Errorf("invalid container ID: %w", err) | ||
} | ||
if cfg.Timeout == 0 { | ||
cfg.Timeout = DefaultTimeout | ||
} | ||
if cfg.OIDBatchSize == 0 { | ||
cfg.OIDBatchSize = DefaultOIDBatchSize | ||
} | ||
if cfg.DownloaderWorkersCount <= 0 { | ||
cfg.DownloaderWorkersCount = DefaultDownloaderWorkersCount | ||
} | ||
if cfg.BQueueSize < cfg.OIDBatchSize { | ||
return fmt.Errorf("BQueueSize (%d) is lower than OIDBatchSize (%d)", cfg.BQueueSize, cfg.OIDBatchSize) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.