Skip to content

feat: add distributed job scheduler with lease-based worker claiming (closes #76) - #122

Merged
JamesEjembi merged 2 commits into
VeriNode-Labs:mainfrom
Kami-no-san:fix/issue-76-distributed-job-scheduler
Jul 30, 2026
Merged

feat: add distributed job scheduler with lease-based worker claiming (closes #76)#122
JamesEjembi merged 2 commits into
VeriNode-Labs:mainfrom
Kami-no-san:fix/issue-76-distributed-job-scheduler

Conversation

@Kami-no-san

Copy link
Copy Markdown
Contributor

Summary

Adds src/job_scheduler/mod.rs, a priority-queue distributed job scheduler with exclusive lease-based worker claiming.

Changes

  • New: src/job_scheduler/mod.rs (725 lines)
    • Jobs enqueued with configurable priority and payload
    • Workers acquire exclusive time-bound leases on jobs
    • Lease renewal extends processing time before expiry
    • Expired leases auto-release jobs back to the pending queue
    • Max acquisition attempts with dead-letter queue after exhaustion
    • Worker tracking with per-worker lease counts
    • Comprehensive metrics export for monitoring dashboards
  • Modified: src/lib.rs — added pub mod job_scheduler;

Test Coverage (17 tests)

  • Enqueue/acquire/complete lifecycle
  • Priority ordering (highest-first)
  • Lease expiry and automatic re-queuing
  • Worker ownership enforcement (renewal, completion)
  • Max acquisition attempt dead-lettering
  • Queue capacity overflow protection
  • Manual dead-lettering
  • Worker tracking and metrics

Design

  • Lock-free at the scheduler level
  • O(n) per operation bounded by highest-priority tier
  • Dependency-free (only alloc) for Soroban/WASM compatibility

Closes #76

…loses VeriNode-Labs#76)

Add src/job_scheduler/mod.rs implementing a priority-queue job scheduler
with exclusive lease-based worker claiming:
- Workers acquire jobs by priority, holding time-bound leases
- Lease renewal prevents expiry while a worker processes a job
- Expired leases auto-release jobs back to the pending queue
- Max acquisition attempts guard before dead-lettering
- Comprehensive test suite (17 tests) covering:
  - Enqueue/acquire/complete lifecycle
  - Lease expiry and re-queuing
  - Worker ownership enforcement
  - Priority ordering
  - Capacity limits
  - Metrics export for monitoring dashboards
Both src/config_audit.rs and src/replication/mod.rs already existed but
were never declarated as pub mod in lib.rs, causing unresolved import
errors in tests/config_audit_test.rs and tests/replication_dr_test.rs.
@JamesEjembi
JamesEjembi merged commit 2888e19 into VeriNode-Labs:main Jul 30, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Distributed Job Scheduler with Lease-based Worker Claiming

2 participants