Skip to content

Changing Functions

Chris O'Hara edited this page Jul 2, 2024 · 3 revisions

Distributed coroutines

When Dispatch coroutines are compiled into distributed coroutines, the state of a suspended Dispatch function is sent to the Dispatch cloud service and persisted durably.

The function may change in the meantime, as bugs are fixed and/or features are added, and the state may no longer be compatible when Dispatch attempts to resume execution.

Incompatible state

The Dispatch SDK detects changes to functions and reports this information back to the Dispatch cloud service.

Go binaries included a unique build ID that changes as functions change, their dependencies change, or as the Go compiler or standard library changes. The Go build ID is embedded into the coroutine state by the Dispatch SDK and compared when resuming a coroutine. If the Go build ID does not match, the SDK reports an IncompatibleState error to the Dispatch cloud service.

Dispatch currently restarts coroutines when incompatible state is detected (i.e. calls the function again with its initial input). Any progress of the previous version of the coroutine is lost, and any in-flight work that was spawned during execution is discarded lazily.

It's important that function identifiers (the first argument to dispatch.Func), along with function input types, are stable. If the function name changes, or an incompatible change is made to the function input type, Dispatch is not able to restart the coroutine. To support changes to function input over time, it's recommended that users use a type that implements proto.Message, which enables forward and backward compatibility.