elsa-core/src/modules/Elsa.Http/Handlers/UpdateRouteTable.cs
Sipke Schoorstra b3bae39bfe
Default Runtime & Persistence (#3287)
* Delete DefaultWorkflowInvoker.cs

* Incremental work

* Refactor runtime

* Implement workflow state store + bookmark store

* Cleanup

* Update migrations

* Move store abstractions to management and runtime projects

* Consolidate persistence providers into single package

* Generate migrations

* Regenerate migrations

* Fix DI of memory stores

* Update migrations

* Refactor definition reference due to unserializable record

* Update web server bundle to use EF core by default

* Update Bookmark.cs

Fixes System Text Json deserialization
2022-09-04 17:04:14 +02:00

32 lines
1.3 KiB
C#

using System.Threading;
using System.Threading.Tasks;
using Elsa.Http.Extensions;
using Elsa.Http.Services;
using Elsa.Mediator.Services;
using Elsa.Workflows.Runtime.Notifications;
namespace Elsa.Http.Handlers
{
public class UpdateRouteTable :
INotificationHandler<WorkflowTriggersIndexed>,
INotificationHandler<WorkflowBookmarksIndexed>
{
private readonly IRouteTable _routeTable;
public UpdateRouteTable(IRouteTable routeTable) => _routeTable = routeTable;
public Task HandleAsync(WorkflowTriggersIndexed notification, CancellationToken cancellationToken)
{
_routeTable.RemoveRoutes(notification.IndexedWorkflowTriggers.RemovedTriggers);
_routeTable.AddRoutes(notification.IndexedWorkflowTriggers.AddedTriggers);
_routeTable.AddRoutes(notification.IndexedWorkflowTriggers.UnchangedTriggers);
return Task.CompletedTask;
}
public Task HandleAsync(WorkflowBookmarksIndexed notification, CancellationToken cancellationToken)
{
_routeTable.RemoveRoutes(notification.IndexedWorkflowBookmarks.RemovedBookmarks);
_routeTable.AddRoutes(notification.IndexedWorkflowBookmarks.AddedBookmarks);
return Task.CompletedTask;
}
}
}