/// <summary> /// Starts the grpc server, binds the <see cref="QualityVerificationGrpcImpl"/> together /// with the <see cref="IServiceHealth"/> implementation and returns a handle for both. /// </summary> /// <param name="arguments">The microserver command line / config arguments.</param> /// <param name="inputsFactoryMethod">The factory method that creates the /// <see cref="IBackgroundVerificationInputs"/> instance. If no factory is proveded, only /// stand-alone verification (such as XML) can be used.</param> /// <param name="checkout3dAnalyst"></param> /// <param name="markUnhealthyOnExceptions"></param> /// <returns></returns> public static StartedGrpcServer StartVerificationServer( [NotNull] MicroserverArguments arguments, [CanBeNull] Func <VerificationRequest, IBackgroundVerificationInputs> inputsFactoryMethod, bool checkout3dAnalyst, bool markUnhealthyOnExceptions) { var healthService = new HealthServiceImpl(); IServiceHealth health = new ServiceHealth(healthService); var wuVerificationServiceImpl = new QualityVerificationGrpcImpl(inputsFactoryMethod, arguments.MaxParallel) { Checkout3DAnalyst = checkout3dAnalyst }; if (markUnhealthyOnExceptions) { wuVerificationServiceImpl.Health = health; } health.SetStatus(wuVerificationServiceImpl.GetType(), true); ServerCredentials serverCredentials = GrpcServerUtils.GetServerCredentials(arguments.Certificate, arguments.PrivateKeyFile, arguments.EnforceMutualTls); var oneGb = (int)Math.Pow(1024, 3); IList <ChannelOption> channelOptions = GrpcServerUtils.CreateChannelOptions(oneGb); var server = new Grpc.Core.Server(channelOptions) { Services = { QualityVerificationGrpc.BindService(wuVerificationServiceImpl), Health.BindService(healthService) }, Ports = { new ServerPort(arguments.HostName, arguments.Port, serverCredentials) } }; server.Start(); _msg.InfoFormat("Service is listening on host {0}, port {1}.", arguments.HostName, arguments.Port); return(new StartedGrpcServer(server, health)); }
/// <summary> /// Starts the grpc server, binds the <see cref="QualityVerificationGrpcImpl"/> together /// with the <see cref="IServiceHealth"/> implementation and returns a handle for both. /// </summary> /// <param name="arguments">The microserver command line / config arguments.</param> /// <param name="inputsFactory">The factory method that creates the /// <see cref="IBackgroundVerificationInputs"/> instance. If no factory is proveded, only /// stand-alone verification (such as XML) can be used.</param> /// <param name="markUnhealthyOnExceptions"></param> /// <returns></returns> public static StartedGrpcServer <QualityVerificationGrpcImpl> StartVerificationServer( [NotNull] MicroserverArguments arguments, [CanBeNull] Func <VerificationRequest, IBackgroundVerificationInputs> inputsFactory, bool markUnhealthyOnExceptions) { var healthService = new HealthServiceImpl(); IServiceHealth health = new ServiceHealth(healthService); LoadReportingGrpcImpl loadReporting = new LoadReportingGrpcImpl(); ServiceLoad serviceLoad = new ServiceLoad(arguments.MaxParallel); loadReporting.AllowMonitoring(nameof(QualityVerificationGrpc), serviceLoad); var verificationServiceImpl = new QualityVerificationGrpcImpl(inputsFactory, arguments.MaxParallel) { CurrentLoad = serviceLoad }; if (markUnhealthyOnExceptions) { verificationServiceImpl.Health = health; } health.SetStatus(verificationServiceImpl.GetType(), true); Grpc.Core.Server server = StartGrpcServer(arguments, verificationServiceImpl, healthService, loadReporting); _msg.InfoFormat("Service is listening on host {0}, port {1}.", arguments.HostName, arguments.Port); return(new StartedGrpcServer <QualityVerificationGrpcImpl>( server, verificationServiceImpl, health)); }