With the new Winter '21 release, salesforce makes it much easier to detect what is a current running context by means of Request.getCurrent().getQuiddity() method. This is great, thank you, salesforce.
//Get info about the current request Request reqInfo = Request.getCurrent(); //Universally unique identifier for this request //Same as requestId in splunk or REQUEST_ID in event monitoring String currentRequestId = reqInfo.getRequestId(); //enum representing how Apex is running. e.g. BULK_API vs LIGHTNING //Use this with a switch statement, //instead of checking System.isFuture() || System.isQueueable() || ... Quiddity currentType = reqInfo.getQuiddity();
There is a list of System.Quiddity enumeration, for example, ANONYMOUS, AURA, etc.
Apex Per-Transaction Governor Limits are divided into two parts: synchronous limit and asynchronous limit. Some of them are different, for example, total number of SOQL queries issued, maximum number of Apex jobs added to the queue with
Finally, question. Is there any documentation, that could point, which enumeration is sync execution, and which is async?