[#637] shard/test: Fix data race

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2023-08-25 11:43:35 +03:00 committed by Evgenii Stratonikov
parent f8ba60aa0c
commit c4db8e7690

View file

@ -28,13 +28,17 @@ type metricsStore struct {
errCounter int64 errCounter int64
} }
func (m metricsStore) SetShardID(_ string) {} func (m *metricsStore) SetShardID(_ string) {}
func (m metricsStore) SetObjectCounter(objectType string, v uint64) { func (m *metricsStore) SetObjectCounter(objectType string, v uint64) {
m.mtx.Lock()
defer m.mtx.Unlock()
m.objCounters[objectType] = v m.objCounters[objectType] = v
} }
func (m metricsStore) AddToObjectCounter(objectType string, delta int) { func (m *metricsStore) AddToObjectCounter(objectType string, delta int) {
m.mtx.Lock()
defer m.mtx.Unlock()
switch { switch {
case delta > 0: case delta > 0:
m.objCounters[objectType] += uint64(delta) m.objCounters[objectType] += uint64(delta)