| | | 1 | | using Elsa.Workflows.Runtime.Options; |
| | | 2 | | using Microsoft.Extensions.Options; |
| | | 3 | | |
| | | 4 | | // ReSharper disable once CheckNamespace |
| | | 5 | | namespace Elsa.Extensions; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// Validates <see cref="GracefulShutdownOptions"/>. |
| | | 9 | | /// </summary> |
| | | 10 | | public class ValidateGracefulShutdownOptions : IValidateOptions<GracefulShutdownOptions> |
| | | 11 | | { |
| | | 12 | | /// <inheritdoc /> |
| | | 13 | | public ValidateOptionsResult Validate(string? name, GracefulShutdownOptions options) |
| | | 14 | | { |
| | 93 | 15 | | var failures = new List<string>(); |
| | | 16 | | |
| | 93 | 17 | | if (options.DrainDeadline <= TimeSpan.Zero) |
| | 2 | 18 | | failures.Add($"{nameof(GracefulShutdownOptions.DrainDeadline)} must be greater than zero."); |
| | | 19 | | |
| | 93 | 20 | | if (options.IngressPauseTimeout <= TimeSpan.Zero) |
| | 2 | 21 | | failures.Add($"{nameof(GracefulShutdownOptions.IngressPauseTimeout)} must be greater than zero."); |
| | | 22 | | |
| | 93 | 23 | | if (options.StimulusQueueMaxDepthWhilePaused is <= 0) |
| | 2 | 24 | | failures.Add($"{nameof(GracefulShutdownOptions.StimulusQueueMaxDepthWhilePaused)} must be null (unlimited) o |
| | | 25 | | |
| | 93 | 26 | | if (options.MaxForceCancelledInstanceIdsReported <= 0) |
| | 2 | 27 | | failures.Add($"{nameof(GracefulShutdownOptions.MaxForceCancelledInstanceIdsReported)} must be greater than z |
| | | 28 | | |
| | 93 | 29 | | return failures.Count > 0 ? ValidateOptionsResult.Fail(failures) : ValidateOptionsResult.Success; |
| | | 30 | | } |
| | | 31 | | } |
| | | 32 | | |