Interface IVariableProvider
Defines a provider for reading and writing workflow variables to a specific storage backend.
public interface IVariableProvider
Examples
public class CustomVariableProvider : IVariableProvider
{
public async Task<bool> WriteVariable(string variableName, string variableValue, CancellationToken cancellationToken)
{
// Custom logic to write to an external system
return await WriteToExternalSystemAsync(variableName, variableValue);
}
public async Task<string?> ReadVariable(string jobName, string variableName, CancellationToken cancellationToken) =>
// Custom logic to read from an external system; null if this provider does not have it
await ReadFromExternalSystemAsync(jobName, variableName);
}
Remarks
This interface is part of Atom's extensible variable management system. Multiple providers can be registered, and the IVariableService will delegate operations to them in a chain of responsibility.
WriteVariable(string, string, CancellationToken) returns true if the provider handled the write, or false to allow
the next provider in the chain to attempt it. ReadVariable(string, string, CancellationToken) returns the variable's value, or
null to allow the next provider to attempt it.
Methods
ReadVariable(string, string, CancellationToken)
Reads a variable from the provider's storage system for a specific job context.
Task<string?> ReadVariable(string jobName, string variableName, CancellationToken cancellationToken = default)
Parameters
jobNamestringThe name of the job context from which to read the variable.
variableNamestringThe name of the variable to read.
cancellationTokenCancellationTokenA cancellation token.
Returns
- Task<string>
A task that resolves to the variable's value, or
nullif this provider cannot supply it.
WriteVariable(string, string, CancellationToken)
Writes a variable to the provider's storage system.
Task<bool> WriteVariable(string variableName, string variableValue, CancellationToken cancellationToken = default)
Parameters
variableNamestringThe name of the variable to write.
variableValuestringThe value to store for the variable.
cancellationTokenCancellationTokenA cancellation token.
Returns
- Task<bool>
A task that resolves to
trueif the provider successfully handled the write operation; otherwise,falseto delegate to the next provider.