9 Star 60 Fork 31

liangren / elsa-core

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
BSD-3-Clause

Elsa Logo

Elsa Workflows

Nuget MyGet (with prereleases) Build status Gitter Stack Overflow questions Docker Pulls

Elsa Core is a workflows library that enables workflow execution in any .NET Core application. Workflows can be defined not only using code but also as JSON, YAML or XML.

Get Started

Follow the Getting Started instructions on the Elsa Workflows documentation site.

Roadmap

Version 1.0

  • Workflow Invoker
  • Long-running Workflows
  • Workflows as code
  • Workflows as data
  • Correlation
  • Persistence: CosmosDB, Entity Framework Core, MongoDB, YesSQL
  • HTML5 Workflow Designer Web Component
  • ASP.NET Core Workflow Dashboard
  • JavaScript Expressions
  • Liquid Expressions
  • Primitive Activities
  • Control Flow Activities
  • Workflow Activities
  • Timer Activities
  • HTTP Activities
  • Email Activities

Version 2.0

  • Service Bus Messaging
  • Generic Command & Event Activities
  • Workflow Host REST API
  • Workflow Host gRPC API
  • Workflow Server
  • Activity Harvesting
  • Distributed Hosting Support (support for multi-node environments)
  • Localization Support
  • Workflow Designer UI improvements
  • Activity Editor UI improvements

Version 3.0

  • State Machines
  • Container Activities

Workflow Designer

Workflows can be visually designed using Elsa Designer, a reusable & extensible HTML5 web component built with StencilJS. To manage workflow definitions and instances, Elsa comes with a reusable Razor Class Library that provides a dashboard application in the form of an MVC area that you can include in your own ASP.NET Core application.

Web-based workflow designer

Programmatic Workflows

Workflows can be created programmatically and then executed using IWorkflowInvoker.

Hello World

The following code snippet demonstrates creating a workflow with two custom activities from code and then invoking it:


// Define a strongly-typed workflow.
public class HelloWorldWorkflow : IWorkflow
{
    public void Build(IWorkflowBuilder builder)
    {
        builder
            .StartWith<HelloWorld>()
            .Then<GoodByeWorld>();
    }
}

// Setup a service collection.
var services = new ServiceCollection()
    .AddWorkflows()
    .AddActivity<HelloWorld>()
    .AddActivity<GoodByeWorld>()
    .BuildServiceProvider();

// Invoke the workflow.
var invoker = services.GetService<IWorkflowInvoker>();
await invoker.InvokeAsync<HelloWorldWorkflow>();

// Output:
// /> Hello World!
// /> Goodbye cruel World...

Persistence

Workflows can be persisted using virtually any storage mechanism. The following providers will be supported:

  • In Memory
  • File System
  • SQL Server
  • MongoDB
  • CosmosDB

Formats

Currently, workflows can be stored in YAML or JSON format. The following demonstrates a simple workflow expressed in YAML and JSON, respectively:

Long Running Workflows

Elsa has native support for long-running workflows. As soon as a workflow is halted because of some blocking activity, the workflow is persisted. When the appropriate event occurs, the workflow is loaded from the store and resumed.

Why Elsa Workflows?

One of the main goals of Elsa is to enable workflows in any .NET application with minimum effort and maximum extensibility. This means that it should be easy to integrate workflow capabilities into your own application.

What about Azure Logic Apps?

As powerful and as complete Azure Logic Apps is, it's available only as a managed service in Azure. Elsa on the other hand allows you to host it not only on Azure, but on any cloud provider that supports .NET Core. And of course you can host it on-premise.

Although you can implement long-running workflows with Logic Apps, you would typically do so with splitting your workflow with multiple Logic Apps where one workflow invokes the other. This can make the logic flow a bit hard to follow. with Elsa, you simply add triggers anywhere in the workflow, making it easier to have a complete view of your application logic. And if you want, you can still invoke other workflows form one workflow.

What about Windows Workflow Foundation?

I've always liked Windows Workflow Foundation, but unfortunately development appears to have halted. Although there's an effort being made to port WF to .NET Standard, there are a few reasons I prefer Elsa:

  • Elsa intrinsically supports triggering events that starts new workflows and resumes halted workflow instances in an easy to use manner. E.g. workflowHost.TriggerWorkflowAsync("HttpRequestTrigger");" will start and resume all workflows that either start with or are halted on the HttpRequestTrigger.
  • Elsa has a web-based workflow designer. I once worked on a project for a customer that was building a huge SaaS platform. One of the requirements was to provide a workflow engine and a web-based editor. Although there are commercial workflow libraries and editors out there, the business model required open-source software. We used WF and the re-hosted Workflow Designer. It worked, but it wasn't great.

What about Orchard Workflows?

Both Orchard and Orchard Core ship with a powerful workflows module, and both are awesome. In fact, Elsa Workflows is taken & adapted from Orchard Core's Workflows module. Elsa uses a similar model, but there are some differences:

  • Elsa Workflows is completely decoupled from web, whereas Orchard Core Workflows is coupled to not only the web, but also the Orchard Core Framework itself.
  • Elsa Workflows can execute in any .NET Core application without taking a dependency on any Orchard Core packages.

Features

The following lists some of Elsa's key features:

  • Small, simple and fast. The library should be lean & mean, meaning that it should be easy to use, fast to execute and easy to extend with custom activities.
  • Invoke arbitrary workflows as if they were functions of my application.
  • Trigger events that cause the appropriate workflows to automatically start/resume based on that event.
  • Support long-running workflows. When a workflow executes and encounters an activity that requires e.g. user input, the workflow will halt, be persisted and go out of memory until it's time to resume. this could be a few seconds later, a few minutes, hours, days or even years.
  • Correlate workflows with application-specific data. This is a key requirement for long-running workflows.
  • Store workflows in a file-based format so I can make it part of source-control.
  • Store workflows in a database when I don't want to make them part of source control.
  • A web-based designer. Whether I store my workflows on a file system or in a database, and whether I host the designer online or only on my local machine, I need to be able to edit my workflows.
  • Configure workflow activities with expressions. Oftentimes, information being processed by a workflow is dynamic in nature, and activities need a way to interact with this information. Workflow expressions allow for this.
  • Extensible with application-specific activities, custom stores and scripting engines.
  • Invoke other workflows. This allows for invoking reusable application logic from various workflows. Like invoking general-purpose functions from C# without having to duplicate code.
  • View & analyze executed workflow instances. I want to see which path a workflow took, its runtime state, where it faulted and compensate faulted workflows.
  • Embed the web-based workflow designer in my own dashboard application. This gives me the option of creating a single Workflow Host that runs all of my application logic, but also the option of hosting a workflows runtime in individual micro services (allowing for orchestration as well as choreography).
  • Separation of concerns: The workflow core library, runtime and designer should all be separated. I.e. when the workflow host should not have a dependency on the web-based designer. This allows one for example to implement a desktop-based designer, or not use a designer at all and just go with YAML files. The host in the end only needs the workflow definitions and access to persistence stores.
  • On premise or managed in the cloud - both scenarios are supported, because Elsa is just a set of NuGet packages that you reference from your application.

How to use Elsa

Elsa is distributed as a set of NuGet packages, which makes it easy to add to your application. When working with Elsa, you'll typically want to have at least two applications:

  1. An ASP.NET Core application to host the workflows designer.
  2. A .NET application that executed workflows

Setting up a Workflow Designer ASP.NET Core Application

TODO: describe all the steps to add packages and register services.

Setting up a Workflow Host .NET Application

TODO: describe all the steps to add packages and register services.

Building & Running Elsa Workflows Dashboard

In order to build & run Elsa on your local machine, follow these steps:

  1. Clone the repository.
  2. Run NPM install on src\dashboard\Elsa.Dashboard\Theme\argon-dashboard
  3. Execute gulp build from the directory src\dashboard\Elsa.Dashboard\Theme\argon-dashboard
  4. Open a shell and navigate to src\dashboard\Elsa.Dashboard.Web and run dotnet run.
  5. Navigate to http://localhost:22174/elsa/home

Code of Conduct

This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. For more information see the .NET Foundation Code of Conduct.

.NET Foundation

This project is supported by the .NET Foundation.

BSD 3-Clause License Copyright (c) 2020, .NET Foundation All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

简介

.NET 5开源工作流框架elsa 展开 收起
BSD-3-Clause
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/imlyqmayun/elsa-core.git
git@gitee.com:imlyqmayun/elsa-core.git
imlyqmayun
elsa-core
elsa-core
master

搜索帮助