| > Go already has that. However, what are the advantages of rescheduling an already running coroutine on a different machine? Say your coroutine is performing a transactional operation with multiple steps, but for some reason the second step starts getting rate limits from an upstream API, you need to enter a retry loop to reschedule the operation a bit later. What if your program stops then? Without capturing the state somewhere, it remains volatile in memory and the operation would be lost when the program stops. This scenario occurs in a wide range of systems, from simple async jobs for email delivery to complex workflows with fan-out and fan-in. > Isn't it expensive to serialize coroutines and transfer them between machines? We only capture the local scope of the call stack, so the amount of data that we need to record is pretty small and stays in the order of magnitude of the data being processed (e.g., the request payload). > I wonder what observability is like. If a coroutine crashes, what its stacktrace will look like? We maintain stack traces across await points of coroutine calls, even if the concurrent operations are scheduled on different program instances. When an error occurs, the stack traces show the entire code path that led to the error. There's definitely a lot of opportunities for creating powerful introspection tools, but since Dispatch is just code, you can also use your typical metrics, logs, and traces to instrument your distributed coroutines. |
What if the local stack references a deep object hierarchy? The classical "I wanted a banana, but got the gorilla holding the banana and the entire jungle"
>What if your program stops then? Without capturing the state somewhere, it remains volatile in memory and the operation would be lost when the program stops.
You persist coroutines on disk?