public void StopTest() { //kill remote process if any Task.Factory.StartNew(Wmi.TerminateRemoteProcess); //cancel the current task CancellationTokens.CancelPerformanceCancellationTokenSource(); }
private static void Configure(AsyncGenerator configuration, CancellationTokens config, IFluentProjectCancellationTokenConfiguration fluentConfig) { if (config.Guards.HasValue) { fluentConfig.Guards(config.Guards.Value); } if (config.MethodParameter.Any()) { fluentConfig.ParameterGeneration(CreateParameterGenerationFunction(configuration, config.MethodParameter)); } if (config.WithoutCancellationToken.Any() || config.RequiresCancellationToken.Any()) { foreach (ExecutionPhase value in Enum.GetValues(typeof(ExecutionPhase))) { var withoutTokenGroup = config.WithoutCancellationToken.GroupBy(o => o.ExecutionPhase).FirstOrDefault(o => o.Key == value); var requiresTokenGroup = config.RequiresCancellationToken.GroupBy(o => o.ExecutionPhase).FirstOrDefault(o => o.Key == value); if (withoutTokenGroup != null || requiresTokenGroup != null) { fluentConfig.RequiresCancellationToken( CreateMethodNullablePredicate(configuration, withoutTokenGroup?.ToList() ?? new List <MethodFilter>(), requiresTokenGroup?.ToList() ?? new List <MethodFilter>() ), value); } } fluentConfig.RequiresCancellationToken(CreateMethodNullablePredicate(configuration, config.WithoutCancellationToken, config.RequiresCancellationToken)); } }
// Enumerates the children of a property. This provides support for dereferencing pointers, displaying members of an array, or fields of a class or struct. // The sample debugger only supports pointer dereferencing as children. This means there is only ever one child. public int EnumChildren(enum_DEBUGPROP_INFO_FLAGS dwFields, uint dwRadix, ref System.Guid guidFilter, enum_DBG_ATTRIB_FLAGS dwAttribFilter, string pszNameFilter, uint dwTimeout, out IEnumDebugPropertyInfo2 ppEnum) { ppEnum = null; try { var children = TaskHelpers.RunSynchronouslyOnUIThread(ct => { var timeoutToken = CancellationTokens.GetToken(TimeSpan.FromMilliseconds(dwTimeout)); var linkedSource = CancellationTokenSource.CreateLinkedTokenSource(ct, timeoutToken); return(_evalResult.GetChildrenAsync(linkedSource.Token)); }); if (children != null) { DEBUG_PROPERTY_INFO[] properties = new DEBUG_PROPERTY_INFO[children.Length]; for (int i = 0; i < children.Length; i++) { properties[i] = new AD7Property(_frame, children[i], true).ConstructDebugPropertyInfo(dwRadix, dwFields); } ppEnum = new AD7PropertyEnum(properties); return(VSConstants.S_OK); } return(VSConstants.S_FALSE); } catch (OperationCanceledException) { return(VSConstants.S_FALSE); } }
public void RunPerfTest() { CancellationTokens.ResetPerformanceCancellationToken(); CancellationTokens.GetPerformanceCancellationToken(); //run program on server Task.Factory.StartNew(Controller.RunTest); Controller.ShowRunningTestViewDialog(); }
/// <summary> /// Cancels the search matching the specified <paramref name="id"/>, if it is in progress. /// </summary> /// <param name="id">The unique identifier for the search.</param> /// <returns>A value indicating whether the search was sucessfully cancelled.</returns> public bool TryCancel(Guid id) { if (CancellationTokens.TryGetValue(id, out var cts)) { cts.Cancel(); return(true); } return(false); }
public async Task PublishBatch(ProducerBatchMessage batch) { //TODO: retries etc... await _cluster.RequestAsync <PublishResponse>(_topic, "topic", batch, CancellationTokens.FromSeconds(5)); foreach (var tcs in batch.DeliveryReports) { tcs.SetResult(true); } }
// The debugger will call this when the user tries to edit the property's values in one of the debugger windows. public int SetValueAsString(string pszValue, uint dwRadix, uint dwTimeout) { try { var result = TaskHelpers.RunSynchronouslyOnUIThread(async ct => { var timeoutToken = CancellationTokens.GetToken(TimeSpan.FromMilliseconds(dwTimeout)); var linkedSource = CancellationTokenSource.CreateLinkedTokenSource(ct, timeoutToken); return(await _evalResult.Frame.ExecuteTextAsync(_evalResult.Expression + " = " + pszValue, ct: linkedSource.Token)); }); return(VSConstants.S_OK); } catch (OperationCanceledException) { return(VSConstants.E_FAIL); } }
public Task RemoveMember(string memberId, CancellationToken ct) => _asyncSemaphore.WaitAsync(() => { Logger.LogInformation("[MongoIdentityStorage] RemoveMember"); if (ct.IsCancellationRequested) { Logger.LogInformation("[MongoIdentityStorage] RemoveMember, resetting cancellation token."); ct = CancellationTokens.WithTimeout(TimeSpan.FromSeconds(5)); } Logger.LogInformation("[MongoIdentityStorage] RemoveMember, Pid {MemberId}.", memberId); return(_pids.DeleteManyAsync(p => p.MemberId == memberId, ct)); });
public Task RemoveLock(SpawnLock spawnLock, CancellationToken ct) => _asyncSemaphore.WaitAsync(() => { Logger.LogInformation("[MongoIdentityStorage] DeleteManyAsync"); if (ct.IsCancellationRequested) { Logger.LogInformation("[MongoIdentityStorage] DeleteManyAsync, resetting cancellation token."); ct = CancellationTokens.WithTimeout(TimeSpan.FromSeconds(5)); } Logger.LogInformation("[MongoIdentityStorage] DeleteManyAsync, LockId {LockId}.", spawnLock.LockId); return(_pids.DeleteManyAsync(p => p.LockedBy == spawnLock.LockId, ct)); });
public async Task RemoveActivation(PID pid, CancellationToken ct) { Logger.LogDebug("Removing activation: {@PID}", pid); await _asyncSemaphore.WaitAsync(() => { Logger.LogInformation("[MongoIdentityStorage] RemoveActivation"); if (ct.IsCancellationRequested) { Logger.LogInformation("[MongoIdentityStorage] RemoveActivation, resetting cancellation token."); ct = CancellationTokens.WithTimeout(TimeSpan.FromSeconds(5)); } Logger.LogInformation("[MongoIdentityStorage] RemoveActivation, Pid {PidIs}.", pid.Id); return(_pids.DeleteManyAsync(p => p.UniqueIdentity == pid.Id, ct)); }); }
private static void Configure(AsyncGenerator configuration, CancellationTokens config, IFluentProjectCancellationTokenConfiguration fluentConfig) { if (config.Guards.HasValue) { fluentConfig.Guards(config.Guards.Value); } if (config.MethodParameter.Any()) { fluentConfig.ParameterGeneration(CreateParameterGenerationFunction(configuration, config.MethodParameter)); } if (config.WithoutCancellationToken.Any() || config.RequiresCancellationToken.Any()) { fluentConfig.RequiresCancellationToken(CreateMethodNullablePredicate(configuration, config.WithoutCancellationToken, config.RequiresCancellationToken)); } }
public async Task <PID?> GetAsync(ClusterIdentity clusterIdentity, CancellationToken ct) { ct = CancellationTokens.WithTimeout(_getPidTimeout); //Get address to node owning this ID var identityOwner = _partitionManager.Selector.GetIdentityOwner(clusterIdentity.Identity); Logger.LogDebug("Identity belongs to {address}", identityOwner); if (string.IsNullOrEmpty(identityOwner)) { return(null); } var remotePid = PartitionManager.RemotePartitionIdentityActor(identityOwner); var req = new ActivationRequest { ClusterIdentity = clusterIdentity }; Logger.LogDebug("Requesting remote PID from {Partition}:{Remote} {@Request}", identityOwner, remotePid, req ); try { var resp = await _cluster.System.Root.RequestAsync <ActivationResponse>(remotePid, req, ct); return(resp.Pid); } //TODO: decide if we throw or return null catch (DeadLetterException) { Logger.LogInformation("Remote PID request deadletter {@Request}, identity Owner {Owner}", req, identityOwner); return(null); } catch (TimeoutException) { Logger.LogInformation("Remote PID request timeout {@Request}, identity Owner {Owner}", req, identityOwner); return(null); } catch (Exception e) { Logger.LogError(e, "Error occured requesting remote PID {@Request}, identity Owner {Owner}", req, identityOwner); return(null); } }
public void ImportFromExternalRepositories(IList <int> externalRepositoryIds, int userId) { if (IsImportRunning) { throw new ImportRunningException(); } if (externalRepositoryIds == null || externalRepositoryIds.Count == 0) { throw new ArgumentNullException(nameof(externalRepositoryIds)); } ActualProgress.Clear(); CancellationTokens.Clear(); m_importList.Clear(); m_importList = externalRepositoryIds; UserId = userId; m_signal.Release(); }
public async Task CanWaitForActivation() { var activator = GetFakeActivator(); var timeout = CancellationTokens.WithTimeout(15 * 1000); var identity = new ClusterIdentity { Kind = "thing", Identity = NextId().ToString() }; var spawnLock = await _storage.TryAcquireLock(identity, timeout); var pid = Activate(activator, identity); _ = SafeTask.Run(async() => { await Task.Delay(500, timeout); await _storage.StoreActivation(activator.Id, spawnLock !, pid, timeout); }, timeout ); var activation = await _storage.WaitForActivation(identity, timeout); activation.Should().NotBeNull(); activation !.MemberId.Should().Be(activator.Id); activation !.Pid.Should().BeEquivalentTo(pid); }
private static async Task RunKafkaConsumeLoop(Cluster cluster) { while (true) { var sw = Stopwatch.StartNew(); //get the messages from Kafka or other log/queue var messages = GetBatchFromKafka(); var tasks = new List <Task>(); //forward each message to their actors foreach (var message in messages) { object m = message.MessageCase switch { MyEnvelope.MessageOneofCase.SomeMessage => message.SomeMessage, MyEnvelope.MessageOneofCase.SomeOtherMessage => message.SomeOtherMessage, _ => throw new ArgumentOutOfRangeException(nameof(message), "Unknown message case") }; var task = cluster .RequestAsync <Ack>(message.DeviceId, "device", m, CancellationTokens.WithTimeout(5000)); tasks.Add(task); } //await response form all actors await Task.WhenAll(tasks); //TODO: commit back to Kafka that all messages succeeded sw.Stop(); var tps = 1000.0 / sw.Elapsed.TotalMilliseconds * tasks.Count; //show throughput, messages per second Console.WriteLine(tps.ToString("n0")); } }
/// <summary> /// Performs a search for the specified <paramref name="query"/> and <paramref name="scope"/>. /// </summary> /// <param name="id">A unique identifier for the search.</param> /// <param name="query">The search query.</param> /// <param name="scope">The search scope.</param> /// <param name="options">Search options.</param> /// <returns>The completed search.</returns> public async Task <Search> StartAsync(Guid id, SearchQuery query, SearchScope scope, SearchOptions options = null) { var token = Client.GetNextToken(); var cancellationTokenSource = new CancellationTokenSource(); CancellationTokens.TryAdd(id, cancellationTokenSource); var rateLimiter = new RateLimiter(250); var search = new Search() { SearchText = query.SearchText, Token = token, Id = id, State = SearchStates.Requested, StartedAt = DateTime.UtcNow, }; using var context = ContextFactory.CreateDbContext(); context.Add(search); List <SearchResponse> responses = new(); async Task UpdateAndSaveChangesAsync(Search search) { using var context = ContextFactory.CreateDbContext(); context.Update(search); await context.SaveChangesAsync(); } options ??= new SearchOptions(); options = options.WithActions( stateChanged: (args) => { search = search.WithSoulseekSearch(args.Search); SearchHub.BroadcastUpdateAsync(search); _ = UpdateAndSaveChangesAsync(search); }, responseReceived: (args) => rateLimiter.Invoke(() => { // note: this is rate limited, but has the potential to update the database every 250ms (or whatever the // interval is set to) for the duration of the search. any issues with disk i/o or performance while searches // are running should investigate this as a cause search.ResponseCount = args.Search.ResponseCount; search.FileCount = args.Search.FileCount; search.LockedFileCount = args.Search.LockedFileCount; SearchHub.BroadcastUpdateAsync(search); _ = UpdateAndSaveChangesAsync(search); })); var soulseekSearchTask = Client.SearchAsync( query, responseReceived: (response) => responses.Add(response), scope, token, options, cancellationToken: cancellationTokenSource.Token); _ = Task.Run(async() => { try { var soulseekSearch = await soulseekSearchTask; search = search.WithSoulseekSearch(soulseekSearch); } finally { rateLimiter.Dispose(); CancellationTokens.TryRemove(id, out _); try { search.EndedAt = DateTime.UtcNow; search.Responses = responses.Select(r => Response.FromSoulseekSearchResponse(r)); await UpdateAndSaveChangesAsync(search); // zero responses before broadcasting search.Responses = Enumerable.Empty <Response>(); await SearchHub.BroadcastUpdateAsync(search); } catch (Exception ex) { Log.Error(ex, "Failed to persist search for {SearchQuery} ({Id})", query, id); } } }); await context.SaveChangesAsync(); await SearchHub.BroadcastCreateAsync(search); return(search); }
public static void RunTest() { CancellationTokens.ResetPerformanceCancellationToken(); CancellationTokens.GetPerformanceCancellationToken(); Test.MethodLevelResults = new ConcurrentDictionary <string, MethodLogs>(); Test.MethodLevelReqStatus = new ConcurrentDictionary <string, MethodLogs>(); Test.ClearCache(); Test.PerformanceRunToken = CancellationTokens.GetPerformanceCancellationToken(); if (!string.IsNullOrEmpty(Test.TestPackage.ResultFileName)) { if (File.Exists(Test.TestPackage.ResultFileName)) { File.Delete(Test.TestPackage.ResultFileName); } } int scenariosCount = Test.TestPackage.Scenarios.Count; int duration = Test.TestPackage.Duration; int clients = Test.TestPackage.Clients; Stopwatch testDurationTimer = new Stopwatch(); testDurationTimer.Start(); int requestSent = 0; int delayRangeStart = Test.TestPackage.DelayRangeStart; int delayRangeEnd = Test.TestPackage.DelayRangeEnd; int clientsSpawned = 0; Task[] clientTasks = new Task[clients]; while (clientsSpawned < clients) { int clientIndex = clientsSpawned; clientTasks[clientIndex] = new Task(() => { int currentScenario = -1; int currentScenarioOrder = -1; while (testDurationTimer.ElapsedMilliseconds <= (duration * 60 * 1000) && !CancellationTokens.GetPerformanceCancellationToken().IsCancellationRequested) { if (scenariosCount == 0) { Random r = new Random(); bool executeWcf = r.Next(0, 1000) % 2 == 0; if (Test.TestPackage.Suites.Count == 0) { executeWcf = false; } if (executeWcf || Test.TestPackage.RestMethods.Count == 0) { int suiteNumberToExecute = r.Next(0, Test.TestPackage.Suites.Count - 1); int testNumberToExecute = r.Next(0, Test.TestPackage.Suites[suiteNumberToExecute].Tests.Count - 1); Common.Test testToExecute = Test.TestPackage.Suites[suiteNumberToExecute].Tests[testNumberToExecute]; Test.InvokeTest(testToExecute, Test.TestPackage.Suites[suiteNumberToExecute].Guid); requestSent++; } else { int suiteNumberToExecute = r.Next(0, Test.TestPackage.RestMethods.Count - 1); Task.Factory.StartNew(() => { Test.InvokeRestApi( Test.TestPackage.RestMethods[suiteNumberToExecute], true); }); requestSent++; } Thread.Sleep(r.Next(delayRangeStart, delayRangeEnd)); } else { if (currentScenario == -1) { Random r = new Random(); currentScenario = r.Next(0, scenariosCount - 1); } var scen = Test.TestPackage.Scenarios[currentScenario]; if (currentScenarioOrder == -1) { currentScenarioOrder = 0; } var order = currentScenarioOrder; var ss = (from s in scen.ScenarioOrder where s.Order == order select s).First(); int totalMethodsInScenario = scen.ScenarioOrder.Count; if (!ss.IsRest) { var methodName = ss.MethodName; var tts = from suite in Test.TestPackage.Suites from tt in suite.Tests where tt.Service.MethodName == methodName && ss.AssemblyGuid == suite.Guid select tt; Common.Test testToExecute = tts.ElementAt(0); var valueToUse = (from v in testToExecute.Service.Values.ValueList where v.Guid == ss.MethodGuid select v).First(); Test.InvokeTest(testToExecute, ss.AssemblyGuid, valueToUse); } else { Task.Factory.StartNew(() => { Test.InvokeRestApi( Test.TestPackage.RestMethods.Find(r => r.Guid == ss.MethodGuid), true); }); } requestSent++; Random r1 = new Random(); Thread.Sleep(r1.Next(delayRangeStart, delayRangeEnd)); currentScenarioOrder = currentScenarioOrder + 1; if (totalMethodsInScenario == currentScenarioOrder) { currentScenarioOrder = -1; currentScenario = -1; Thread.Sleep(Test.TestPackage.IntervalBetweenScenarios); } } } }, CancellationTokens.GetPerformanceCancellationToken()); clientTasks[clientIndex].Start(); clientsSpawned++; } try { Task.WaitAll(clientTasks); SpinWait.SpinUntil(() => (requestSent == Test.TotalResponsesRecieved), 60000); } catch (AggregateException ae) { Logger.LogMessage("Aggregaate Exception Occured : " + ae.Message); foreach (Exception ex in ae.InnerExceptions) { Logger.LogMessage(string.Format("Aggregate exception : {0} {1} {2}", ex.Message, Environment.NewLine, ex.StackTrace)); } } }
public void DumpState(ClusterIdentity clusterIdentity) { Console.WriteLine("Memberlist members:"); _cluster.MemberList.DumpState(); Console.WriteLine("Partition manager selector:"); _partitionManager.Selector.DumpState(); //Get address to node owning this ID var identityOwner = _partitionManager.Selector.GetIdentityOwner(clusterIdentity.Identity); Console.WriteLine("Identity owner for ID:"); Console.WriteLine(identityOwner); var remotePid = PartitionManager.RemotePartitionIdentityActor(identityOwner); var req = new ActivationRequest { ClusterIdentity = clusterIdentity }; var resp = _cluster.System.Root.RequestAsync <ActivationResponse>(remotePid, req, CancellationTokens.WithTimeout(5000)).Result; Console.WriteLine("Target Pid:"); if (resp == null) { Console.WriteLine("Null response"); } else if (resp.Pid == null) { Console.WriteLine("Null PID"); } else { Console.WriteLine(resp.Pid); } }
public void CancelTask(int externalRepositoryId) { CancellationTokens.TryGetValue(externalRepositoryId, out var tokenSource); tokenSource?.Cancel(); }
/// <summary> /// Runs performance test /// </summary> public static void RunTest() { WCFLoad.Test.MethodLevelResults = new ConcurrentDictionary <string, MethodLogs>(); WCFLoad.Test.MethodLevelReqStatus = new ConcurrentDictionary <string, MethodLogs>(); WCFLoad.Test.ClearCache(); //Reset total clients ApplicationData.TotalClientsStarted = 0; IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName()); IPAddress ipAddress = ipHostInfo.AddressList[0]; FbHelper.SetInitialValues(ipAddress.ToString(), true, Environment.CurrentDirectory + "\\firebird_filesmydb.fdb"); FbHelper.CreateDataBase(); FbServiceController.StartService(); CreateClients(); ServiceClient.ServerIpAddress = "localhost"; ServiceClient.ServerPort = "9090"; WCFLoad.Test.PerformanceRunToken = CancellationTokens.GetPerformanceCancellationToken(); if (!string.IsNullOrEmpty(WCFLoad.Test.TestPackage.ResultFileName)) { if (File.Exists(WCFLoad.Test.TestPackage.ResultFileName)) { File.Delete(WCFLoad.Test.TestPackage.ResultFileName); } } IsTestCompleted = false; int scenariosCount = WCFLoad.Test.TestPackage.Scenarios.Count; int duration = WCFLoad.Test.TestPackage.Duration; int clients = WCFLoad.Test.TestPackage.Clients; if (WCFLoad.Test.TestPackage.Nodes.NodeList.Count > 0) { clients = WCFLoad.Test.TestPackage.Clients / WCFLoad.Test.TestPackage.Nodes.NodeList.Count; } Stopwatch testDurationTimer = new Stopwatch(); testDurationTimer.Start(); int requestSent = 0; int delayRangeStart = WCFLoad.Test.TestPackage.DelayRangeStart; int delayRangeEnd = WCFLoad.Test.TestPackage.DelayRangeEnd; int clientsSpawned = 0; Task[] clientTasks = new Task[clients]; while (clientsSpawned < clients) { int clientIndex = clientsSpawned; clientTasks[clientIndex] = new Task(() => { int currentScenario = -1; int currentScenarioOrder = -1; while (testDurationTimer.ElapsedMilliseconds <= (duration * 60 * 1000) && !CancellationTokens.GetPerformanceCancellationToken().IsCancellationRequested) { if (scenariosCount == 0) { Random r = new Random(); bool executeWcf = r.Next(0, 1000) % 2 == 0; if (WCFLoad.Test.TestPackage.Suites.Count == 0) { executeWcf = false; } if (executeWcf || WCFLoad.Test.TestPackage.RestMethods.Count == 0) { int suiteNumberToExecute = r.Next(0, WCFLoad.Test.TestPackage.Suites.Count - 1); int testNumberToExecute = r.Next(0, WCFLoad.Test.TestPackage.Suites[suiteNumberToExecute].Tests.Count - 1); var testToExecute = WCFLoad.Test.TestPackage.Suites[suiteNumberToExecute].Tests[testNumberToExecute]; WCFLoad.Test.InvokeTest(testToExecute, WCFLoad.Test.TestPackage.Suites[suiteNumberToExecute].Guid); requestSent++; } else { int suiteNumberToExecute = r.Next(0, WCFLoad.Test.TestPackage.RestMethods.Count - 1); Task.Factory.StartNew(() => { WCFLoad.Test.InvokeRestApi( WCFLoad.Test.TestPackage.RestMethods[suiteNumberToExecute], true); }); } requestSent++; Thread.Sleep(r.Next(delayRangeStart, delayRangeEnd)); } else { if (currentScenario == -1) { Random r = new Random(); currentScenario = r.Next(0, scenariosCount - 1); } var scen = WCFLoad.Test.TestPackage.Scenarios[currentScenario]; if (currentScenarioOrder == -1) { currentScenarioOrder = 0; } var order = currentScenarioOrder; var ss = (from s in scen.ScenarioOrder where s.Order == order select s).First(); int totalMethodsInScenario = scen.ScenarioOrder.Count; if (!ss.IsRest) { var methodName = ss.MethodName; var tts = from suite in WCFLoad.Test.TestPackage.Suites from tt in suite.Tests where tt.Service.MethodName == methodName && ss.AssemblyGuid == suite.Guid select tt; Test testToExecute = tts.ElementAt(0); var valueToUse = (from v in testToExecute.Service.Values.ValueList where v.Guid == ss.MethodGuid select v).First(); WCFLoad.Test.InvokeTest(testToExecute, ss.AssemblyGuid, valueToUse); } else { Task.Factory.StartNew(() => { WCFLoad.Test.InvokeRestApi( WCFLoad.Test.TestPackage.RestMethods.Find(r => r.Guid == ss.MethodGuid), true); }); } requestSent++; Random r1 = new Random(); Thread.Sleep(r1.Next(delayRangeStart, delayRangeEnd)); currentScenarioOrder = currentScenarioOrder + 1; if (totalMethodsInScenario == currentScenarioOrder) { currentScenarioOrder = -1; currentScenario = -1; Thread.Sleep(WCFLoad.Test.TestPackage.IntervalBetweenScenarios); } } } }, CancellationTokens.GetPerformanceCancellationToken()); clientTasks[clientIndex].Start(); clientsSpawned++; } try { //Wait for all client threads to complete Task.WaitAll(clientTasks); SpinWait.SpinUntil(() => (requestSent == WCFLoad.Test.TotalResponsesRecieved), 60000); } catch (AggregateException ae) { Logger.LogMessage("Aggregaate Exception Occured : " + ae.Message); foreach (Exception ex in ae.InnerExceptions) { Logger.LogMessage(string.Format("Aggregate exception : {0} {1} {2}", ex.Message, Environment.NewLine, ex.StackTrace)); } } IsTestCompleted = true; WCFLoad.Test.CallRunResultUpdatedEvent(); FbServiceController.StopService(); }
public static void Run() { var l = LoggerFactory.Create(x => x.AddConsole().SetMinimumLevel(LogLevel.Information)); Log.SetLoggerFactory(l); var config = ActorSystemConfig.Setup().WithMetricsProviders(new PrometheusConfigurator()); var remoteConfig = GrpcCoreRemoteConfig .BindToLocalhost() .WithProtoMessages(MessagesReflection.Descriptor); var clusterConfig = ClusterConfig .Setup("MyCluster", new ConsulProvider(new ConsulProviderConfig(), c => c.Address = new Uri("http://127.0.0.1:8500/")), new PartitionIdentityLookup() ); var system = new ActorSystem(config) .WithRemote(remoteConfig) .WithCluster(clusterConfig); system .Cluster() .StartMemberAsync(); var props = Props.FromProducer(() => new MyActor()); var config2 = ActorSystemConfig.Setup().WithMetricsProviders(new PrometheusConfigurator()); var remoteConfig2 = GrpcCoreRemoteConfig .BindToLocalhost() .WithProtoMessages(MessagesReflection.Descriptor); var clusterConfig2 = ClusterConfig .Setup("MyCluster", new ConsulProvider(new ConsulProviderConfig(), c => c.Address = new Uri("http://127.0.0.1:8500/")), new PartitionIdentityLookup() ) .WithClusterKind("somekind", props); var system2 = new ActorSystem(config2) .WithRemote(remoteConfig2) .WithCluster(clusterConfig2); system2 .Cluster() .StartMemberAsync(); _ = SafeTask.Run(async() => { var r = new Random(); while (true) { await Task.Delay(r.Next(1, 2000)); await system.Cluster().RequestAsync <SomeResponse>($"someactor{r.Next(1, 100)}", "somekind", new SomeRequest(), CancellationTokens.WithTimeout(5000) ); } } ); }