-
Notifications
You must be signed in to change notification settings - Fork 732
/
WeightedUriEndpoint.cs
35 lines (30 loc) · 1 KB
/
WeightedUriEndpoint.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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.ComponentModel.DataAnnotations;
namespace Microsoft.Extensions.Http.Resilience;
/// <summary>
/// Represents a URI-based endpoint with a weight assigned.
/// </summary>
public class WeightedUriEndpoint
{
private const int MinWeight = 1;
private const int MaxWeight = 64000;
private const int DefaultWeight = MaxWeight / 2;
/// <summary>
/// Gets or sets the URL of the endpoint.
/// </summary>
/// <remarks>
/// Only schema, domain name, and port are used. The rest of the URL is constructed from the request URL.
/// </remarks>
[Required]
public Uri? Uri { get; set; }
/// <summary>
/// Gets or sets the weight of the endpoint.
/// </summary>
/// <value>
/// The default is 32000.
/// </value>
[Range(MinWeight, MaxWeight)]
public int Weight { get; set; } = DefaultWeight;
}