using Elsa.Http.Options; using Elsa.Mediator.Contracts; using Elsa.Workflows.Runtime.Notifications; using JetBrains.Annotations; using Microsoft.Extensions.Options; namespace Elsa.Http.Handlers; /// /// A handler that updates the route table when workflow triggers and bookmarks are indexed. /// [UsedImplicitly] public class UpdateRouteTable(IRouteTableUpdater routeTableUpdater, IOptions options) : INotificationHandler, INotificationHandler { /// public async Task HandleAsync(WorkflowTriggersIndexed notification, CancellationToken cancellationToken) { routeTableUpdater.RemoveRoutes(notification.IndexedWorkflowTriggers.RemovedTriggers); await routeTableUpdater.AddRoutesAsync(notification.IndexedWorkflowTriggers.AddedTriggers, cancellationToken); await routeTableUpdater.AddRoutesAsync(notification.IndexedWorkflowTriggers.UnchangedTriggers, cancellationToken); } /// public async Task HandleAsync(WorkflowBookmarksIndexed notification, CancellationToken cancellationToken) { routeTableUpdater.RemoveRoutes(notification.IndexedWorkflowBookmarks.RemovedBookmarks); await routeTableUpdater.AddRoutesAsync(notification.IndexedWorkflowBookmarks.AddedBookmarks, notification.IndexedWorkflowBookmarks.WorkflowExecutionContext, cancellationToken); } }