| | | 1 | | using CShells.FastEndpoints.Features; |
| | | 2 | | using CShells.Features; |
| | | 3 | | using Elsa.Expressions.Options; |
| | | 4 | | using Elsa.Extensions; |
| | | 5 | | using Elsa.Resilience.Entities; |
| | | 6 | | using Elsa.Resilience.Modifiers; |
| | | 7 | | using Elsa.Resilience.Options; |
| | | 8 | | using Elsa.Resilience.Recorders; |
| | | 9 | | using Elsa.Resilience.Serialization; |
| | | 10 | | using Elsa.Resilience.StrategySources; |
| | | 11 | | using Elsa.Workflows; |
| | | 12 | | using Microsoft.Extensions.DependencyInjection; |
| | | 13 | | |
| | | 14 | | namespace Elsa.Resilience.ShellFeatures; |
| | | 15 | | |
| | | 16 | | [ShellFeature] |
| | | 17 | | public class ResilienceFeature : IFastEndpointsShellFeature |
| | | 18 | | { |
| | | 19 | | public void ConfigureServices(IServiceCollection services) |
| | | 20 | | { |
| | 0 | 21 | | services.Configure<ExpressionOptions>(options => |
| | 0 | 22 | | { |
| | 0 | 23 | | options.AddTypeAlias<List<RetryAttemptRecord>>("RetryAttemptRecordList"); |
| | 0 | 24 | | }); |
| | | 25 | | |
| | 0 | 26 | | services.AddOptions<ResilienceOptions>(); |
| | | 27 | | |
| | 0 | 28 | | services |
| | 0 | 29 | | .AddSingleton<ResilienceStrategySerializer>() |
| | 0 | 30 | | .AddSingleton<IActivityDescriptorModifier, ResilientActivityDescriptorModifier>() |
| | 0 | 31 | | .AddScoped<IResilienceStrategyCatalog, ResilienceStrategyCatalog>() |
| | 0 | 32 | | .AddScoped<IResilienceStrategyConfigEvaluator, ResilienceStrategyConfigEvaluator>() |
| | 0 | 33 | | .AddScoped<IResilientActivityInvoker, ResilientActivityInvoker>() |
| | 0 | 34 | | .AddScoped<IResilienceStrategySource, ConfigurationResilienceStrategySource>() |
| | 0 | 35 | | .AddSingleton(VoidRetryAttemptRecorder.Instance) |
| | 0 | 36 | | .AddSingleton(VoidRetryAttemptReader.Instance) |
| | 0 | 37 | | .AddScoped<IRetryAttemptRecorder, ActivityExecutionContextRetryAttemptRecorder>() |
| | 0 | 38 | | .AddScoped<IRetryAttemptReader, ActivityExecutionContextRetryAttemptReader>() |
| | 0 | 39 | | .AddScoped<ActivityExecutionContextRetryAttemptReader>() |
| | 0 | 40 | | .AddHandlersFrom<ResilienceFeature>(); |
| | | 41 | | |
| | | 42 | | // Register transient exception detection infrastructure |
| | 0 | 43 | | services |
| | 0 | 44 | | .AddSingleton<ITransientExceptionStrategy, DefaultTransientExceptionStrategy>() |
| | 0 | 45 | | .AddSingleton<ITransientExceptionDetector, TransientExceptionDetector>(); |
| | 0 | 46 | | } |
| | | 47 | | } |