Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Releases: beyond-the-cloud-dev/async-lib

v2.6.0

08 Jun 13:11
@Mateusz7410 Mateusz7410

Choose a tag to compare

What's Changed

This release adds opt-in retry with backoff for failed Queueable jobs, dependency gating between chained jobs, imperative chain control, and a much richer AsyncResult__c audit trail. (#23, #34)

🚀 New Features

  • Retry & backoff for Queueable jobs. Opt in per job with retry(n) (capped at 10), choose a backoff(...) strategy, and narrow which failures retry with retryOn(...). Defaults can also come from QueueableJobSetting__mdt (MaxRetries, BackoffStrategy, BackoffBaseMinutes, RetryableExceptions). (#23, #34)

    Async.queueable(new MyJob())
     .retry(3)
     .backoff(Backoff.exponential(2))
     .retryOn(CalloutException.class)
     .enqueue();
  • Backoff strategies. New top-level Backoff class: Backoff.fixed(min), Backoff.exponential(base), Backoff.exponentialWithJitter(base) (all capped at the 10-minute platform limit).

  • Per-job retry hooks. Override isRetryable(Exception) to veto a retry, and resetForRetry() to reset mutable state before the job runs again.

  • Dependency gating. Gate a job on the outcome of an earlier one: dependsOn(Async.after(result).succeeded()), Async.afterPrevious().failed(), Async.after(customJobId).finished(). A job whose dependency doesn't match is skipped, and the skip cascades to its dependents — handy for compensation jobs.

  • Imperative chain control. From a finalizer, call Async.stopChain() to halt the rest of the chain, or Async.skipJob(customJobId) to skip a specific job.

  • Richer result tracking. An AsyncResult__c row per job (ran or skipped) now records status, chain id, class name, exception type/message, retry attempts and history, skip reason, required/actual outcome, and a self-lookup to the dependency's result. The new AsyncResultAccess permission set grants read access to these fields.

✨ Improvements

  • rollbackOnJobExecuteFail now actually rolls back the failed job's DML and lets the chain continue. Previously, set on its own, it was effectively a no-op and the chain halted. See upgrade notes.
  • API version raised to 66.0 across all classes and the project source API.

📚 Documentation

  • website/api/queueable.md documents retry, backoff, retryOn, dependsOn, the dependency builders, chain control, and the AsyncResult__c fields.
  • website/getting-started.md covers the retry and dependency entry points.

⚠️ Upgrade notes from v2.5.0

  • rollbackOnJobExecuteFail behavior change. If you set only rollbackOnJobExecuteFail and relied on the chain halting, it now rolls back and continues. To stop on failure, do not set the continue/rollback flags.

Install

https://login.salesforce.com/packaging/installPackage.apexp?p0=04tP6000003Hg17IAC
Assets 2
Loading
pgajek2 reacted with rocket emoji
1 person reacted

v2.5.0

17 May 19:46
@Mateusz7410 Mateusz7410

Choose a tag to compare

What's Changed

This release adds incremental queueable chain composition, fixes a set of chain-result and inner-class deep-clone bugs, and is the first time Async Lib is distributed as a btcdev-namespaced unlocked package.

🚀 New Features

  • Async.queueable() (no-arg) builder. Compose a queueable chain when the set of jobs depends on runtime conditions. Calling enqueue() on a builder with zero jobs is a safe no-op. (#28)

    QueueableBuilder builder = Async.queueable();
    if (needsJob1) { builder.chain(new Job1()); }
    if (needsJob2) { builder.chain(new Job2()); }
    if (needsJob3) { builder.chain(new Job3()); }
    builder.enqueue();
  • First packaged release. Async Lib is now distributed as a btcdev-namespaced unlocked package. See Installation.

✨ Improvements

🐛 Bug Fixes

  • Result.salesforceJobId now reports the actually-enqueued first-chain job id (previously the last builder-supplied job, which was never enqueued).
  • SchedulableManager.schedule() + skipWhenAlreadyScheduled() returns an empty List<Async.Result> on duplicate (previously null).
  • QueueableJob.cloneForDeepCopy() resolves inner job classes correctly (previously NPE'd because outer-class names were mistaken for namespaces).
  • Documented cloneForDeepCopy override pattern for namespaced consumers, fixing the JSONException seen when calling .deepClone() from a package install.

📚 Documentation

  • NEW Deep Clone in Packages — when and how to override cloneForDeepCopy for namespaced consumers.
  • Installation page covers the unlocked-package path and the btcdev namespace prefix callout.
  • Async.Result table documents the Result.job field and the corrected salesforceJobId semantics.
  • Documentation · Installation

⚠️ Upgrade notes from v2.4.0

  • Result.salesforceJobId is no longer null for chained-then-enqueued flows. If your code branched on result.salesforceJobId == null to detect that, switch to inspecting result.queueableChainState.jobs.
  • SchedulableBuilder.schedule() with skipWhenAlreadyScheduled() returns an empty list, not null. Replace result == null guards with result.isEmpty().
  • If you previously source-deployed the library and switch to the package install, replace Async.* / QueueableJob / etc. with btcdev.Async.* / btcdev.QueueableJob.

Install

https://login.salesforce.com/packaging/installPackage.apexp?p0=04tP60000038pYHIAY
Loading

Context Mocking for Queueable Jobs

31 Jan 13:02
@Mateusz7410 Mateusz7410
13fdb95
This commit was created on GitHub.com and signed with GitHub’s verified signature.
GPG key ID: B5690EEEBB952194
Verified
Learn about vigilant mode.

Choose a tag to compare

New Features

Context Mocking with AsyncMock

Test your async jobs with full control over QueueableContext and FinalizerContext. No more limitations when testing error handling paths or finalizer behavior.

@IsTest
static void shouldHandleJobFailure() {
 AsyncMock.whenFinalizer('error-handler')
 .thenThrow(new DmlException('Parent job failed'));
 Test.startTest();
 Async.queueable(new MyJob()).mockId('error-handler').enqueue();
 Test.stopTest();
}

Key capabilities:

  • whenQueueable() / whenFinalizer() - Setup mocks by mockId
  • whenQueueableDefault() / whenFinalizerDefault() - Default fallback mocks
  • thenReturn() / thenThrow() - Configure success or exception responses
  • Queue-based mock consumption for testing multiple invocations
  • Direct unit testing without Test.startTest()/stopTest()

mockId Builder Method

New mockId(String) method on QueueableBuilder to identify jobs for mocking.

Improvements

  • Renamed QueueableChainBatch to QueueableChainSchedulable
  • Added namespace checks when adding QueueableJobSetting metadata
  • Improved API documentation with structured tables for result properties

Documentation

AsyncMock API - Complete reference
Testing Async Jobs - Patterns and best practices

Loading

Soft and deep job cloning.

08 Nov 19:15
@Mateusz7410 Mateusz7410

Choose a tag to compare

This release introduces:

  • Soft and deep Clone of the Job - Enhanced QueueableBuilder with .deepClone() method for complete object isolation when working with complex object relationships. Learn more here.
Loading

Fix chaining job issue

05 Nov 22:23
@Mateusz7410 Mateusz7410

Choose a tag to compare

This release introduces:

  1. Fix for skipping chained jobs from the same context by cloning passed job.
Loading

On demand Queueable Job chaining and result enhancements

11 Oct 16:27
@Mateusz7410 Mateusz7410

Choose a tag to compare

This release introduces:

  1. New QueueableBuilder.chain() methods - chain() and chain(QueueableJob job), which allowing you to manually add jobs to an existing chain. You can now decide when to chain jobs — not just rely on the automatic chaining mechanism triggered when platform limits are hit.
  2. Enhanced Results from QueueableBuilder enqueue(), chain(), and chain(QueueableJob job) now return the Queueable Chain State. Additionally, enqueue() indicates whether the action created a new chain, continued an existing chain, or scheduled an initial job.
    → Learn more here.
  3. Access Queueable Chain State On-Demand
    Use Async.getCurrentQueueableChainState() to inspect the current chain — including all chained jobs, next job IDs, and chain type.
Loading

v2.0.0

01 Oct 09:21
@Mateusz7410 Mateusz7410

Choose a tag to compare

This release introduces:

  1. Change of initial job start, from 'Database.executeBatch()' to scheduling it in 1 minute in the future, due to issues related when using Queueable Jobs in Batches. Full explanation can be found here.
  2. New ScheduleableBuilder method skipWhenAlreadyScheduled() that allows scheduling only if the job with the same name is not already scheduled. More info here.
  3. Minor enhancements.
Loading

v1.0.0

24 Aug 16:19
@pgajek2 pgajek2

Choose a tag to compare

documentation
Loading

AltStyle によって変換されたページ (->オリジナル) /