From 9596b284a28838d35e6eea10b706a80dabe3a565 Mon Sep 17 00:00:00 2001 From: Andrii Voznesenskyi Date: Wed, 30 Oct 2024 22:16:08 +0100 Subject: [PATCH] (#140) paralax grpc: [pack-all-force] --- .../src/Paralax.gRPC/Extensions.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Paralax.gRPC/src/Paralax.gRPC/Extensions.cs b/src/Paralax.gRPC/src/Paralax.gRPC/Extensions.cs index 6f62523..44d744d 100644 --- a/src/Paralax.gRPC/src/Paralax.gRPC/Extensions.cs +++ b/src/Paralax.gRPC/src/Paralax.gRPC/Extensions.cs @@ -11,7 +11,7 @@ using System.Diagnostics; using Microsoft.Extensions.Options; -namespace Paralax.gRPC.Extensions +namespace Paralax.gRPC { public static class GrpcExtensions { @@ -25,8 +25,8 @@ public static IParalaxBuilder AddGrpc(this IParalaxBuilder builder, IConfigurati { var optionsBuilder = new GrpcOptionsBuilder(); configureOptions.Invoke(optionsBuilder); - var grpcOptions = optionsBuilder.Build(); - builder.Services.AddSingleton(grpcOptions); + var grpcOptionsBuilt = optionsBuilder.Build(); + builder.Services.AddSingleton(grpcOptionsBuilt); } builder.Services.AddCommonProtobufServices(); @@ -35,11 +35,11 @@ public static IParalaxBuilder AddGrpc(this IParalaxBuilder builder, IConfigurati builder.Services.AddSingleton(); builder.Services.AddSingleton(); + var serviceProvider = builder.Services.BuildServiceProvider(); + var grpcOptions = serviceProvider.GetRequiredService>().Value; + builder.Services.Configure(options => { - var serviceProvider = builder.Services.BuildServiceProvider(); - var grpcOptions = serviceProvider.GetRequiredService>().Value; - options.ListenAnyIP(grpcOptions.Port, listenOptions => { listenOptions.Protocols = HttpProtocols.Http2; @@ -48,11 +48,15 @@ public static IParalaxBuilder AddGrpc(this IParalaxBuilder builder, IConfigurati builder.Services.AddGrpc(options => { - var grpcOptions = builder.Services.BuildServiceProvider().GetRequiredService>().Value; options.MaxReceiveMessageSize = grpcOptions.MaxReceiveMessageSize; options.MaxSendMessageSize = grpcOptions.MaxSendMessageSize; }); + if (grpcOptions.EnableReflection) + { + builder.Services.AddGrpcReflection(); + } + return builder; }