-
-
Save pyao-bwc/8d14826f2d449a8fa1fb8c46207834e7 to your computer and use it in GitHub Desktop.
Finalizer Deployment Issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @description Promise implementation in apex, per: | |
* https://developer.salesforce.com/blogs/2020/01/learn-moar-in-spring-20-implementing-promises-with-transaction-finalizers.html | |
* Tested By: PromniseTest | |
*/ | |
public abstract class Promise implements Queueable, Database.AllowsCallouts { | |
public List<Promise> promises = new List<Promise>(); | |
public Object passThrough; | |
public Boolean continueChainAfterFailure = true; | |
protected Chain chain; | |
public Promise then(Object toAdd) { | |
promises.add((Promise) toAdd); | |
return this; | |
} | |
abstract public void execute(); | |
public virtual void execute(QueueableContext context) { | |
chain = new Chain(this.promises, this.passThrough, this.continueChainAfterFailure); | |
System.attachFinalizer(chain); | |
execute(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment