dhiaayachi / temporal

Temporal service
https://docs.temporal.io
MIT License
0 stars 0 forks source link

Make UpdateWithStart API available #258

Open dhiaayachi opened 1 month ago

dhiaayachi commented 1 month ago

We have SignalWithStart that caller don't have to worry if the target workflow exists or not and the API will create a workflow if it does not already exists.

Same scenario is very useful for UpdateWorkflowExecution as well. It would be very useful to have UpdateWithStart API available.

dhiaayachi commented 3 weeks ago

Thank you for the feature request! It's a great idea to have an UpdateWithStart API for Temporal workflows, similar to SignalWithStart.

Currently, there isn't an API that combines UpdateWorkflowExecution and workflow creation in a single call. However, you can achieve this functionality with a simple workflow implementation:

  1. Create a dedicated workflow: This workflow will handle both workflow updates and creation if it doesn't exist.
  2. Use SignalWithStart to initiate the workflow: When you need to update the workflow, use SignalWithStart to start or signal the dedicated workflow.
  3. Within the workflow: The workflow will check if the target workflow exists. If it does, it will proceed with the update. If not, it will create the target workflow and then apply the update.

This approach allows you to have the desired behavior without requiring a specific UpdateWithStart API.

Let me know if you have any other questions.

dhiaayachi commented 3 weeks ago

Thank you for the feature request!

This is a great suggestion for improving the workflow interaction experience. Currently, UpdateWorkflowExecution doesn't have a WithStart equivalent.

To achieve the desired behavior of creating the workflow if it doesn't exist while updating it, you can consider using a combined approach:

  1. Check if the workflow exists using DescribeWorkflowExecution:
    • If the workflow exists, proceed with UpdateWorkflowExecution.
  2. If the workflow doesn't exist, start a new workflow using StartWorkflowExecution and then use UpdateWorkflowExecution to apply the desired updates.

This workaround provides the desired functionality while utilizing the existing API methods.

We value your feedback and will consider this suggestion for future enhancements to the Temporal SDK.

dhiaayachi commented 3 weeks ago

Thank you for the feature request! I understand the need for an UpdateWithStart API similar to SignalWithStart.

While we don't have UpdateWithStart implemented currently, you can achieve this behavior by:

  1. Checking for workflow existence: Use the DescribeWorkflowExecution API to check if the workflow exists.
  2. Update or start the workflow: If the workflow exists, use UpdateWorkflowExecution. If it doesn't, use StartWorkflowExecution.

This approach gives you the flexibility to handle both scenarios.

We appreciate your suggestion and will consider it for future development.

dhiaayachi commented 3 weeks ago

Thank you for your feature request! I understand the desire to have an UpdateWithStart API similar to SignalWithStart for updating workflows. Currently, Temporal does not offer such an API directly.

As a workaround, you could implement a pattern using a signal to trigger an update operation in your workflow. For example, you can send a signal containing the update data and handle it in your workflow code to update the workflow state accordingly. This allows you to update an existing workflow without needing to create a new one.

Let me know if this helps!