|
3 | 3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
4 | 4 | //
|
5 | 5 |
|
6 |
| -using System; |
7 | 6 | using System.Threading;
|
8 | 7 | using System.Threading.Tasks;
|
9 | 8 |
|
10 |
| -using Grpc.Core; |
| 9 | +using Grpc.Net.Client; |
11 | 10 | using Microsoft.Azure.WebJobs.Script.Grpc.Messages;
|
12 | 11 |
|
13 | 12 | namespace Microsoft.Azure.Functions.PowerShellWorker.Messaging
|
14 | 13 | {
|
15 | 14 | internal class MessagingStream
|
16 | 15 | {
|
17 |
| - private readonly AsyncDuplexStreamingCall<StreamingMessage, StreamingMessage> _call; |
| 16 | + private readonly Grpc.Core.AsyncDuplexStreamingCall<StreamingMessage, StreamingMessage> _call; |
18 | 17 | private readonly SemaphoreSlim _semaphoreSlim = new SemaphoreSlim(initialCount: 1, maxCount: 1);
|
19 | 18 |
|
20 | 19 | internal MessagingStream(string host, int port)
|
21 | 20 | {
|
| 21 | + // To call unsecured gRPC services, ensure the address starts with 'http' as opposed to 'https'. |
| 22 | + // For more detail, see https://docs.microsoft.com/en-us/aspnet/core/grpc/client?view=aspnetcore-6.0 |
| 23 | + string address = $"{host}:{port}"; |
22 | 24 | const int maxMessageLength = int.MaxValue;
|
23 | 25 |
|
24 |
| - var channelOptions = new [] |
| 26 | + var channelOptions = new GrpcChannelOptions |
25 | 27 | {
|
26 |
| - new ChannelOption(ChannelOptions.MaxReceiveMessageLength, maxMessageLength), |
27 |
| - new ChannelOption(ChannelOptions.MaxSendMessageLength, maxMessageLength) |
| 28 | + MaxReceiveMessageSize = maxMessageLength, |
| 29 | + MaxSendMessageSize = maxMessageLength, |
28 | 30 | };
|
29 | 31 |
|
30 |
| - Channel channel = new Channel(host, port, ChannelCredentials.Insecure, channelOptions); |
| 32 | + GrpcChannel channel = GrpcChannel.ForAddress(address, channelOptions); |
31 | 33 | _call = new FunctionRpc.FunctionRpcClient(channel).EventStream();
|
32 | 34 | }
|
33 | 35 |
|
|
0 commit comments