[#776] cmd/node: Configure write-cache size limit
Add `size_limit` config value to write-cache section. Add `SizeLimit` method of `writecache.Config` type. Pass its value to `WithMaxCacheSize` option on app construction. Reflect config update in examples. Cover new value in unit test. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
a1696a81b6
commit
368e280413
6 changed files with 30 additions and 2 deletions
|
@ -21,6 +21,9 @@ const (
|
|||
|
||||
// WorkersNumberDefault is a default number of workers.
|
||||
WorkersNumberDefault = 20
|
||||
|
||||
// SizeLimitDefault is a default write-cache size limit.
|
||||
SizeLimitDefault = 1 << 30
|
||||
)
|
||||
|
||||
// From wraps config section into Config.
|
||||
|
@ -107,3 +110,19 @@ func (x *Config) WorkersNumber() int {
|
|||
|
||||
return WorkersNumberDefault
|
||||
}
|
||||
|
||||
// SizeLimit returns value of "size_limit" config parameter.
|
||||
//
|
||||
// Returns SizeLimitDefault if value is not a positive number.
|
||||
func (x *Config) SizeLimit() uint64 {
|
||||
c := config.UintSafe(
|
||||
(*config.Config)(x),
|
||||
"size_limit",
|
||||
)
|
||||
|
||||
if c > 0 {
|
||||
return c
|
||||
}
|
||||
|
||||
return SizeLimitDefault
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue