Skip to content

Add job dependencies (dependsOn) across Postgres, Redis, demo, and docs#40

Merged
nicnocquee merged 4 commits into
mainfrom
depends-on
Mar 22, 2026
Merged

Add job dependencies (dependsOn) across Postgres, Redis, demo, and docs#40
nicnocquee merged 4 commits into
mainfrom
depends-on

Conversation

@nicnocquee
Copy link
Copy Markdown
Owner

Summary

Adds optional job prerequisites via dependsOn: wait for listed jobs to complete and/or for tag-based “drain” barriers. Implements persistence and scheduling in PostgreSQL and Redis, exposes types and helpers (including batch references for addJobs), and documents the feature with a demo and API/usage pages.

Important changes

  • New dependsOn on job options: jobIds (all must complete) and tags (active barrier until no matching in-flight work)
  • PostgreSQL migration adds dependency columns; Postgres and Redis backends enforce prerequisites and cancel dependents when prerequisites fail or are cancelled
  • batchDepRef / resolution for dependencies inside the same addJobs batch
  • Demo: Dependencies page and monitor updates to illustrate behavior

Other changes

  • Docs: job-dependencies usage page, API cross-links, llms.txt / llms-full.txt updates
  • Website copy tweaks; AI rules/skills updated for the new feature
  • @nicnocquee/react types extended where needed

How to test

  1. Run the demo app, open the new Dependencies section from the sidebar, and run the dependency demo; confirm jobs order and blocking match the UI.
  2. Add jobs with dependsOn.jobIds and dependsOn.tags via the library or demo; verify a dependent stays pending until prerequisites complete, and that failure/cancel of a prerequisite cancels pending dependents as documented.
  3. With Postgres: apply migrations, enqueue dependent jobs, and confirm rows/constraints behave as expected.
  4. With Redis backend: repeat key flows and confirm equivalent behavior.
  5. Skim apps/docs/content/docs/usage/job-dependencies.mdx and linked API pages; confirm examples and behavior descriptions match the implementation.

- Introduced a new SQL migration to add `depends_on_job_ids` and `depends_on_tags` columns to the `job_queue` table, along with an index for efficient querying.
- Implemented job dependency management in the backend, allowing jobs to specify prerequisites that must be completed before execution.
- Enhanced the `JobOptions` and `JobRecord` interfaces to include fields for job dependencies.
- Added utility functions for normalizing and resolving job dependencies, ensuring robust handling of prerequisite jobs.
- Developed comprehensive tests for the new job dependency features, validating their functionality and integration.

These changes significantly enhance the job management capabilities of DataQueue, enabling more complex workflows and dependencies.
- Introduced a new feature for job dependencies, allowing jobs to specify prerequisites using `dependsOn.jobIds` and `dependsOn.tags`.
- Implemented a `DependencyDemo` component to showcase job dependency functionality, including linear chains and tag-drain barriers.
- Updated the `AddJobForm` to include a new job type for dependencies and enhanced the `JobMonitor` to display dependency information.
- Created comprehensive documentation on job dependencies, including usage examples and integration details.
- Updated the sidebar and comparison sections to reflect the new job dependencies feature.

These changes significantly enhance the job management capabilities of DataQueue, enabling more complex workflows and dependencies.
@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 22, 2026

Deploy Preview for dataqueue-demo ready!

Name Link
🔨 Latest commit d92eb1b
🔍 Latest deploy log https://app.netlify.com/projects/dataqueue-demo/deploys/69bfe5d95452010008addb4d
😎 Deploy Preview https://deploy-preview-40--dataqueue-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 22, 2026

Deploy Preview for docsdataqueuedev ready!

Name Link
🔨 Latest commit d92eb1b
🔍 Latest deploy log https://app.netlify.com/projects/docsdataqueuedev/deploys/69bfe5d92923be0008c74f56
😎 Deploy Preview https://deploy-preview-40--docsdataqueuedev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

- Introduced a new endpoint for batch job insertion at `/api/jobs/batch`, allowing multiple jobs to be added simultaneously with support for job dependencies using `dependsOn.jobIds` and `dependsOn.tags`.
- Updated the existing job creation endpoint to include the `dependsOn` field in the job options.
- Enhanced helper functions to support batch job addition and job dependency management.
- Added comprehensive end-to-end tests to validate the functionality of job dependencies and batch processing.

These changes significantly enhance the job management capabilities of DataQueue, enabling more complex workflows and efficient job handling.
- Updated the batch job processing endpoint to utilize a mapped array of job options, enhancing type safety with `JobOptions` and `JobType`.
- Improved code readability by separating the mapping logic from the job addition call.
- Ensured compatibility with the existing job dependency features introduced in previous commits.

These changes streamline the job addition process and maintain consistency with the recent enhancements in job management capabilities.
@nicnocquee nicnocquee merged commit b284237 into main Mar 22, 2026
10 checks passed
@nicnocquee nicnocquee deleted the depends-on branch March 22, 2026 12:54
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 22, 2026

Codecov Report

❌ Patch coverage is 66.24088% with 185 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.18%. Comparing base (f5717e2) to head (d92eb1b).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/dataqueue/src/backends/postgres.ts 44.84% 89 Missing and 2 partials ⚠️
packages/dataqueue/src/backends/redis.ts 46.47% 89 Missing and 2 partials ⚠️
packages/dataqueue/src/job-dependencies.ts 96.29% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #40      +/-   ##
==========================================
- Coverage   81.28%   80.18%   -1.11%     
==========================================
  Files          37       39       +2     
  Lines        7011     7515     +504     
  Branches      908      987      +79     
==========================================
+ Hits         5699     6026     +327     
- Misses       1292     1463     +171     
- Partials       20       26       +6     
Flag Coverage Δ
e2e 98.93% <100.00%> (+0.09%) ⬆️
unit 75.16% <55.52%> (-1.53%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant