forked from TrueCloudLab/frostfs-node
[#1632] node: Configure TTL of Sidechain caches
From now cache TTL can be parameterized in the `neofs-node` app using `cache_ttl` config key. `disable_cache` value is no longer supported. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
5ce8315cd8
commit
fa3124fc33
9 changed files with 35 additions and 33 deletions
|
@ -27,6 +27,8 @@ const (
|
|||
|
||||
// PriorityDefault is a default endpoint priority for the morph client.
|
||||
PriorityDefault = 1
|
||||
|
||||
CacheTTLDefault = 30 * time.Second
|
||||
)
|
||||
|
||||
// RPCEndpoint returns list of the values of "rpc_endpoint" config parameter
|
||||
|
@ -74,8 +76,15 @@ func DialTimeout(c *config.Config) time.Duration {
|
|||
return DialTimeoutDefault
|
||||
}
|
||||
|
||||
// DisableCache returns the value of "disable_cache" config parameter
|
||||
// CacheTTL returns the value of "cache_ttl" config parameter
|
||||
// from "morph" section.
|
||||
func DisableCache(c *config.Config) bool {
|
||||
return config.BoolSafe(c.Sub(subsection), "disable_cache")
|
||||
//
|
||||
// Returns CacheTTLDefault if value is zero or invalid. Supports negative durations.
|
||||
func CacheTTL(c *config.Config) time.Duration {
|
||||
res := config.DurationSafe(c.Sub(subsection), "cache_ttl")
|
||||
if res != 0 {
|
||||
return res
|
||||
}
|
||||
|
||||
return CacheTTLDefault
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestMorphSection(t *testing.T) {
|
|||
|
||||
require.Panics(t, func() { morphconfig.RPCEndpoint(empty) })
|
||||
require.Equal(t, morphconfig.DialTimeoutDefault, morphconfig.DialTimeout(empty))
|
||||
require.Equal(t, false, morphconfig.DisableCache(empty))
|
||||
require.Equal(t, morphconfig.CacheTTLDefault, morphconfig.CacheTTL(empty))
|
||||
})
|
||||
|
||||
const path = "../../../../config/example/node"
|
||||
|
@ -32,7 +32,7 @@ func TestMorphSection(t *testing.T) {
|
|||
var fileConfigTest = func(c *config.Config) {
|
||||
require.Equal(t, rpcs, morphconfig.RPCEndpoint(c))
|
||||
require.Equal(t, 30*time.Second, morphconfig.DialTimeout(c))
|
||||
require.Equal(t, true, morphconfig.DisableCache(c))
|
||||
require.Equal(t, 15*time.Second, morphconfig.CacheTTL(c))
|
||||
}
|
||||
|
||||
configtest.ForEachFileType(path, fileConfigTest)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue