Skip to content

Commit 07d40dd

Browse files
committed
Updated channel and option types used
1 parent aae8d7b commit 07d40dd

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/Messaging/MessagingStream.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,33 @@
33
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
44
//
55

6-
using System;
76
using System.Threading;
87
using System.Threading.Tasks;
98

10-
using Grpc.Core;
9+
using Grpc.Net.Client;
1110
using Microsoft.Azure.WebJobs.Script.Grpc.Messages;
1211

1312
namespace Microsoft.Azure.Functions.PowerShellWorker.Messaging
1413
{
1514
internal class MessagingStream
1615
{
17-
private readonly AsyncDuplexStreamingCall<StreamingMessage, StreamingMessage> _call;
16+
private readonly Grpc.Core.AsyncDuplexStreamingCall<StreamingMessage, StreamingMessage> _call;
1817
private readonly SemaphoreSlim _semaphoreSlim = new SemaphoreSlim(initialCount: 1, maxCount: 1);
1918

2019
internal MessagingStream(string host, int port)
2120
{
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}";
2224
const int maxMessageLength = int.MaxValue;
2325

24-
var channelOptions = new []
26+
var channelOptions = new GrpcChannelOptions
2527
{
26-
new ChannelOption(ChannelOptions.MaxReceiveMessageLength, maxMessageLength),
27-
new ChannelOption(ChannelOptions.MaxSendMessageLength, maxMessageLength)
28+
MaxReceiveMessageSize = maxMessageLength,
29+
MaxSendMessageSize = maxMessageLength,
2830
};
2931

30-
Channel channel = new Channel(host, port, ChannelCredentials.Insecure, channelOptions);
32+
GrpcChannel channel = GrpcChannel.ForAddress(address, channelOptions);
3133
_call = new FunctionRpc.FunctionRpcClient(channel).EventStream();
3234
}
3335

0 commit comments

Comments
 (0)