private async ValueTask TopicReChecker() { try { var ask = await _lookup.Ask <AskResponse>(new GetTopicsUnderNamespace(NamespaceName, _subscriptionMode)).ConfigureAwait(false); var response = ask.ConvertTo <GetTopicsUnderNamespaceResponse>(); var topicsFound = response.Topics; var topics = _context.GetChildren().ToList(); if (_log.IsDebugEnabled) { _log.Debug($"Get topics under namespace {NamespaceName}, topics.size: {topics.Count}"); TopicsMap.ForEach(t => _log.Debug($"Get topics under namespace {NamespaceName}, topic: {t.Key}")); } var newTopics = TopicsPatternFilter(topicsFound, _topicsPattern); var oldTopics = Topics; OnTopicsAdded(TopicsListsMinus(newTopics, oldTopics)); OnTopicsRemoved(TopicsListsMinus(oldTopics, newTopics)); } catch (Exception ex) { _log.Error(ex.ToString()); } finally { _recheckPatternTimeout = _context.System.Scheduler.Advanced.ScheduleOnceCancelable(TimeSpan.FromSeconds(Math.Max(1, Conf.PatternAutoDiscoveryPeriod)), async() => { await TopicReChecker(); }); } if (_recheckPatternTimeout.IsCancellationRequested) { return; } }
public Task <Done> HostShutdown() { _log.Info("Shutdown All Host Apps"); return(Task.WhenAll(_context .GetChildren() .Select(ar => ar.Ask <StopResponse>(new InternalStopApp(), TimeSpan.FromMinutes(2))) .ToArray()).ContinueWith(_ => Done.Instance)); }