elsa-core icon indicating copy to clipboard operation
elsa-core copied to clipboard

[Feat Request] Globally configure Variable storage driver

Open badsyntax opened this issue 10 months ago • 0 comments

Feature Request

Problem Overview

In cases where a (programmatic) workflow has many variables, it would be useful to globally configure the variable storage driver instead of specifying it for every variable.

Proposed Solution

Instead of doing this:

var myVariable1 = workflowBuilder.WithVariable<string>().WithMemoryStorage();
var myVariable2 = workflowBuilder.WithVariable<string>().WithMemoryStorage();
var myVariable3 = workflowBuilder.WithVariable<string>().WithMemoryStorage();

or

var myVariable1 = new Variable<string>().WithMemoryStorage();
workflowBuilder.Variables.Add(myVariable1);

var myVariable2 = new Variable<string>().WithMemoryStorage();
workflowBuilder.Variables.Add(myVariable2);

var myVariable3 = new Variable<string>().WithMemoryStorage();
workflowBuilder.Variables.Add(myVariable3);

It would be useful to do something like

workflowBuilder.WorkflowOptions.StorageDriverType = typeof(MemoryStorageDriver);

Then we don't need to specify the storage driver when creating Variables eg:

var myVariable1 = workflowBuilder.WithVariable<string>();
var myVariable2 = workflowBuilder.WithVariable<string>();
var myVariable3 = workflowBuilder.WithVariable<string>();

or

var myVariable1 = new Variable<string>();
workflowBuilder.Variables.Add(myVariable1);

var myVariable2 = new Variable<string>();
workflowBuilder.Variables.Add(myVariable2);

var myVariable3 = new Variable<string>();
workflowBuilder.Variables.Add(myVariable3);

Additional Context

https://discord.com/channels/814605913783795763/1385515616705708132/1386606615905435708

badsyntax avatar Jun 24 '25 05:06 badsyntax