-
Notifications
You must be signed in to change notification settings - Fork 791
/
Copy pathServiceMapping.cs
86 lines (78 loc) · 3.72 KB
/
ServiceMapping.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
85
86
#region Copyright notice and license
// Copyright 2019 The gRPC Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#endregion
namespace Grpc.AspNetCore.HealthChecks;
/// <summary>
/// Represents the mapping of health check results to a service exposed by the gRPC health checks API.
/// </summary>
public sealed class ServiceMapping
{
/// <summary>
/// Creates a new instance of <see cref="ServiceMapping"/>.
/// </summary>
/// <param name="name">The service name.</param>
/// <param name="predicate">The predicate used to filter <see cref="HealthResult"/> instances. These results determine service health.</param>
[Obsolete("This constructor is obsolete and will be removed in the future. Use ServiceMapping(string name, Func<HealthCheckRegistration, bool> predicate) to map service names to .NET health checks.")]
public ServiceMapping(string name, Func<HealthResult, bool> predicate)
{
Name = name;
Predicate = predicate;
}
/// <summary>
/// Creates a new instance of <see cref="ServiceMapping"/>.
/// </summary>
/// <param name="name">The service name.</param>
/// <param name="predicate">
/// The predicate used to filter health checks when the <c>Health</c> service <c>Check</c> and <c>Watch</c> methods are called.
/// <para>
/// The <c>Health</c> service methods have different behavior:
/// </para>
/// <list type="bullet">
/// <item><description><c>Check</c> uses the predicate to determine which health checks are run for a service.</description></item>
/// <item><description><c>Watch</c> periodically runs all health checks. The predicate filters the health results for a service.</description></item>
/// </list>
/// <para>
/// The health result for the service is based on the health check results.
/// </para>
/// </param>
public ServiceMapping(string name, Func<HealthCheckMapContext, bool> predicate)
{
Name = name;
HealthCheckPredicate = predicate;
}
/// <summary>
/// Gets the service name.
/// </summary>
public string Name { get; }
/// <summary>
/// Gets the predicate used to filter health checks when the <c>Health</c> service <c>Check</c> and <c>Watch</c> methods are called.
/// <para>
/// The <c>Health</c> service methods have different behavior:
/// </para>
/// <list type="bullet">
/// <item><description><c>Check</c> uses the predicate to determine which health checks are run for a service.</description></item>
/// <item><description><c>Watch</c> periodically runs all health checks. The predicate filters the health results for a service.</description></item>
/// </list>
/// <para>
/// The health result for the service is based on the health check results.
/// </para>
/// </summary>
public Func<HealthCheckMapContext, bool>? HealthCheckPredicate { get; }
/// <summary>
/// Gets the predicate used to filter <see cref="HealthResult"/> instances. These results determine service health.
/// </summary>
[Obsolete($"This member is obsolete and will be removed in the future. Use {nameof(HealthCheckPredicate)} to map service names to .NET health checks.")]
public Func<HealthResult, bool>? Predicate { get; }
}