[#101] app: Refactor the default copies number setting

Signed-off-by: Artem Tataurov <a.tataurov@yadro.com>
This commit is contained in:
Artem Tataurov 2023-05-16 17:24:10 +03:00
parent bf47978cfe
commit e24bc3f2ce
4 changed files with 35 additions and 18 deletions

View file

@ -34,7 +34,7 @@ type (
XMLDecoder XMLDecoderProvider
DefaultMaxAge int
NotificatorEnabled bool
CopiesNumber uint32
DefaultCopiesNumbers []uint32
CopiesNumbers map[string][]uint32
ResolveZoneList []string
IsResolveListAllow bool // True if ResolveZoneList contains allowed zones
@ -84,9 +84,9 @@ func New(log *zap.Logger, obj layer.Client, notificator Notificator, cfg *Config
}
// pickCopiesNumbers chooses the return values following this logic:
// 1) array of copies numbers sent in request's header has the highest priority
// 2) array of copies numbers with corresponding location constraint provided in the config file
// 3) default copies number from the config file wrapped into array
// 1) array of copies numbers sent in request's header has the highest priority.
// 2) array of copies numbers with corresponding location constraint provided in the config file.
// 3) default copies number from the config file wrapped into array.
func (h *handler) pickCopiesNumbers(metadata map[string]string, locationConstraint string) ([]uint32, error) {
copiesNumbersStr, ok := metadata[layer.AttributeFrostfsCopiesNumber]
if ok {
@ -102,7 +102,7 @@ func (h *handler) pickCopiesNumbers(metadata map[string]string, locationConstrai
return copiesNumbers, nil
}
return []uint32{h.cfg.CopiesNumber}, nil
return h.cfg.DefaultCopiesNumbers, nil
}
func parseCopiesNumbers(copiesNumbersStr string) ([]uint32, error) {