| | | 1 | | using Elsa.Connections.Contracts; |
| | | 2 | | using Elsa.Features.Abstractions; |
| | | 3 | | using Elsa.Features.Attributes; |
| | | 4 | | using Elsa.Features.Services; |
| | | 5 | | using Microsoft.Extensions.DependencyInjection; |
| | | 6 | | using Microsoft.Extensions.DependencyInjection.Extensions; |
| | | 7 | | using Microsoft.Extensions.Hosting; |
| | | 8 | | |
| | | 9 | | namespace Elsa.Connections.Features; |
| | | 10 | | |
| | | 11 | | /// <summary>Installs the opt-in hosted credential lifecycle reconciler.</summary> |
| | | 12 | | [DependsOn(typeof(ConnectionsFeature))] |
| | 0 | 13 | | public sealed class ConnectionLifecycleReconciliationFeature(IModule module) : FeatureBase(module) |
| | | 14 | | { |
| | | 15 | | public override void Apply() |
| | | 16 | | { |
| | 0 | 17 | | Services.TryAddSingleton<IConnectionLifecycleScopeProvider, EmptyConnectionLifecycleScopeProvider>(); |
| | 0 | 18 | | Services.AddOptions<ConnectionLifecycleReconciliationOptions>() |
| | 0 | 19 | | .Validate(options => options.Interval > TimeSpan.Zero, "Interval must be positive.") |
| | 0 | 20 | | .Validate(options => options.BatchSize is >= 1 and <= 500, "Batch size must be between 1 and 500.") |
| | 0 | 21 | | .Validate(options => options.MaxConcurrency is >= 1 and <= 64, "Maximum concurrency must be between 1 and 64 |
| | 0 | 22 | | .Validate(options => options.RetryBackoff > TimeSpan.Zero && options.MaxRetryBackoff >= options.RetryBackoff |
| | 0 | 23 | | "Retry backoff values are invalid.") |
| | 0 | 24 | | .ValidateOnStart(); |
| | 0 | 25 | | Services.AddSingleton<IHostedService, ConnectionLifecycleReconciliationWorker>(); |
| | 0 | 26 | | } |
| | | 27 | | } |