forked from GoogleCloudPlatform/microservices-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HealthImpl.cs
23 lines (21 loc) · 814 Bytes
/
HealthImpl.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using System;
using System.Threading.Tasks;
using cartservice.interfaces;
using Grpc.Core;
using Grpc.Health.V1;
using StackExchange.Redis;
using static Grpc.Health.V1.Health;
namespace cartservice {
internal class HealthImpl : HealthBase {
private ICartStore dependency { get; }
public HealthImpl (ICartStore dependency) {
this.dependency = dependency;
}
public override Task<HealthCheckResponse> Check(HealthCheckRequest request, ServerCallContext context){
Console.WriteLine ("Checking CartService Health");
return Task.FromResult(new HealthCheckResponse {
Status = dependency.Ping() ? HealthCheckResponse.Types.ServingStatus.Serving : HealthCheckResponse.Types.ServingStatus.NotServing
});
}
}
}