-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Motivation
Queueables are often created only to enter an async context. When code is already running asynchronously, enqueuing another Queueable is frequently unnecessary and leads to overuse of async jobs, added complexity, and avoidable governor pressure.
Proposed Idea
Introduce a context-aware async execution strategy where business logic can:
• Execute immediately if already in an async context, or
• Enqueue a Queueable only when needed.
The Queueable itself should be lightweight and act only as an entry point to the business logic.
Decision Logic
Execution behavior could be determined by:
• Current execution context (sync vs async)
• Governor limits (e.g. CPU usage)
• Configurable defaults via Custom Metadata
Callers could override behavior per use case:
• Always async
• Force immediate execution
• Let the framework decide (similar to Flow’s “Let the flow decide”)
Benefits
• Reduced Queueable overuse
• Better async efficiency and limit utilization
• Less reliance on async exception-handling patterns