|
| 1 | +# Workflow Core 3.0.0 |
| 2 | + |
| 3 | +### Split DSL into own package |
| 4 | + |
| 5 | +The JSON and YAML definition features into their own package. |
| 6 | + |
| 7 | +Migration required for existing projects: |
| 8 | + |
| 9 | +* Install the `WorkflowCore.DSL` package from nuget. |
| 10 | +* Call `AddWorkflowDSL()` on your service collection. |
| 11 | + |
| 12 | +### Activities |
| 13 | + |
| 14 | +An activity is defined as an item on an external queue of work, that a workflow can wait for. |
| 15 | + |
| 16 | +In this example the workflow will wait for `activity-1`, before proceeding. It also passes the value of `data.Value1` to the activity, it then maps the result of the activity to `data.Value2`. |
| 17 | + |
| 18 | +Then we create a worker to process the queue of activity items. It uses the `GetPendingActivity` method to get an activity and the data that a workflow is waiting for. |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | +```C# |
| 23 | +public class ActivityWorkflow : IWorkflow<MyData> |
| 24 | +{ |
| 25 | + public void Build(IWorkflowBuilder<MyData> builder) |
| 26 | + { |
| 27 | + builder |
| 28 | + .StartWith<HelloWorld>() |
| 29 | + .Activity("activity-1", (data) => data.Value1) |
| 30 | + .Output(data => data.Value2, step => step.Result) |
| 31 | + .Then<PrintMessage>() |
| 32 | + .Input(step => step.Message, data => data.Value2); |
| 33 | + } |
| 34 | + |
| 35 | +} |
| 36 | +... |
| 37 | + |
| 38 | +var activity = host.GetPendingActivity("activity-1", "worker1", TimeSpan.FromMinutes(1)).Result; |
| 39 | + |
| 40 | +if (activity != null) |
| 41 | +{ |
| 42 | + Console.WriteLine(activity.Parameters); |
| 43 | + host.SubmitActivitySuccess(activity.Token, "Some response data"); |
| 44 | +} |
| 45 | + |
| 46 | +``` |
| 47 | + |
| 48 | +The JSON representation of this step would look like this |
| 49 | + |
| 50 | +```json |
| 51 | +{ |
| 52 | + "Id": "activity-step", |
| 53 | + "StepType": "WorkflowCore.Primitives.Activity, WorkflowCore", |
| 54 | + "Inputs": |
| 55 | + { |
| 56 | + "ActivityName": "\"activity-1\"", |
| 57 | + "Parameters": "data.Value1" |
| 58 | + }, |
| 59 | + "Outputs": { "Value2": "step.Result" } |
| 60 | +} |
| 61 | +``` |
0 commit comments