private IServiceTopology LocateInner(string environmentName, string applicationName) { var currentEnvironmentName = environmentName; // Note(kungurtsev): not return null, if application was found in some skipped environment. IServiceTopology firstResolved = null; for (var depth = 0; depth < settings.MaximumEnvironmentsDepth; depth++) { var environment = environmentsStorage.Get(currentEnvironmentName); if (environment == null) { return(firstResolved); } var topology = applicationsStorage.Get(currentEnvironmentName, applicationName).ServiceTopology; firstResolved = firstResolved ?? topology; var parentEnvironment = environment.ParentEnvironment; if (parentEnvironment == null) { return(topology ?? firstResolved); } var goToParent = topology == null || topology.Replicas.Count == 0 && environment.SkipIfEmpty(); if (!goToParent) { return(topology); } currentEnvironmentName = parentEnvironment; } log.Warn("Cycled when resolving '{Application}' application in '{Environment}'.", applicationName, environmentName); return(firstResolved); }
private static void ShouldReturnImmediately(ApplicationsStorage storage, string environment, string application, ServiceTopology topology) { storage.Get(environment, application).ServiceTopology.Should().BeEquivalentTo(topology); }