forked from TrueCloudLab/frostfs-node
[#1746] network: Set timeout for streaming operations
Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
parent
0140ac354b
commit
4354359aed
11 changed files with 38 additions and 11 deletions
|
@ -323,8 +323,9 @@ func initCfg(path string) *cfg {
|
|||
workerPool: reputationWorkerPool,
|
||||
},
|
||||
clientCache: cache.NewSDKClientCache(cache.ClientCacheOpts{
|
||||
DialTimeout: apiclientconfig.DialTimeout(appCfg),
|
||||
Key: &key.PrivateKey,
|
||||
DialTimeout: apiclientconfig.DialTimeout(appCfg),
|
||||
StreamTimeout: apiclientconfig.StreamTimeout(appCfg),
|
||||
Key: &key.PrivateKey,
|
||||
}),
|
||||
persistate: persistate,
|
||||
}
|
||||
|
|
|
@ -11,6 +11,9 @@ const (
|
|||
|
||||
// DialTimeoutDefault is a default dial timeout of NeoFS API client connection.
|
||||
DialTimeoutDefault = 5 * time.Second
|
||||
|
||||
// StreamTimeoutDefault is a default timeout of NeoFS API streaming operation.
|
||||
StreamTimeoutDefault = 15 * time.Second
|
||||
)
|
||||
|
||||
// DialTimeout returns the value of "dial_timeout" config parameter
|
||||
|
@ -25,3 +28,16 @@ func DialTimeout(c *config.Config) time.Duration {
|
|||
|
||||
return DialTimeoutDefault
|
||||
}
|
||||
|
||||
// StreamTimeout returns the value of "stream_timeout" config parameter
|
||||
// from "apiclient" section.
|
||||
//
|
||||
// Returns DialTimeoutDefault if the value is not positive duration.
|
||||
func StreamTimeout(c *config.Config) time.Duration {
|
||||
v := config.DurationSafe(c.Sub(subsection), "stream_timeout")
|
||||
if v > 0 {
|
||||
return v
|
||||
}
|
||||
|
||||
return StreamTimeoutDefault
|
||||
}
|
||||
|
|
|
@ -15,12 +15,14 @@ func TestApiclientSection(t *testing.T) {
|
|||
empty := configtest.EmptyConfig()
|
||||
|
||||
require.Equal(t, apiclientconfig.DialTimeoutDefault, apiclientconfig.DialTimeout(empty))
|
||||
require.Equal(t, apiclientconfig.StreamTimeoutDefault, apiclientconfig.StreamTimeout(empty))
|
||||
})
|
||||
|
||||
const path = "../../../../config/example/node"
|
||||
|
||||
var fileConfigTest = func(c *config.Config) {
|
||||
require.Equal(t, 15*time.Second, apiclientconfig.DialTimeout(c))
|
||||
require.Equal(t, 20*time.Second, apiclientconfig.StreamTimeout(c))
|
||||
}
|
||||
|
||||
configtest.ForEachFileType(path, fileConfigTest)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue