-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Encapsulate all the stuff related to process managers configuration i…
…n a single method (#109)
- Loading branch information
Showing
5 changed files
with
61 additions
and
55 deletions.
There are no files selected for viewing
44 changes: 0 additions & 44 deletions
44
samples/Orchestration/ProcessManagerSample/ProcessManagerNotificationHandler.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 13 additions & 6 deletions
19
src/Orchestration/NBB.ProcessManager.Runtime/DependencyInjectionExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/Orchestration/NBB.ProcessManager.Runtime/ProcessManagerNotificationHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using MediatR; | ||
using NBB.Core.Abstractions; | ||
using NBB.ProcessManager.Definition; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace NBB.ProcessManager.Runtime | ||
{ | ||
public class ProcessManagerNotificationHandler<TDefinition, TData, TEvent> : INotificationHandler<TEvent> | ||
where TDefinition : IDefinition<TData> | ||
where TData : struct | ||
where TEvent : INotification, IEvent | ||
{ | ||
private readonly ProcessExecutionCoordinator _pec; | ||
|
||
public ProcessManagerNotificationHandler(ProcessExecutionCoordinator pec) | ||
{ | ||
_pec = pec; | ||
} | ||
|
||
public async Task Handle(TEvent notification, CancellationToken cancellationToken) | ||
{ | ||
await _pec.Invoke<TDefinition, TData, TEvent>(notification, cancellationToken); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/Orchestration/NBB.ProcessManager.Runtime/TimeoutOccuredHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using MediatR; | ||
using NBB.Messaging.Abstractions; | ||
using NBB.ProcessManager.Runtime.Timeouts; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace NBB.ProcessManager.Runtime | ||
{ | ||
public class TimeoutOccuredHandler : INotificationHandler<TimeoutOccured> | ||
{ | ||
private readonly IMessageBusPublisher _busPublisher; | ||
|
||
public TimeoutOccuredHandler(IMessageBusPublisher busPublisher) | ||
{ | ||
_busPublisher = busPublisher; | ||
} | ||
|
||
public Task Handle(TimeoutOccured notification, CancellationToken cancellationToken) | ||
=> _busPublisher.PublishAsync(notification.Message, cancellationToken); | ||
} | ||
} |