Skip to content

feat(backend): implement scalable async task queue & webhook system (#71)#97

Merged
ayomideadeniran merged 2 commits intoSoroLabs:mainfrom
ACodehunter:main
Mar 24, 2026
Merged

feat(backend): implement scalable async task queue & webhook system (#71)#97
ayomideadeniran merged 2 commits intoSoroLabs:mainfrom
ACodehunter:main

Conversation

@ACodehunter
Copy link
Copy Markdown

Summary

Implement a background task queue system to handle deep-profiling jobs and batch analyses without blocking the main API thread.

New API Endpoints

Endpoint Method Description
/jobs/submit POST Submit a new background job, returns job_id immediately
/jobs/:id GET Check job status, progress, and results
/jobs/:id/cancel POST Cancel a queued or processing job

Key Features

  • JobQueue: Thread-safe job storage using DashMap<JobId, Job>
  • JobWorker: Async worker that processes jobs with isolated failure handling
  • Webhook System: POST callbacks on completion/failure with exponential backoff retry
  • Progress Tracking: Percentage and status messages
  • Job Timeouts: Configurable per-job timeout (default: 5 minutes)
  • Auto-Cleanup: Removes completed jobs after retention period

Job Types

  • Analyze - Single contract analysis
  • Compare - Compare two contracts
  • OptimizeLimits - Optimize resource limits

Configuration

New environment variables:

  • JOB_TIMEOUT_SECS (default: 300)
  • JOB_CLEANUP_INTERVAL_SECS (default: 3600)
  • JOB_RETENTION_SECS (default: 3600)
  • WEBHOOK_TIMEOUT_SECS (default: 10)
  • WEBHOOK_MAX_RETRIES (default: 3)

Files Added

  • core/src/jobs.rs (925 lines)

Tests

  • Job lifecycle tests
  • Job queue operations
  • Job ID parsing

Closes #71

Developer added 2 commits March 24, 2026 11:29
Remove the async task queue and webhook system implementation
to re-implement with a different approach as requested.

Removed:
- core/src/jobs.rs (entire module)
- Job-related configuration from AppConfig
- Job endpoints (/jobs/submit, /jobs/:id, /jobs/:id/cancel)
- Job dependencies (dashmap, uuid, chrono)
- JobQueue and JobWorker from AppState

This prepares the codebase for a fresh implementation.
…oroLabs#71)

Re-implement the async task queue using SQLx for database persistence
instead of in-memory DashMap. This provides durability and allows jobs
to survive server restarts.

Key Changes:
- Use SQLx with support for both PostgreSQL and SQLite
- Jobs stored in database with full persistence
- Database migrations for jobs table schema
- Improved job worker with semaphore-based concurrency control
- Webhook system with retry logic and exponential backoff

New Files:
- core/src/jobs.rs - SQLx-based job queue implementation
- core/migrations/001_create_jobs_table.sql - Database schema

Modified:
- core/Cargo.toml - Added sqlx, uuid, chrono dependencies
- core/src/main.rs - Added job endpoints and integration

Features:
- POST /jobs/submit - Submit async job
- GET /jobs/:id - Check job status
- POST /jobs/:id/cancel - Cancel job
- Configurable concurrency (max_concurrent_jobs)
- Automatic cleanup of old completed jobs
- Progress tracking stored in database
@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 24, 2026

@knightsdev001 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@ayomideadeniran ayomideadeniran merged commit 35627a4 into SoroLabs:main Mar 24, 2026
1 of 4 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.

[Backend] Scalable Async Task Queue & Webhook System

2 participants