Draft
Conversation
…king and semaphores backed by Redis.
…nd remove RescheduleSignal.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces support for distributed exclusive locks and semaphores to the RubyReactor framework, enabling safe concurrent execution and resource limiting for reactors. The changes include a new DSL for configuring locking and semaphore behavior, integration with Redis for lock/semaphore primitives, and Sidekiq worker enhancements to handle lock contention gracefully. Comprehensive integration and unit tests are provided to ensure correct behavior.
Locking and Semaphore DSL:
LockableDSL module (ruby_reactor/dsl/lockable.rb) allowing reactors to declare exclusive locks (with_lock) and semaphores (with_semaphore) with customizable keys, TTLs, and limits.Lockablefor easy configuration (reactor.rb).Lock and Semaphore Implementation:
Lock) and semaphore (Semaphore) classes with acquisition/release logic, error handling, and re-entrancy support (lock.rb,semaphore.rb). [1] [2]RedisLockingmodule (storage/redis_locking.rb) and included it in the Redis adapter (storage/redis_adapter.rb). [1] [2]Executor and Worker Integration:
Executorto acquire locks/semaphores before execution/resume, raising specific errors on contention, and Sidekiq worker to reschedule jobs when locks are busy instead of failing. [1] [2] [3] [4] [5] [6]Testing and Examples:
spec/examples/locking_reactors.rb).spec/ruby_reactor/integration/locking_spec.rb).spec/ruby_reactor/sidekiq_workers/worker_spec.rb).