fix/355-increase-tree-service-client-cache-size #359

Closed
ale64bit wants to merge 156 commits from ale64bit/frostfs-node:fix/355-increase-tree-service-client-cache-size into support/v0.36
5 changed files with 8 additions and 17 deletions
Showing only changes of commit e61aec4a7d - Show all commits

View file

@ -26,15 +26,12 @@ const (
EnvPrefix = "FROSTFS" EnvPrefix = "FROSTFS"
) )
// Prm groups required parameters of the Config.
type Prm struct{}
// New creates a new Config instance. // New creates a new Config instance.
// //
// If file option is provided (WithConfigFile), // If file option is provided (WithConfigFile),
// configuration values are read from it. // configuration values are read from it.
// Otherwise, Config is a degenerate tree. // Otherwise, Config is a degenerate tree.
func New(_ Prm, opts ...configViper.Option) *Config { func New(opts ...configViper.Option) *Config {
v, o, err := configViper.CreateViper(opts...) v, o, err := configViper.CreateViper(opts...)
if err != nil { if err != nil {

View file

@ -19,7 +19,7 @@ func TestConfigDir(t *testing.T) {
require.NoError(t, os.WriteFile(cfgFileName0, []byte(`{"storage":{"shard_pool_size":15}}`), 0777)) require.NoError(t, os.WriteFile(cfgFileName0, []byte(`{"storage":{"shard_pool_size":15}}`), 0777))
require.NoError(t, os.WriteFile(cfgFileName1, []byte("logger:\n level: debug"), 0777)) require.NoError(t, os.WriteFile(cfgFileName1, []byte("logger:\n level: debug"), 0777))
c := New(Prm{}, configViper.WithConfigDir(dir)) c := New(configViper.WithConfigDir(dir))
require.Equal(t, "debug", cast.ToString(c.Sub("logger").Value("level"))) require.Equal(t, "debug", cast.ToString(c.Sub("logger").Value("level")))
require.EqualValues(t, 15, cast.ToUint32(c.Sub("storage").Value("shard_pool_size"))) require.EqualValues(t, 15, cast.ToUint32(c.Sub("storage").Value("shard_pool_size")))
} }

View file

@ -12,21 +12,17 @@ import (
) )
func fromFile(path string) *config.Config { func fromFile(path string) *config.Config {
var p config.Prm
os.Clearenv() // ENVs have priority over config files, so we do this in tests os.Clearenv() // ENVs have priority over config files, so we do this in tests
return config.New(p, return config.New(
configViper.WithConfigFile(path), configViper.WithConfigFile(path),
) )
} }
func fromEnvFile(t testing.TB, path string) *config.Config { func fromEnvFile(t testing.TB, path string) *config.Config {
var p config.Prm
loadEnv(t, path) // github.com/joho/godotenv can do that as well loadEnv(t, path) // github.com/joho/godotenv can do that as well
return config.New(p, configViper.WithEnvPrefix(config.EnvPrefix)) return config.New(configViper.WithEnvPrefix(config.EnvPrefix))
} }
func forEachFile(paths []string, f func(*config.Config)) { func forEachFile(paths []string, f func(*config.Config)) {
@ -52,9 +48,7 @@ func ForEnvFileType(t testing.TB, pref string, f func(*config.Config)) {
// EmptyConfig returns config without any values and sections. // EmptyConfig returns config without any values and sections.
func EmptyConfig() *config.Config { func EmptyConfig() *config.Config {
var p config.Prm return config.New(configViper.WithEnvPrefix(config.EnvPrefix))
return config.New(p, configViper.WithEnvPrefix(config.EnvPrefix))
} }
// loadEnv reads .env file, parses `X=Y` records and sets OS ENVs. // loadEnv reads .env file, parses `X=Y` records and sets OS ENVs.

View file

@ -47,7 +47,7 @@ func main() {
os.Exit(SuccessReturnCode) os.Exit(SuccessReturnCode)
} }
appCfg := config.New(config.Prm{}, appCfg := config.New(
configViper.WithConfigFile(*configFile), configViper.WithConfigDir(*configDir), configViper.WithConfigFile(*configFile), configViper.WithConfigDir(*configDir),
configViper.WithEnvPrefix(config.EnvPrefix)) configViper.WithEnvPrefix(config.EnvPrefix))

View file

@ -27,13 +27,13 @@ func TestValidate(t *testing.T) {
t.Run("mainnet", func(t *testing.T) { t.Run("mainnet", func(t *testing.T) {
os.Clearenv() // ENVs have priority over config files, so we do this in tests os.Clearenv() // ENVs have priority over config files, so we do this in tests
p := filepath.Join(exampleConfigPrefix, "mainnet/config.yml") p := filepath.Join(exampleConfigPrefix, "mainnet/config.yml")
c := config.New(config.Prm{}, configViper.WithConfigFile(p)) c := config.New(configViper.WithConfigFile(p))
require.NoError(t, validateConfig(c)) require.NoError(t, validateConfig(c))
}) })
t.Run("testnet", func(t *testing.T) { t.Run("testnet", func(t *testing.T) {
os.Clearenv() // ENVs have priority over config files, so we do this in tests os.Clearenv() // ENVs have priority over config files, so we do this in tests
p := filepath.Join(exampleConfigPrefix, "testnet/config.yml") p := filepath.Join(exampleConfigPrefix, "testnet/config.yml")
c := config.New(config.Prm{}, configViper.WithConfigFile(p)) c := config.New(configViper.WithConfigFile(p))
require.NoError(t, validateConfig(c)) require.NoError(t, validateConfig(c))
}) })
} }