Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] Readonly Workflow Variables #5551

Open
sfmskywalker opened this issue Jun 7, 2024 · 1 comment
Open

[ENH] Readonly Workflow Variables #5551

sfmskywalker opened this issue Jun 7, 2024 · 1 comment
Labels
elsa 3 This issue is specific to Elsa 3 enhancement New feature or request

Comments

@sfmskywalker
Copy link
Member

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

  • An outer workflow scope defines a variable's value.
  • Subscopes should not be able to change the variable's value.
  • Similar to readonly fields in C# classes where variables are initialized and then set to readonly.

Benefits

  • Enhances data integrity within workflows.
  • Prevents accidental modifications of critical variables.
  • Aligns with best practices in programming for managing state and immutability.
@sfmskywalker sfmskywalker added enhancement New feature or request elsa 3 This issue is specific to Elsa 3 labels Jun 7, 2024
Copy link

glime-ai bot commented Jun 7, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
elsa 3 This issue is specific to Elsa 3 enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

1 participant