Class Runtime
DCR Workflow Runtime
public class Runtime
- Inheritance
-
Runtime
- Inherited Members
- Extension Methods
Remarks
The runtime takes care of executing activities, with necessary side-effects such as executing effects, running effect continuation activities, and running robot activities. Depending on configuration, model may be persisted back to the database.
Constructors
Runtime(IRuntimeConfigurationService, IServiceProvider, ILogger<Runtime>, RuntimeScheduler?, IRuntimeContextService?)
Multi-configuration runtime constructor
public Runtime(IRuntimeConfigurationService configService, IServiceProvider sp, ILogger<Runtime> logger, RuntimeScheduler? scheduler = null, IRuntimeContextService? context = null)
Parameters
configService
IRuntimeConfigurationServiceService providing current runtime configuration. NB! The service will be consulted at construction time, after which the configuration is fixed. If the service subsequentely changes state, that new state will not be reflected in the constructed runtime.
sp
IServiceProviderlogger
ILogger<Runtime>scheduler
RuntimeSchedulercontext
IRuntimeContextService
Remarks
This constructor is intended for multi-tenant settings, where the service environment contains an IRuntimeConfigurationService appropriate for the current tenant.
Runtime(RuntimeConfiguration, IServiceProvider, ILogger<Runtime>, RuntimeScheduler?, IRuntimeContextService?)
Canonical runtime constructor
public Runtime(RuntimeConfiguration config, IServiceProvider sp, ILogger<Runtime> logger, RuntimeScheduler? scheduler = null, IRuntimeContextService? context = null)
Parameters
config
RuntimeConfigurationStatic configuration
sp
IServiceProviderUsed to construct effects
logger
ILogger<Runtime>scheduler
RuntimeSchedulerOptional scheduler (for scheduling robots for automatic execution in the future)
context
IRuntimeContextServiceOptional service providing last-minute context such as current case or user id. Execute(Model, Activity, value?, Dictionary<string, string>?, Dictionary<string, string>?, List<LogEntry>?, CancellationToken?, ICasePersistor?).
Remarks
Note that all actual configuration of the runtime is given
by
Properties
Effects
public IEnumerable<string> Effects { get; }
Property Value
Methods
CommitTransactionAsync(Model, TransactionLogEntry, Dictionary<string, string>?, Dictionary<string, string>?, List<LogEntry>?, CancellationToken?, ICasePersistor?)
public Task<Model> CommitTransactionAsync(Model model, TransactionLogEntry transaction, Dictionary<string, string>? context = null, Dictionary<string, string>? secrets = null, List<LogEntry>? trace = null, CancellationToken? cts = null, ICasePersistor? persistor = null)
Parameters
model
Modeltransaction
TransactionLogEntrycontext
Dictionary<string, string>secrets
Dictionary<string, string>trace
List<LogEntry>cts
CancellationToken?persistor
ICasePersistor
Returns
Create(Action<IRuntimeBuilder>?)
public static Runtime Create(Action<IRuntimeBuilder>? configure = null)
Parameters
configure
Action<IRuntimeBuilder>
Returns
Execute(Model, Activity, value?, Dictionary<string, string>?, Dictionary<string, string>?, List<LogEntry>?, CancellationToken?, ICasePersistor?)
Execute an activity including follow-up actions such as running robots and executing effects
public Task<Model> Execute(Model model, Activity activity0, value? value0 = null, Dictionary<string, string>? context = null, Dictionary<string, string>? secrets = null, List<LogEntry>? trace = null, CancellationToken? cts = null, ICasePersistor? persistor = null)
Parameters
model
ModelThe DCR model to update. This model will be mutated.
activity0
ActivityThe activity of the model to execute. The activity must be enabled in the model.
value0
valueThe value to assign to he activity as part of the execution
context
Dictionary<string, string>Key-value pairs from the host system to be used in parameters
secrets
Dictionary<string, string>Key-value pairs from the host system to be used for authentication
trace
List<LogEntry>If supplied, a record of activites executed will be added to this list
cts
CancellationToken?A cancellation token
persistor
ICasePersistor
Returns
- Task<Model>
The updated model. NB! In case of concurrency conflicts, the returned model may have been reloaded from persistent store. It is important that calling code replaces any reference it might have to the
model
argument with the returned reference.
Exceptions
- KeyNotFoundException
- InvalidOperationException
- RuntimeException
Execute(Model, Request, Dictionary<string, string>?, Dictionary<string, string>?, List<LogEntry>?, CancellationToken?, ICasePersistor?)
public Task<Model> Execute(Model model, Request request, Dictionary<string, string>? context = null, Dictionary<string, string>? secrets = null, List<LogEntry>? trace = null, CancellationToken? cts = null, ICasePersistor? persistor = null)
Parameters
model
Modelrequest
Requestcontext
Dictionary<string, string>secrets
Dictionary<string, string>trace
List<LogEntry>cts
CancellationToken?persistor
ICasePersistor
Returns
ExecuteAsync(Activity, value?, Dictionary<string, string>?, Dictionary<string, string>?, List<LogEntry>?, CancellationToken?, ICasePersistor?)
public Task<Model> ExecuteAsync(Activity act, value? value = null, Dictionary<string, string>? context = null, Dictionary<string, string>? secrets = null, List<LogEntry>? trace = null, CancellationToken? cts = null, ICasePersistor? persistor = null)
Parameters
act
Activityvalue
valuecontext
Dictionary<string, string>secrets
Dictionary<string, string>trace
List<LogEntry>cts
CancellationToken?persistor
ICasePersistor
Returns
ExecuteAsync(Model, Request, Dictionary<string, string>?, Dictionary<string, string>?, List<LogEntry>?, CancellationToken?, ICasePersistor?)
Execute an activity including follow-up actions such as running robots and executing effects
public Task<Model> ExecuteAsync(Model model, Request request, Dictionary<string, string>? context = null, Dictionary<string, string>? secrets = null, List<LogEntry>? trace = null, CancellationToken? cts = null, ICasePersistor? persistor = null)
Parameters
model
ModelThe DCR model to update. This model will be mutated.
request
Requestcontext
Dictionary<string, string>Key-value pairs from the host system to be used in parameters
secrets
Dictionary<string, string>Key-value pairs from the host system to be used for authentication
trace
List<LogEntry>If supplied, a record of activites executed will be added to this list
cts
CancellationToken?A cancellation token
persistor
ICasePersistor
Returns
- Task<Model>
The updated model. NB! In case of concurrency conflicts, the returned model may have been reloaded from persistent store. It is important that calling code replaces any reference it might have to the
model
argument with the returned reference.
Exceptions
- KeyNotFoundException
- InvalidOperationException
- RuntimeException
ExecuteAsync(Model, string, value?, Dictionary<string, string>?, Dictionary<string, string>?, List<LogEntry>?, CancellationToken?, ICasePersistor?)
public Task<Model> ExecuteAsync(Model m, string activityId, value? value = null, Dictionary<string, string>? context = null, Dictionary<string, string>? secrets = null, List<LogEntry>? trace = null, CancellationToken? cts = null, ICasePersistor? persistor = null)
Parameters
m
ModelactivityId
stringvalue
valuecontext
Dictionary<string, string>secrets
Dictionary<string, string>trace
List<LogEntry>cts
CancellationToken?persistor
ICasePersistor
Returns
ExecuteClientEffectAsync(Model, Activity, value?, Dictionary<string, string>?, Dictionary<string, string>?, CancellationToken?, object?)
public Task<object?> ExecuteClientEffectAsync(Model model, Activity activity0, value? value0 = null, Dictionary<string, string>? context = null, Dictionary<string, string>? secrets = null, CancellationToken? cts = null, object? clientState = null)
Parameters
model
Modelactivity0
Activityvalue0
valuecontext
Dictionary<string, string>secrets
Dictionary<string, string>cts
CancellationToken?clientState
object
Returns
GetSpeculative()
public Runtime GetSpeculative()
Returns
Initialize(Model, Dictionary<string, string>?, Dictionary<string, string>?, Dictionary<string, string>?, List<LogEntry>?, ICasePersistor?)
public Task<Model> Initialize(Model model, Dictionary<string, string>? parameters = null, Dictionary<string, string>? context = null, Dictionary<string, string>? secrets = null, List<LogEntry>? trace = null, ICasePersistor? persistor = null)
Parameters
model
Modelparameters
Dictionary<string, string>context
Dictionary<string, string>secrets
Dictionary<string, string>trace
List<LogEntry>persistor
ICasePersistor
Returns
Load(string)
Load model from file
public Model Load(string filename)
Parameters
filename
string
Returns
Remarks
File will be assumed to contain an XML-serialized
model, unless the filename ends with .dcr
.
Parse(string, string?)
public Model Parse(string str, string? title = null)
Parameters
Returns
Parse(XDocument)
Deserialize an XML-serialized model
public Model Parse(XDocument xml)
Parameters
xml
XDocument
Returns
ParseDcr(string, string?)
Deserialize model from .dcr
source
format
public Model ParseDcr(string str, string? title = null)
Parameters
Returns
RunOnlyRobots(Model, Dictionary<string, string>?, Dictionary<string, string>?, List<LogEntry>?, CancellationToken?, ICasePersistor?)
public Task<Model> RunOnlyRobots(Model model, Dictionary<string, string>? context = null, Dictionary<string, string>? secrets = null, List<LogEntry>? trace = null, CancellationToken? cts = null, ICasePersistor? persistor = null)
Parameters
model
Modelcontext
Dictionary<string, string>secrets
Dictionary<string, string>trace
List<LogEntry>cts
CancellationToken?persistor
ICasePersistor
Returns
ValidateEffects(Model)
Statically verify that effects in model m are defined under current runtime
public IEnumerable<RuntimeException> ValidateEffects(Model m)
Parameters
m
Model
Returns
- IEnumerable<RuntimeException>
An empty sequence if all effects are defined or ignored, otherwise the sequence of errors detected
Remarks
Validation proceeds by instantiating effects for each activity one at a time. Validation respects ignore options for the Runtime; no validation errors will be reported for ignored effects, and if unknown effects are ignored, no errors will be reported at all.
ValidateModel(XDocument)
public IEnumerable<RuntimeException> ValidateModel(XDocument graph)
Parameters
graph
XDocument
Returns
- IEnumerable<RuntimeException>