public async Task Setup() { var echoProps = Props.FromFunc(ctx => { if (ctx.Sender is not null) { ctx.Respond(ctx.Message !); } return(Task.CompletedTask); } ); if (RequestDeduplication) { echoProps = echoProps.WithClusterRequestDeduplication(TimeSpan.FromSeconds(30)); } var echoKind = new ClusterKind(Kind, echoProps); if (LocalAffinity) { echoKind.WithLocalAffinityRelocationStrategy(); } var sys = new ActorSystem(new ActorSystemConfig()) .WithRemote(GrpcNetRemoteConfig.BindToLocalhost(9090)) .WithCluster(ClusterConfig().WithClusterKind(echoKind)); _cluster = sys.Cluster(); await _cluster.StartMemberAsync(); _id = ClusterIdentity.Create("1", Kind); await _cluster.RequestAsync <int>(_id.Identity, _id.Kind, 1, CancellationToken.None); }
public Fixture() { var clientConfig = ConfigureClientRemoteConfig(GrpcNetRemoteConfig.BindToLocalhost(5000)); (_clientHost, Remote) = GetHostedGrpcNetRemote(clientConfig); var serverConfig = ConfigureServerRemoteConfig(GrpcCoreRemoteConfig.BindToLocalhost(5001)); ServerRemote = GetGrpcCoreRemote(serverConfig); }
public Fixture() { var clientConfig = ConfigureClientRemoteConfig(GrpcNetRemoteConfig.BindToLocalhost()) .WithSerializer(serializerId: 2, priority: 1000, new CustomSerializer()); (_clientHost, Remote) = GetHostedGrpcNetRemote(clientConfig); var serverConfig = ConfigureServerRemoteConfig(GrpcNetRemoteConfig.BindToLocalhost()) .WithSerializer(serializerId: 2, priority: 1000, new CustomSerializer()); (_serverHost, ServerRemote) = GetHostedGrpcNetRemote(serverConfig); }
/// <summary> /// Configures the <see cref="ActorSystem"/> service in the <see cref="ServiceCollection"/>. /// </summary> /// <param name="builder">The <see cref="IHostBuilder"/>.</param> /// <returns>The builder for continuation.</returns> public static IHostBuilder AddActorSystem(this IHostBuilder builder) => builder.ConfigureServices(_ => _ .AddSingleton(provider => new ActorSystem(ActorSystemConfig.Setup()) .WithServiceProvider(provider) .WithRemote(GrpcNetRemoteConfig .BindToLocalhost() .WithProtoMessages(provider.GetRequiredService <IProtobufFileDescriptors>().All.ToArray())) .WithCluster(ClusterConfig.Setup( "Dolittle", new TestProvider(new TestProviderOptions(), new InMemAgent()), new PartitionIdentityLookup()) .WithDiscoveredClusterKinds(provider))) .AddSingleton(provider => provider.GetRequiredService <ActorSystem>().Root.WithTracing()) .AddSingleton(provider => provider.GetRequiredService <ActorSystem>().Cluster()));