Skip to content

Add Async.queueable() no-arg builder for conditional chaining#32

Merged
Mateusz7410 merged 2 commits into
mainfrom
feature/28
May 17, 2026
Merged

Add Async.queueable() no-arg builder for conditional chaining#32
Mateusz7410 merged 2 commits into
mainfrom
feature/28

Conversation

@Mateusz7410
Copy link
Copy Markdown
Collaborator

@Mateusz7410 Mateusz7410 commented May 17, 2026

Summary

  • Add Async.queueable() no-arg overload + matching QueueableBuilder() constructor so jobs can be chained incrementally
  • chain(QueueableJob) skips the implicit chain() step when the builder has no current job, so the first .chain(job) on an empty builder becomes the first job in the chain
  • enqueue() on an empty builder returns a Result with null salesforceJobId and an empty QueueableChainState (no-op, no exception)
  • Document the new entry point + add Result.job and clarify the salesforceJobId description in website/api/queueable.md
  • Add 4 new AsyncTest methods: empty enqueue, single chain on empty builder, multi-chain via repeated .chain(), and conditional-branch chaining

Why

Closes #28. Lets callers build a chain whose membership depends on runtime conditions without workarounds:

QueueableBuilder builder = Async.queueable();
if (cond1) { builder.chain(new Job1()); }
if (cond2) { builder.chain(new Job2()); }
if (cond3) { builder.chain(new Job3()); }
builder.enqueue(); // enqueues whatever was added; no-op if nothing was

Test plan

  • bash scripts/agent/verify.sh full (CI-parity local Apex tests + coverage)
  • bash scripts/agent/verify.sh ns (btcdev-namespaced scratch — package-install perspective)

Files

  • force-app/main/default/classes/Async.cls (+4)
  • force-app/main/default/classes/queue/QueueableBuilder.cls (+11, -2)
  • force-app/main/default/classes/AsyncTest.cls (+90, -1)
  • website/api/queueable.md (+73, -35)

Closes #28

Lets callers compose a queueable chain when the set of jobs depends on
runtime conditions, without needing a sentinel first job. Calling
enqueue() on a builder with zero jobs is a safe no-op that returns an
Async.Result with an empty queueableChainState.jobs list.

Closes #28
Adds the previously undocumented Result.job field to the Result
properties table, and rewords the salesforceJobId description to match
the post-fix behavior (the first-chain job id is now reported, not the
last builder-supplied one). Also notes the null states when enqueue()
is called on an empty Async.queueable() builder.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
async-lib Ready Ready Preview, Comment May 17, 2026 6:52pm

Request Review

@github-actions
Copy link
Copy Markdown

🧪 Apex Test Results

✅ All Tests Passed

==========================================
     APEX TEST EXECUTION SUMMARY
==========================================

📊 Total Tests: 89
✅ Passed: 89
❌ Failed: 0
⏭️  Skipped: 0


🎉 All tests passed successfully!

📦 Download Full Test Results & Logs


📊 Stats: 89 total | ✅ 89 passed | ❌ 0 failed
🤖 Automated comment by Salesforce CI

@codecov
Copy link
Copy Markdown

codecov Bot commented May 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.52%. Comparing base (2ff435d) to head (9908a89).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #32      +/-   ##
==========================================
+ Coverage   96.47%   96.52%   +0.04%     
==========================================
  Files          14       14              
  Lines         568      576       +8     
==========================================
+ Hits          548      556       +8     
  Misses         20       20              
Flag Coverage Δ
Apex 96.52% <100.00%> (+0.04%) ⬆️

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.

@Mateusz7410 Mateusz7410 merged commit 52055e6 into main May 17, 2026
5 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.

Allow to chain Queueable Jobs without the first one.

1 participant