elsa-workflows / elsa-core

A .NET workflows library
https://v3.elsaworkflows.io/
MIT License
6.26k stars 1.14k forks source link

[ENH] Readonly Workflow Variables #5551

Open sfmskywalker opened 3 months ago

sfmskywalker commented 3 months ago

Overview

We need the ability to mark workflow variables as readonly. This feature will ensure that once a variable is set, it cannot be modified within the workflow.

Use Case

Benefits

glime-ai[bot] commented 3 months ago

To implement a feature that marks workflow variables as readonly in Elsa Workflows, you would need to extend the workflow engine's capabilities. As of my knowledge cutoff in early 2023, Elsa Workflows does not natively support marking variables as readonly. However, you can achieve similar functionality through custom development.

Here's a general approach you could take:

  1. Custom Activity: Create a custom activity that sets a variable and marks it as readonly. This activity would register the variable in a special list or dictionary that tracks readonly variables.

  2. Variable Interceptor: Implement a variable interceptor that checks if a variable is marked as readonly before allowing it to be set. If a variable is readonly and an attempt is made to modify it, the interceptor would throw an exception or ignore the change.

  3. Workflow Behavior: Introduce a custom workflow behavior that integrates with the variable interceptor to enforce the readonly rule throughout the workflow execution.

  4. Design-Time Support: If you're using a visual designer, you might need to extend the designer to allow marking variables as readonly.

  5. Documentation and Testing: Update your project documentation to explain how to use the readonly feature and create test cases to ensure it works as expected.

  6. Contribution to Elsa: If this is a feature that could benefit others, consider contributing it back to the Elsa project.

Remember to follow the Elsa Workflows documentation and guidelines for extending the workflow engine and creating custom activities. You may also want to engage with the Elsa community for support and to discuss the potential for including this feature in future releases.

Since this is a custom feature, there is no direct documentation link to provide. However, you can refer to the Elsa Workflows documentation for creating custom activities and extending the workflow engine:

Please note that the URLs provided are based on the documentation structure as of my knowledge cutoff date, and they may have changed since then. You should check the latest Elsa Workflows documentation for the most up-to-date information.

This comment was generated by Glime.