Базово работает

gRPC на отдельном порту
This commit is contained in:
2026-06-01 18:02:48 +03:00
parent 3af9cb1912
commit 50626c6ac6
38 changed files with 833 additions and 164 deletions

View File

@@ -15,7 +15,19 @@ public sealed class GrpcSmsClient : ISmsClient, IDisposable
public GrpcSmsClient(GrpcSmsClientOptions options)
{
_channel = GrpcChannel.ForAddress(options.Address);
var address = options.Address;
var channelOptions = new GrpcChannelOptions();
if (address.StartsWith("http://", StringComparison.OrdinalIgnoreCase))
{
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
channelOptions.HttpHandler = new SocketsHttpHandler
{
EnableMultipleHttp2Connections = true,
};
}
_channel = GrpcChannel.ForAddress(address, channelOptions);
_client = new SmsTestService.SmsTestServiceClient(_channel);
}
@@ -58,14 +70,12 @@ public sealed class GrpcSmsClient : ISmsClient, IDisposable
_channel.Dispose();
}
private static Dish ToDish(MenuItem item) => new()
{
Id = item.Id,
Article = item.Article,
Name = item.Name,
Price = (decimal)item.Price,
IsWeighted = item.IsWeighted,
FullPath = item.FullPath,
Barcodes = item.Barcodes.ToList(),
};
private static Dish ToDish(MenuItem item) => new(
item.Id,
item.Article,
item.Name,
(decimal)item.Price,
item.IsWeighted,
item.FullPath,
item.Barcodes.ToList());
}