-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
BestWorkerMode.cs
84 lines (77 loc) · 3.54 KB
/
BestWorkerMode.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.Text.Json;
using Azure.Core;
namespace Azure.Communication.JobRouter
{
/// <summary> Jobs are distributed to the worker with the strongest abilities available. </summary>
public partial class BestWorkerMode : IUtf8JsonSerializable
{
#region Default scoring rule
/// <summary> Initializes a new instance of BestWorkerModePolicy with default scoring rule.
/// Default scoring formula that uses the number of job labels that the worker labels match, as well as the number of label selectors the worker labels match and/or exceed
/// using a logistic function (https://en.wikipedia.org/wiki/Logistic_function).
/// </summary>
public BestWorkerMode()
{
Kind = DistributionModeKind.BestWorker;
}
#endregion
/// <summary>
/// A rule of one of the following types:
///
/// StaticRule: A rule
/// providing static rules that always return the same result, regardless of
/// input.
/// DirectMapRule: A rule that return the same labels as the input
/// labels.
/// ExpressionRule: A rule providing inline expression
/// rules.
/// FunctionRule: A rule providing a binding to an HTTP Triggered Azure
/// Function.
/// WebhookRule: A rule providing a binding to a webserver following
/// OAuth2.0 authentication protocol.
/// Please note <see cref="RouterRule"/> is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.
/// The available derived classes include <see cref="DirectMapRouterRule"/>, <see cref="ExpressionRouterRule"/>, <see cref="FunctionRouterRule"/>, <see cref="StaticRouterRule"/> and <see cref="WebhookRouterRule"/>.
/// </summary>
public RouterRule ScoringRule { get; set; }
/// <summary>
/// Encapsulates all options that can be passed as parameters for scoring rule with
/// BestWorkerMode
/// </summary>
public ScoringRuleOptions ScoringRuleOptions { get; set; }
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
if (Optional.IsDefined(ScoringRule))
{
writer.WritePropertyName("scoringRule"u8);
writer.WriteObjectValue(ScoringRule);
}
if (Optional.IsDefined(ScoringRuleOptions))
{
writer.WritePropertyName("scoringRuleOptions"u8);
writer.WriteObjectValue(ScoringRuleOptions);
}
writer.WritePropertyName("kind"u8);
writer.WriteStringValue(Kind.ToString());
if (Optional.IsDefined(MinConcurrentOffers))
{
writer.WritePropertyName("minConcurrentOffers"u8);
writer.WriteNumberValue(MinConcurrentOffers);
}
if (Optional.IsDefined(MaxConcurrentOffers))
{
writer.WritePropertyName("maxConcurrentOffers"u8);
writer.WriteNumberValue(MaxConcurrentOffers);
}
if (Optional.IsDefined(BypassSelectors))
{
writer.WritePropertyName("bypassSelectors"u8);
writer.WriteBooleanValue(BypassSelectors.Value);
}
writer.WriteEndObject();
}
}
}