temporalio / sdk-core

Core Temporal SDK that can be used as a base for language specific Temporal SDKs
MIT License
278 stars 77 forks source link

[Feature Request] Enable Eager Workflow Start #606

Closed antlai-temporal closed 1 year ago

antlai-temporal commented 1 year ago

Is your feature request related to a problem? Please describe.

Support for Eager Workflow Start has been enabled by the server since 1.20, and is already available in Java and Go SDKs. It reduces latency to start a new workflow by allowing the client to directly schedule a first task to a local worker, bypassing matching and an extra transaction/roundtrip. See https://github.com/temporalio/features/issues/242 for details.

We want to support Eager Workflow Start for core-based languages, starting with Python.

Describe the solution you'd like

The implementation relies on https://github.com/temporalio/sdk-core/issues/605, a worker registry that finds local compatible workers, and extends it with a SlotManager trait that provides a method to reserve a worker slot, and another one to schedule a task using this slot.

The client will also transparently use eager mode when it is enabled, and gracefully default to non-eager mode when either the server or the SlotManager rejects it.