Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions force-app/main/default/classes/Async.cls
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ public inherited sharing class Async {
return new SchedulableBuilder(scheduleJob);
}

public static Dependency after(String customJobId) {
return new Dependency().onCustomJobId(customJobId);
}

public static Dependency after(Result dependency) {
return new Dependency().onCustomJobId(dependency?.customJobId);
}

public static Dependency afterPrevious() {
return new Dependency().onPrevious();
}

public static QueueableJobContext getQueueableJobContext() {
return QueueableManager.get().getQueueableJobContext();
}
Expand All @@ -27,6 +39,14 @@ public inherited sharing class Async {
return new QueueableChainState().setCurrentQueueableChainState();
}

public static void stopChain() {
QueueableManager.get().stopChain();
}

public static void skipJob(String customJobId) {
QueueableManager.get().skipJob(customJobId);
}

public class QueueableJobContext {
public QueueableJob currentJob;
public QueueableContext queueableCtx {
Expand Down Expand Up @@ -126,6 +146,43 @@ public inherited sharing class Async {
SCHEDULABLE
}

public enum Outcome {
SUCCESS,
FAILURE,
COMPLETED
}

public class Dependency {
public Boolean previous = false;
public String resolvedTargetCustomJobId;
public Outcome requiredOutcome;

public Dependency onCustomJobId(String customJobId) {
this.resolvedTargetCustomJobId = customJobId;
return this;
}

public Dependency onPrevious() {
this.previous = true;
return this;
}

public Dependency succeeded() {
this.requiredOutcome = Outcome.SUCCESS;
return this;
}

public Dependency failed() {
this.requiredOutcome = Outcome.FAILURE;
return this;
}

public Dependency finished() {
this.requiredOutcome = Outcome.COMPLETED;
return this;
}
}

public class IllegalArgumentException extends Exception {
}
}
Loading
Loading