Add remote trigger support for finalization worker
Introduced `RemoteEnvelopeFinalizationTrigger` to enable triggering the envelope finalization worker via a remote HTTP endpoint. Added `BackgroundServicesOptions` for centralized configuration of background services, including enabling/disabling the local worker and configuring the remote trigger URL. Enhanced `TriggerFinalizationWorkerBehavior` with improved error handling and logging using `ILogger`. Added `DisableControllerConvention` to dynamically exclude controllers based on configuration. Updated `Program.cs` for conditional service registration and improved configuration loading. Modified `appsettings.json` and `appsettings.Development.json` to include remote trigger settings. Incremented project version to `2.1.0-beta`. Refactored code for better maintainability, scalability, and observability.
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
using EnvelopeGenerator.Application.Common.Interfaces;
|
||||
using EnvelopeGenerator.Application.DocReceiverElements.Commands;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DocReceiverElements.Behaviors;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class TriggerFinalizationWorkerBehavior(IEnvelopeFinalizationTrigger? Trigger = null) : IPipelineBehavior<SigningCommand, Unit>
|
||||
public class TriggerFinalizationWorkerBehavior(ILogger<TriggerFinalizationWorkerBehavior> Logger, IEnvelopeFinalizationTrigger? Trigger = null) : IPipelineBehavior<SigningCommand, Unit>
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
@@ -20,7 +21,16 @@ public class TriggerFinalizationWorkerBehavior(IEnvelopeFinalizationTrigger? Tri
|
||||
public async Task<Unit> Handle(SigningCommand request, RequestHandlerDelegate<Unit> next, CancellationToken cancellationToken)
|
||||
{
|
||||
if(Trigger != null)
|
||||
await Trigger.TriggerAsync(cancellationToken);
|
||||
try
|
||||
{
|
||||
|
||||
await Trigger.TriggerAsync(cancellationToken);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Log the exception or handle it as needed
|
||||
Logger.LogError(ex, "Error triggering finalization worker");
|
||||
}
|
||||
|
||||
return await next(cancellationToken);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user