Skip to content

upgrade grpc #1632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<ItemGroup>
<PackageReference Include="DotNet.Testcontainers" Version="1.5.0" />
<PackageReference Include="Grpc.Tools" Version="2.42.0" PrivateAssets="All" />
<PackageReference Include="Grpc.Tools" Version="2.46.3" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
<PackageReference Include="MongoDB.Driver" Version="2.14.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/ClusterBenchmark/ClusterBenchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<ItemGroup>
<PackageReference Include="DotNet.Testcontainers" Version="1.5.0" />
<PackageReference Include="Grpc.Tools" Version="2.42.0" PrivateAssets="All" />
<PackageReference Include="Grpc.Tools" Version="2.46.3" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
<PackageReference Include="MongoDB.Driver" Version="2.14.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/GossipBenchmark/Messages/Messages.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.21.0" />
<PackageReference Include="Grpc.Tools" Version="2.44.0-pre2" PrivateAssets="All" />
<PackageReference Include="Grpc.Tools" Version="2.46.3" PrivateAssets="All" />
<PackageReference Include="Proto.Cluster.CodeGen" Version="0.30.0" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageReference Include="Proto.Cluster.Identity.Redis" Version="0.26.0" />
<PackageReference Include="Proto.Cluster.Kubernetes" Version="0.26.0" />
<PackageReference Include="Proto.Cluster.Consul" Version="0.27.0" />
<PackageReference Include="Proto.Remote.GrpcNet" Version="0.26.0" />
<PackageReference Include="Proto.Remote.GrpcNet" Version="0.27.0" />
<PackageReference Include="StackExchange.Redis" Version="2.5.61" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/RemoteBenchmark/Messages/Messages.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.21.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="Grpc.Tools" Version="2.42.0" PrivateAssets="All" />
<PackageReference Include="Grpc.Tools" Version="2.46.3" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\src\Proto.Actor\Proto.Actor.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion examples/ActorMetrics/ActorMetrics.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Grpc.Tools" Version="2.42.0">
<PackageReference Include="Grpc.Tools" Version="2.46.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion examples/Chat/Messages/Chat.Messages.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Grpc.Tools" Version="2.42.0" PrivateAssets="All" />
<PackageReference Include="Grpc.Tools" Version="2.46.3" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\src\Proto.Actor\Proto.Actor.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion examples/ClusterGrainHelloWorld/Messages/Messages.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.21.0" />
<PackageReference Include="Grpc.Tools" Version="2.44.0-pre2" PrivateAssets="All" />
<PackageReference Include="Grpc.Tools" Version="2.46.3" PrivateAssets="All" />
<PackageReference Include="Proto.Cluster.CodeGen" Version="0.30.0" />
</ItemGroup>
<ItemGroup>
Expand Down
14 changes: 7 additions & 7 deletions examples/ClusterPubSub/ClusterPubSub.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Proto.Cluster.TestProvider\Proto.Cluster.TestProvider.csproj"/>
<ProjectReference Include="..\..\src\Proto.Cluster.TestProvider\Proto.Cluster.TestProvider.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.21.0"/>
<PackageReference Include="Grpc.Tools" Version="2.42.0">
<PackageReference Include="Google.Protobuf" Version="3.21.0" />
<PackageReference Include="Grpc.Tools" Version="2.46.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0"/>
<PackageReference Include="Proto.Cluster.CodeGen" Version="0.31.0"/>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
<PackageReference Include="Proto.Cluster.CodeGen" Version="0.31.0" />
</ItemGroup>

<ItemGroup>
<Protobuf Include="protos.proto" GrpcServices="none"/>
<ProtoGrain Include="protos.proto"/>
<Protobuf Include="protos.proto" GrpcServices="none" />
<ProtoGrain Include="protos.proto" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.21.0"/>
<PackageReference Include="Grpc.Tools" Version="2.42.0">
<PackageReference Include="Google.Protobuf" Version="3.21.0" />
<PackageReference Include="Grpc.Tools" Version="2.46.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0"/>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
<Protobuf Include="protos.proto" GrpcServices="none"/>
<Protobuf Include="protos.proto" GrpcServices="none" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Grpc.Tools" Version="2.42.0">
<PackageReference Include="Grpc.Tools" Version="2.46.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.21.0" />
<PackageReference Include="Grpc.Tools" Version="2.42.0">
<PackageReference Include="Grpc.Tools" Version="2.46.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion examples/Persistence/Messages/Messages.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.21.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="Grpc.Tools" Version="2.42.0" PrivateAssets="All" />
<PackageReference Include="Grpc.Tools" Version="2.46.3" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<Protobuf Include="Protos.proto" GrpcServices="Server,Client" />
Expand Down
7 changes: 7 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"sdk": {
"version": "6.0.0",
"rollForward": "latestMajor",
"allowPrerelease": true
}
}
30 changes: 17 additions & 13 deletions src/Proto.Actor/Process/ProcessRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Proto;

public class ProcessRegistry
{
private readonly List<Func<PID, Process>> _hostResolvers = new();
private readonly List<Func<PID, Process?>> _hostResolvers = new();
private readonly HashedConcurrentDictionary _localProcesses = new();
private int _sequenceId;

Expand Down Expand Up @@ -42,21 +42,25 @@ public Process Get(PID pid)
{
if (pid.Address == ActorSystem.NoHost || (pid.Address == System.Address && !pid.Id.StartsWith(ActorSystem.Client, StringComparison.Ordinal)))
{
if (_localProcesses.TryGetValue(pid.Id, out var process)) return process;
return System.DeadLetter;
}
else
{
Process? reff = null;
foreach (var resolver in _hostResolvers)
return _localProcesses.TryGetValue(pid.Id, out var process) switch
{
reff = resolver(pid);
if (reff != null) return reff;
}
true => process,
false => System.DeadLetter
};
}

if (reff is null) throw new NotSupportedException("Unknown host");
return reff;
Process? reff = null;
foreach (var resolver in _hostResolvers)
{
reff = resolver(pid);
if (reff != null) return reff;
}

return reff switch
{
null => throw new NotSupportedException("Unknown host"),
_ => reff
};
}

public (PID pid, bool ok) TryAdd(string id, Process process)
Expand Down
2 changes: 1 addition & 1 deletion src/Proto.Actor/Proto.Actor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.15.0" />
<PackageReference Include="Grpc.Tools" Version="2.42.0" PrivateAssets="All" />
<PackageReference Include="Grpc.Tools" Version="2.46.3" PrivateAssets="All" />
<PackageReference Include="IsExternalInit.System.Runtime.CompilerServices" Version="1.0.0" Condition="'$(TargetFramework)' == 'netstandard2.1'" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Roslynator.Analyzers" Version="4.0.2">
Expand Down
19 changes: 11 additions & 8 deletions src/Proto.Actor/Utils/TaskExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,19 @@ public static class TaskExtensions
{
public static async Task<TResult> WithTimeout<TResult>(this Task<TResult> task, TimeSpan timeout, CancellationToken? ct = null)
{
if (!task.IsCompleted)
{
using var timeoutCancellationTokenSource =
ct is not null ? CancellationTokenSource.CreateLinkedTokenSource(ct.Value) : new CancellationTokenSource();
if (task.IsCompleted) return await task.ConfigureAwait(false); // Very important in order to propagate exceptions

var completedTask = await Task.WhenAny(task, Task.Delay(timeout, timeoutCancellationTokenSource.Token)).ConfigureAwait(false);
if (completedTask != task) throw new TimeoutException("The operation has timed out.");
using var timeoutCancellationTokenSource =
ct switch
{
not null => CancellationTokenSource.CreateLinkedTokenSource(ct.Value),
_ => new CancellationTokenSource()
};

timeoutCancellationTokenSource.Cancel();
}
var completedTask = await Task.WhenAny(task, Task.Delay(timeout, timeoutCancellationTokenSource.Token)).ConfigureAwait(false);
if (completedTask != task) throw new TimeoutException("The operation has timed out.");

timeoutCancellationTokenSource.Cancel();

return await task.ConfigureAwait(false); // Very important in order to propagate exceptions
}
Expand Down
2 changes: 1 addition & 1 deletion src/Proto.Cluster/Proto.Cluster.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<TargetFrameworks>net5.0;net6.0;netcoreapp3.1</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Grpc.Tools" Version="2.42.0" PrivateAssets="All" />
<PackageReference Include="Grpc.Tools" Version="2.46.3" PrivateAssets="All" />
<PackageReference Include="Roslynator.Analyzers" Version="4.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
10 changes: 5 additions & 5 deletions src/Proto.Remote/Proto.Remote.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Grpc.AspNetCore" Version="2.43.0" />
<PackageReference Include="Grpc.Core.Api" Version="2.43.0" />
<PackageReference Include="Grpc.HealthCheck" Version="2.43.0" />
<PackageReference Include="Grpc.Net.Common" Version="2.43.0" />
<PackageReference Include="Grpc.Tools" Version="2.43.0" PrivateAssets="All" />
<PackageReference Include="Grpc.AspNetCore" Version="2.46.0" />
<PackageReference Include="Grpc.Core.Api" Version="2.46.3" />
<PackageReference Include="Grpc.HealthCheck" Version="2.46.3" />
<PackageReference Include="Grpc.Net.Common" Version="2.46.0" />
<PackageReference Include="Grpc.Tools" Version="2.46.3" PrivateAssets="All" />
<PackageReference Include="Roslynator.Analyzers" Version="4.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
2 changes: 1 addition & 1 deletion tests/Proto.Cluster.Tests/Proto.Cluster.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<ProjectReference Include="..\..\src\Proto.Remote\Proto.Remote.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Grpc.Tools" Version="2.44.0" PrivateAssets="All" />
<PackageReference Include="Grpc.Tools" Version="2.46.3" PrivateAssets="All" />
<PackageReference Include="IsExternalInit.System.Runtime.CompilerServices" Version="1.0.0" />
<PackageReference Include="OpenTelemetry.Exporter.Jaeger" Version="1.1.0" />
<PackageReference Include="Roslynator.Analyzers" Version="4.0.2">
Expand Down
3 changes: 2 additions & 1 deletion tests/Proto.Cluster.Tests/PubSubBatchingProducerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Threading;
using System.Threading.Tasks;
using FluentAssertions;
using FluentAssertions.Execution;
using Proto.Cluster.PubSub;
using Xunit;

Expand Down Expand Up @@ -105,7 +106,7 @@ public async Task Throws_when_queue_full()
sutAction.Should().Throw<ProducerQueueFullException>();
}

[Fact]
[Fact(Skip="Flaky")]
public async Task Can_cancel_publishing_a_message()
{
await using var producer =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Grpc.Tools" Version="2.43.0-pre1">
<PackageReference Include="Grpc.Tools" Version="2.46.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFrameworks>net5.0;netcoreapp3.1</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Grpc.Tools" Version="2.40.0" PrivateAssets="All" />
<PackageReference Include="Grpc.Tools" Version="2.46.3" PrivateAssets="All" />
<PackageReference Include="Roslynator.Analyzers" Version="4.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down