Interfaccia IChainableNode

Namespace: Microsoft.Azure. Workflows.Sdk

Definisce il contratto di catena fluente per comporre le operazioni di workflow in pipeline di esecuzione sequenziali e parallele utilizzando il Then() pattern metodo. Sia IWorkflowOperation che OperationChain implementano questa interfaccia così da poter comporre flussi di lavoro lineari e ramificati in modo fluido.

Usage

var trigger = WorkflowTriggers.BuiltIn.CreateHttpTrigger();
var compose = WorkflowActions.BuiltIn.Compose(inputs: () => "Hello").WithName("Greet");
var response = WorkflowActions.BuiltIn.Response(responseBody: () => $"{compose.Output}").WithName("Reply");

trigger
    .Then(compose)
    .Then(response);

Methods

Allora(IWorkflowAction)

Chain una successiva IWorkflowAction da eseguire dopo che il nodo corrente si è completato con successo. Questo è il sovraccarico standard per costruire flussi di lavoro sequenziali.

OperationChain Then(IWorkflowAction action)
Name Description TIPO Required
action L'azione da aggiungere alla catena corrente. IWorkflowAction
var trigger = WorkflowTriggers.BuiltIn.CreateHttpTrigger();
var compose = WorkflowActions.BuiltIn.Compose(inputs: () => "Hello").WithName("Greet");
var response = WorkflowActions.BuiltIn.Response(responseBody: () => $"{compose.Output}").WithName("Reply");

trigger
    .Then(compose)
    .Then(response);

Allora(IWorkflowAction, FlowStatus[])

Catena una successiva IWorkflowAction con condizioni esplicite FlowStatus . Usa questo sovraccarico quando l'azione aggiunta dovrebbe essere eseguita solo dopo che l'azione precedente ha raggiunto uno degli stati specificati.

OperationChain Then(IWorkflowAction action, FlowStatus[] runAfter)
Name Description TIPO Required
action L'azione da aggiungere alla catena corrente. IWorkflowAction
runAfter I valori di stato che permettono all'azione aggiunta di essere eseguita. FlowStatus[]
var trigger = WorkflowTriggers.BuiltIn.CreateHttpTrigger();
var process = WorkflowActions.BuiltIn.Compose(inputs: () => "Process").WithName("Process");
var errorHandler = WorkflowActions.BuiltIn.Compose(inputs: () => "Error occurred").WithName("HandleError");

trigger
    .Then(process)
    .Then(errorHandler, runAfter: new[] { FlowStatus.Failed, FlowStatus.TimedOut });

Allora(IWorkflowAction, RunAfter[])

Chain una successiva IWorkflowAction con configurazione esplicita per predecessore RunAfter . Usa questo sovraccarico in scenari fan-in in cui la prossima azione deve attendere più catene predecessori.

OperationChain Then(IWorkflowAction action, RunAfter[] runAfter)
Name Description TIPO Required
action L'azione da aggiungere dopo che i predecessori configurati sono stati completati. IWorkflowAction
runAfter Le definizioni di run-after per predecessore che controllano quando l'azione viene eseguita. RunAfter[]
var trigger = WorkflowTriggers.BuiltIn.CreateHttpTrigger();
var leftChain = trigger
    .Then(WorkflowActions.BuiltIn.Compose(inputs: () => "Left").WithName("Left"));
var rightChain = trigger
    .Then(WorkflowActions.BuiltIn.Compose(inputs: () => "Right").WithName("Right"));
var merged = WorkflowActions.BuiltIn.Compose(inputs: () => "Done").WithName("Merged");

leftChain
    .Join(rightChain)
    .Then(merged, runAfter: new[]
    {
        new RunAfter(leftChain, FlowStatus.Succeeded),
        new RunAfter(rightChain, FlowStatus.Succeeded),
    });

Allora(Func<IChainableNode, OperationChain[]>)

Divide il nodo corrente in più rami paralleli. Il callback riceve l'IChainableNode corrente e deve restituire istanze OperationChain che condividono lo stesso nodo radice.

OperationChain Then(Func<IChainableNode, OperationChain[]> branches)
Name Description TIPO Required
branches Un callback che crea uno o più rami dal nodo corrente. Func<IChainableNode, OperationChain[]>
var trigger = WorkflowTriggers.BuiltIn.CreateHttpTrigger();
var branch1 = WorkflowActions.BuiltIn.Compose(inputs: () => "Branch 1").WithName("Branch1");
var branch2 = WorkflowActions.BuiltIn.Compose(inputs: () => "Branch 2").WithName("Branch2");
var merged = WorkflowActions.BuiltIn.Compose(inputs: () => "Merged").WithName("Merged");

trigger
    .Then(parent => new[]
    {
        parent.Then(branch1),
        parent.Then(branch2),
    })
    .Then(merged);