deveel - Deveel.Workflows 1.0.0-r00064

A lightweight library for designing and executing workflows through .NET

PM> Install-Package Deveel.Workflows -Version 1.0.0-r00064 -Source https://www.myget.org/F/deveel/api/v3/index.json

Copy to clipboard

> nuget.exe install Deveel.Workflows -Version 1.0.0-r00064 -Source https://www.myget.org/F/deveel/api/v3/index.json

Copy to clipboard

> dotnet add package Deveel.Workflows --version 1.0.0-r00064 --source https://www.myget.org/F/deveel/api/v3/index.json

Copy to clipboard
<PackageReference Include="Deveel.Workflows" Version="1.0.0-r00064" />
Copy to clipboard
source https://www.myget.org/F/deveel/api/v3/index.json

nuget Deveel.Workflows  ~> 1.0.0-r00064
Copy to clipboard

> choco install Deveel.Workflows --version 1.0.0-r00064 --source https://www.myget.org/F/deveel/api/v2

Copy to clipboard
Import-Module PowerShellGet
Register-PSRepository -Name "deveel" -SourceLocation "https://www.myget.org/F/deveel/api/v2"
Install-Module -Name "Deveel.Workflows" -RequiredVersion "1.0.0-r00064" -Repository "deveel" -AllowPreRelease
Copy to clipboard

Build status MyGet NuGet

DFlow

This is a lightweight library, with no aim to be an enterprise-level solution, to easily design in-code workflows to operate from an initial state to a final state.

Install

Workflows

The workflow model offered by DFlow is simple and is read-only: once defined the workflow model is immutable.

Worflow
+- Activity1
+- Activity2
+- Branch1
+--- Branch-Activity1
+--- Branch-Activity2

A workflow is designed as a container of activities and follows a sequential order of execution (that means, the result of an activity is the input of the next activity) Branches to the workflow can be defined with other strategies of execution (the provided ones are parallel and sequential)

Activities

Activities are structured in a decision-tree model

  • Is the activity executable given the current state?
  • Execute the activity and return a new state next to the current

There are four kind of pre-defined activities in DFlow

  1. Execution Activity: is the foundation activity for decision making and executing of a step of the workflow. In fact, all other activities derive from this
  2. Branch Activity: creates a branch of activities to execute within a workflow or othr branches
  3. Merge Activity: an activitiy that merges the resulting state of a parallel executed branch, using a strategy defined by the user, to come out with a single result
  4. Repeat Activity: given a decisor (a logic to evaluate the current state), this activity repeat the current branch until the condition of the decisor is met (much like a do-while logic)

It is possible to implement new activities using the library: in fact all the activities derive from the Execution Activity

Example Code

It is possible to implement flows with two strategy of coding:

  1. Direct Moderling: define instances of the workflow and its steps
  2. Dynamic Building Modeling: define the workflows and steps in a virtual building process (useful for later activation of components)
/// Simple workflow builder
var builder = Workflow.Build(workflow => workflow               // 1.
    .Activity<Emit>()                                           // 2.
    .Activity(activity => activity                              // 3.
        .Named("do")                                            // 4.
        .If(state => state.Value is bool && (bool)c.Value)      // 5.
        .Execute(state => {                                     // 6.
            Console.WriteLine("Hello!"); 
         })
     .Branch(branch => branch                                   // 7.
        .Named("branch1")                                       // 8.
        .InParallel()                                           // 9.
        .Activity<PActivity1>()                                 // 10.
        .Activity<PActivity2>())
     .Merge(BranchMergeStrategy.Instance));                     // 11.
        
var workflow = builder.Build();                                 // 12.

Th code above gives a general idea of a building model, and the possibilities are many more than those presented above, but in the specific:

  1. The factory of a workflow builder
  2. Defines a reference to a user-defined activity Emit, derived by Activity or implementing IActivity
  3. Defines dynamically an activity using a builder
  4. Gives the name ("do") to the dynamically defined activity: an activity should always be named and activity builders require the definition of the name
  5. Specifies a condition to met for the activity to be executed: it takes a State object ar input
  6. The code to be executed if the condition is met: this overload takes a State parameter and is executed synchronously; other overloads allow to execute asynchronous operations and provide a CancellationToken parameter
  7. Creates a branch within the workflow
  8. Gives a name to the branch: being components of a workflow, branches should be named (the builder model requires the specification of a name for branches)
  9. Defines the strategy of execution of the branch: by default, the strategy applies is Sequential, so it is possible to change it to other strategies
  10. Attaches a user-defined activity PActivity1 to the branch that will be executed in parallel with the other activities
  11. Because the branch execution strategy defined is Parallel, the resulting State will be a container of the states resulted from the parallel execution of the activities in the branch; this activity merges the states into a single state, using a user-defined strategy (BranchMergeStrategy.Instance) for merging the values of the states
  12. The builder builds a Workflow object using a default IBuildContext (that constructs Activity references with a simple constructor): to build workflows with more advanced service resolving, a new implemenation of IBuildContext is required.
  • .NETStandard 1.5
    • Microsoft.Extensions.DependencyInjection.Abstractions (>= 1.1.0)
    • NETStandard.Library (>= 1.6.1)
    • System.ComponentModel (>= 4.3.0)
  • .NETStandard 1.5: 1.5.0.0

Owners

Antonello Provenzano

Authors

Antonello Provenzano

Project URL

https://github.com/deveel/dflow

License

MIT

Tags

workflow dotnet core activity activities job graph

Info

2 total downloads
0 downloads for version 1.0.0-r00064
Download (28.54 KB)
Found on the current feed only

Package history

Version Size Last updated Downloads Mirrored?
1.0.0-r00064 28.54 KB Sat, 06 May 2017 12:47:40 GMT 0
1.0.0-r00061 28.54 KB Sun, 30 Apr 2017 22:10:07 GMT 1
1.0.0-r00042 25.29 KB Sat, 11 Mar 2017 14:18:55 GMT 0
1.0.0-r00041 25.2 KB Fri, 10 Mar 2017 23:27:22 GMT 0
1.0.0-r00040 25.15 KB Thu, 09 Mar 2017 19:01:47 GMT 0
1.0.0-r00039 25.01 KB Sat, 04 Mar 2017 20:23:43 GMT 0
1.0.0-r00038 24.06 KB Sat, 25 Feb 2017 10:23:13 GMT 1
1.0.0-r00037 24.07 KB Fri, 24 Feb 2017 18:39:54 GMT 0