Skip to main content
Durable coroutines enable durable execution of functions with arbitrary control flow. A coroutine is a function tat can be suspended and later resumed. A durable coroutine is a coroutine that can be suspended and later resume in another process. The original prcess can crash or be restarted manually, and any durable coroutines that were in-flight will be resume automatically. Durable coroutines are an answer to critical challenges when building distributed systems:
  • Determinism: Workflow based solutions require the application code to be deterministic. Creating quite a bit of constraints on the code that developers need to write. It many cases, it means that all code performing I/O operations or do things like generating random numbers need to be isolated. Many solutions expose a list of rules that developers have to follow in risk of exposing themselves to execution failures and impossibility of replay or resuming the executions.
  • Idempotency:
  • Consistency:

Creating a coroutine

In most of the cases, developers will not have to deal with coroutines directly. The coroc compiler is taking care of generating the code leveraging the coroutines.
import "github.com/stealthrocket/coroutine"

...

coro := coroutine.New[*Request, *Response](work)

func work() {

}

Deep dive

Stack

Suspend & Resume

Serializability