From 80af71db44f0c566512606a451e32ef0c11ac412 Mon Sep 17 00:00:00 2001 From: Anton Nikiforov Date: Wed, 4 Sep 2024 11:51:52 +0300 Subject: [PATCH] [#xx] engine: Rename `rebuildLimiter` to `routineLimiter` Signed-off-by: Anton Nikiforov --- pkg/local_object_storage/engine/engine.go | 4 ++-- .../engine/{rebuild_limiter.go => routine_limiter.go} | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) rename pkg/local_object_storage/engine/{rebuild_limiter.go => routine_limiter.go} (51%) diff --git a/pkg/local_object_storage/engine/engine.go b/pkg/local_object_storage/engine/engine.go index b87d77e6c..5d9c5ee64 100644 --- a/pkg/local_object_storage/engine/engine.go +++ b/pkg/local_object_storage/engine/engine.go @@ -40,7 +40,7 @@ type StorageEngine struct { err error } evacuateLimiter *evacuationLimiter - rebuildLimiter *rebuildLimiter + rebuildLimiter *routineLimiter } type shardWrapper struct { @@ -243,7 +243,7 @@ func New(opts ...Option) *StorageEngine { closeCh: make(chan struct{}), setModeCh: make(chan setModeRequest), evacuateLimiter: &evacuationLimiter{}, - rebuildLimiter: newRebuildLimiter(c.rebuildWorkersCount), + rebuildLimiter: newRoutineLimiter(c.rebuildWorkersCount), } } diff --git a/pkg/local_object_storage/engine/rebuild_limiter.go b/pkg/local_object_storage/engine/routine_limiter.go similarity index 51% rename from pkg/local_object_storage/engine/rebuild_limiter.go rename to pkg/local_object_storage/engine/routine_limiter.go index 28b02b0a3..a98194f32 100644 --- a/pkg/local_object_storage/engine/rebuild_limiter.go +++ b/pkg/local_object_storage/engine/routine_limiter.go @@ -2,17 +2,17 @@ package engine import "context" -type rebuildLimiter struct { +type routineLimiter struct { semaphore chan struct{} } -func newRebuildLimiter(workersCount uint32) *rebuildLimiter { - return &rebuildLimiter{ +func newRoutineLimiter(workersCount uint32) *routineLimiter { + return &routineLimiter{ semaphore: make(chan struct{}, workersCount), } } -func (l *rebuildLimiter) AcquireWorkSlot(ctx context.Context) error { +func (l *routineLimiter) AcquireWorkSlot(ctx context.Context) error { select { case l.semaphore <- struct{}{}: return nil @@ -21,6 +21,6 @@ func (l *rebuildLimiter) AcquireWorkSlot(ctx context.Context) error { } } -func (l *rebuildLimiter) ReleaseWorkSlot() { +func (l *routineLimiter) ReleaseWorkSlot() { <-l.semaphore }