Skip to content

Commit

Permalink
Aot compatible (#1939)
Browse files Browse the repository at this point in the history
* make it aot compatible
  • Loading branch information
rogeralsing authored Feb 25, 2023
1 parent 527a4fc commit 52c07ea
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 20 deletions.
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 @@
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.21.12" />
<PackageReference Include="Google.Protobuf" Version="3.22.0" />
<PackageReference Include="Grpc.Tools" Version="2.51.0" PrivateAssets="All" />
<PackageReference Include="Proto.Cluster.CodeGen" Version="1.0.0-rc3.17" />
</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 @@ -4,7 +4,7 @@
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.21.12" />
<PackageReference Include="Google.Protobuf" Version="3.22.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="Grpc.Tools" Version="2.51.0" PrivateAssets="All" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion examples/AspNetGrains/Messages/Messages.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.21.12" />
<PackageReference Include="Google.Protobuf" Version="3.22.0" />
<PackageReference Include="Grpc.Tools" Version="2.51.0" PrivateAssets="All" />
<PackageReference Include="Proto.Cluster.CodeGen" Version="1.0.0-rc3.17" />
</ItemGroup>
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 @@ -4,7 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.21.12" />
<PackageReference Include="Google.Protobuf" Version="3.22.0" />
<PackageReference Include="Grpc.Tools" Version="2.51.0" PrivateAssets="All" />
<PackageReference Include="Proto.Cluster.CodeGen" Version="1.0.0-rc3.17" />
</ItemGroup>
Expand Down
10 changes: 6 additions & 4 deletions examples/ClusterGrainHelloWorld/Node1/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Proto;
using Proto.Cluster;
using Proto.Cluster.Partition;
using Proto.Cluster.PartitionActivator;
using Proto.Cluster.Seed;
using Proto.Remote;
using Proto.Remote.GrpcNet;
Expand All @@ -21,14 +22,14 @@
LoggerFactory.Create(l => l.AddConsole().SetMinimumLevel(LogLevel.Information)));

// Required to allow unencrypted GrpcNet connections
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
// AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);

var system = new ActorSystem()
.WithRemote(GrpcNetRemoteConfig.BindToLocalhost().WithProtoMessages(ProtosReflection.Descriptor))
.WithCluster(ClusterConfig
.Setup("MyCluster",
new SeedNodeClusterProvider(new SeedNodeClusterProviderOptions(("127.0.0.1", 8090))),
new PartitionIdentityLookup()));
SeedNodeClusterProvider.JoinSeedNode("127.0.0.1",8090),
new PartitionActivatorLookup()));

system.EventStream.Subscribe<ClusterTopology>(
e => { Console.WriteLine($"{DateTime.Now:O} My members {e.TopologyHash}"); }
Expand All @@ -40,9 +41,10 @@ await system

Console.WriteLine("Started");


var helloGrain = system.Cluster().GetHelloGrain("MyGrain");

var res = await helloGrain.SayHello(new HelloRequest(), FromSeconds(5));
var res = await helloGrain.SayHello(new HelloRequest(), FromSeconds(15));
Console.WriteLine(res.Message);

res = await helloGrain.SayHello(new HelloRequest(), FromSeconds(5));
Expand Down
2 changes: 1 addition & 1 deletion examples/ClusterGrainHelloWorld/Node2/Node2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<ServerGarbageCollection>true</ServerGarbageCollection>
<ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
<LangVersion>10</LangVersion>
<LangVersion>11</LangVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\src\Proto.Cluster\Proto.Cluster.csproj"/>
Expand Down
5 changes: 3 additions & 2 deletions examples/ClusterGrainHelloWorld/Node2/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Proto;
using Proto.Cluster;
using Proto.Cluster.Partition;
using Proto.Cluster.PartitionActivator;
using Proto.Cluster.Seed;
using Proto.Remote;
using Proto.Remote.GrpcNet;
Expand All @@ -21,12 +22,12 @@
LoggerFactory.Create(l => l.AddConsole().SetMinimumLevel(LogLevel.Information)));

// Required to allow unencrypted GrpcNet connections
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
// AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);

var system = new ActorSystem(new ActorSystemConfig().WithDeveloperSupervisionLogging(true))
.WithRemote(GrpcNetRemoteConfig.BindToLocalhost(8090).WithProtoMessages(ProtosReflection.Descriptor))
.WithCluster(ClusterConfig
.Setup("MyCluster", new SeedNodeClusterProvider(), new PartitionIdentityLookup())
.Setup("MyCluster", SeedNodeClusterProvider.StartSeedNode(), new PartitionActivatorLookup())
.WithClusterKind(
HelloGrainActor.GetClusterKind((ctx, identity) => new HelloGrain(ctx, identity.Identity)))
);
Expand Down
2 changes: 1 addition & 1 deletion examples/ClusterPubSub/ClusterPubSub.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</ItemGroup>

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

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

<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.21.12" />
<PackageReference Include="Google.Protobuf" Version="3.22.0" />
<PackageReference Include="Grpc.Tools" Version="2.51.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
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 @@ -3,7 +3,7 @@
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.21.12" />
<PackageReference Include="Google.Protobuf" Version="3.22.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="Grpc.Tools" Version="2.51.0" PrivateAssets="All" />
</ItemGroup>
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 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.21.12" />
<PackageReference Include="Google.Protobuf" Version="3.22.0" />
<PackageReference Include="Grpc.Tools" Version="2.51.0" 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" />
Expand Down
9 changes: 5 additions & 4 deletions src/Proto.Remote/Serialization/Serialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
using Google.Protobuf;
using Google.Protobuf.Reflection;
using Proto.Extensions;

using ActorMessages = Proto.ProtosReflection;
using RemoteMessages = Proto.Remote.ProtosReflection;
namespace Proto.Remote;

public class Serialization : IActorSystemExtension<Serialization>
Expand All @@ -31,14 +32,14 @@ internal readonly

public Serialization()
{
RegisterFileDescriptor(Proto.ProtosReflection.Descriptor);
RegisterFileDescriptor(ProtosReflection.Descriptor);
RegisterFileDescriptor(ActorMessages.Descriptor);
RegisterFileDescriptor(RemoteMessages.Descriptor);

RegisterSerializer(
SERIALIZER_ID_PROTOBUF,
0,
new ProtobufSerializer(this));

RegisterSerializer(
SERIALIZER_ID_JSON,
-1000,
Expand Down

0 comments on commit 52c07ea

Please sign in to comment.