-
Notifications
You must be signed in to change notification settings - Fork 772
/
Copy pathWeightedGroupsRoutingOptions.cs
39 lines (35 loc) · 1.82 KB
/
WeightedGroupsRoutingOptions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Microsoft.Extensions.Options;
namespace Microsoft.Extensions.Http.Resilience;
/// <summary>
/// Represents the options for collection of endpoint groups that have a weight assigned.
/// </summary>
/// <remarks>
/// This strategy picks the first endpoint group based on its weight and then selects the remaining groups in order,
/// starting from the first one and omitting the one that was already selected.
/// </remarks>
public class WeightedGroupsRoutingOptions
{
/// <summary>
/// Gets or sets the selection mode that determines the behavior of underlying routing strategy.
/// </summary>
public WeightedGroupSelectionMode SelectionMode { get; set; } = WeightedGroupSelectionMode.EveryAttempt;
/// <summary>
/// Gets or sets the collection of weighted endpoints groups.
/// </summary>
#pragma warning disable CA2227 // Collection properties should be read only
#pragma warning disable IL2026 // Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code
[Required]
#if NET8_0_OR_GREATER
[System.ComponentModel.DataAnnotations.Length(1, int.MaxValue)]
#else
[Microsoft.Shared.Data.Validation.Length(1)]
#endif
[ValidateEnumeratedItems]
public IList<WeightedUriEndpointGroup> Groups { get; set; } = new List<WeightedUriEndpointGroup>();
#pragma warning restore IL2026 // Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code
#pragma warning restore CA2227 // Collection properties should be read only
}