Skip to content

feat: implement queueing and reservation functionality - #405

Merged
niteshpurohit merged 8 commits into
mainfrom
feat/queueing-reservation
Mar 29, 2026
Merged

niteshpurohit merged 8 commits into
mainfrom
feat/queueing-reservation

Conversation

@niteshpurohit

Copy link
Copy Markdown
Member
  • Added InMemoryQueueStore class for managing job queues and reservations.
  • Introduced QueueStore module with required methods for enqueueing, reserving, releasing, and expiring reservations.
  • Created Reservation class to handle lease tokens and job metadata.
  • Updated job model documentation to include queueing and reservation contract details.
  • Added tests for InMemoryQueueStore and QueueStore to ensure correct behavior and error handling.

closes: #13

- Added InMemoryQueueStore class for managing job queues and reservations.
- Introduced QueueStore module with required methods for enqueueing, reserving, releasing, and expiring reservations.
- Created Reservation class to handle lease tokens and job metadata.
- Updated job model documentation to include queueing and reservation contract details.
- Added tests for InMemoryQueueStore and QueueStore to ensure correct behavior and error handling.
@niteshpurohit niteshpurohit self-assigned this Mar 29, 2026
Copilot AI review requested due to automatic review settings March 29, 2026 14:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds the first runtime queueing/reservation layer to Karya, including an in-memory reference store, a backend contract, and supporting documentation/tests, to satisfy Issue #13’s “queueing and reservation behavior” milestone.

Changes:

  • Introduces Karya::QueueStore contract and Karya::InMemoryQueueStore implementation for enqueue/reserve/release/expiration.
  • Adds Karya::Reservation immutable value object for reservation lease metadata.
  • Updates runtime job model docs to describe the queueing/reservation contract and adds specs for the new components.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
docs/pages/runtime/job-model.md Documents the queueing + reservation contract and lifecycle expectations.
core/karya/lib/karya/reservation.rb Adds immutable Reservation value object with normalization/validation.
core/karya/lib/karya/queue_store.rb Defines QueueStore interface and related error types.
core/karya/lib/karya/in_memory_queue_store.rb Implements in-memory enqueue/reserve/release/expire behavior with mutex protection.
core/karya/lib/karya.rb Wires new runtime components into the gem entrypoint.
core/karya/spec/karya/reservation_spec.rb Tests reservation normalization/validation and expiration predicate.
core/karya/spec/karya/queue_store_spec.rb Tests QueueStore interface enforcement (NotImplementedError).
core/karya/spec/karya/in_memory_queue_store_spec.rb Exercises enqueue/reserve/release/expire flows and important edge cases.

Comment thread core/karya/lib/karya/in_memory_queue_store.rb
Comment thread core/karya/lib/karya/in_memory_queue_store.rb Outdated
Comment thread core/karya/lib/karya/queue_store.rb Outdated
- Added validation for the `expired_tombstone_limit` parameter in the initializer to ensure it is a finite non-negative Integer.
- Enhanced error handling by updating the message for duplicate reservation tokens to clarify that the token can be either active or expired.
- Introduced new tests to cover cases for invalid `expired_tombstone_limit` values, ensuring robustness in input handling.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Comment thread core/karya/lib/karya/in_memory_queue_store.rb Outdated
- Updated enqueue, reserve, and release methods to use specific error classes for better clarity.
- Introduced InvalidQueueStoreOperationError for general queue operation errors.
- Refined existing error handling to ensure invalid inputs are caught and reported accurately.
- Added tests to verify that invalid inputs do not expire reservations and are handled correctly.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Comment thread core/karya/lib/karya/in_memory_queue_store.rb Outdated
Comment thread core/karya/lib/karya/in_memory_queue_store.rb Outdated
Comment thread core/karya/spec/karya/in_memory_queue_store_spec.rb
- Added checks to raise appropriate errors when a reservation is not found or expired.
- Updated error messages for clarity, ensuring they accurately reflect the issue.
- Enhanced test coverage to validate handling of blank and nil worker IDs during reservation.
- Clarified that automated linter feedback should not be a focus during reviews, as it is handled in CI.
- Added emphasis on reviewing code clarity, logic simplification, error message quality, and test coverage completeness.
- Included new review priorities for ambiguous error messages, duplicate logic, and incomplete test coverage.
- Added a new gemfile for tracking the Rails main branch to facilitate early regression detection.
- Updated the gemfile.lock to include dependencies for the Rails main branch.
- Modified the Gemfile.lock in `karya-roda` and `karya-sinatra` to upgrade `bigdecimal`, `json`, and `parser` versions for compatibility and performance improvements.
- Enhanced the `bundle-update-all` and `ci-install-bundles` scripts to support multiple gemfiles in suites, ensuring that all relevant gemfiles are updated and installed.
- Improved the `run-common` script to check for Rails versions and handle gemfile-specific commands, allowing for better integration with Rails applications.
- Updated various run scripts (`run-reek-all`, `run-rspec-unit-all`, `run-rubocop-all`) to support running commands for multiple gemfiles, enhancing the testing and linting processes across different configurations.
Copilot AI review requested due to automatic review settings March 29, 2026 16:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 41 changed files in this pull request and generated 2 comments.

Comment thread scripts/bundle-update-all
Comment thread scripts/run-common
- Introduced a new LeaseDuration class to validate and normalize lease durations.
- Ensured that lease durations must be positive numbers and support various numeric types.
- Updated the reserve method to utilize the new LeaseDuration class for improved error handling.
- Added a test case to reject unsupported numeric lease durations, enhancing robustness.
@niteshpurohit
niteshpurohit merged commit 948397a into main Mar 29, 2026
22 checks passed
@niteshpurohit
niteshpurohit deleted the feat/queueing-reservation branch March 29, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement queueing and reservation behavior

2 participants