-
Notifications
You must be signed in to change notification settings - Fork 146
/
GrpcOrchestratorServer.cs
46 lines (42 loc) · 1.46 KB
/
GrpcOrchestratorServer.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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System;
using BuildXL.Distribution.Grpc;
using BuildXL.Utilities.Configuration;
using BuildXL.Utilities.Instrumentation.Common;
#if NETCOREAPP
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;
#endif
namespace BuildXL.Engine.Distribution.Grpc
{
/// <summary>
/// Orchestrator server
/// </summary>
public sealed class GrpcOrchestratorServer : GrpcServer
{
private readonly GrpcOrchestrator m_grpcOrchestrator;
/// <nodoc/>
internal GrpcOrchestratorServer(LoggingContext loggingContext, IOrchestratorService orchestratorService, DistributedInvocationId invocationId)
: base(loggingContext, invocationId)
{
m_grpcOrchestrator = new GrpcOrchestrator(loggingContext, orchestratorService);
}
/// <inheritdoc/>
public override void Start(int port)
{
if (EngineEnvironmentSettings.GrpcKestrelServerEnabled)
{
#if NETCOREAPP
Action<object> configure = (endpoints) => ((IEndpointRouteBuilder)endpoints).MapGrpcService<GrpcOrchestrator>();
_ = StartKestrel(port, configure);
#endif
}
else
{
var serviceDefinition = Orchestrator.BindService(m_grpcOrchestrator);
Start(port, serviceDefinition);
}
}
}
}