public List <FeatureToggle> GetFeatureToggles() { using (var client = new HttpClient()) { SetRequestHeader(client); client.Timeout = _mogglesConfigurationManager.GetTimeoutValue(); string urlWithParams = GetUrlParams(); HttpResponseMessage response; string featureToggles; try { response = client.GetAsync(urlWithParams).Result; featureToggles = response.Content.ReadAsStringAsync().Result; } catch (AggregateException ex) { _featureToggleLoggingService.TrackException(ex, _mogglesConfigurationManager.GetApplicationName(), _mogglesConfigurationManager.GetEnvironment()); throw new MogglesClientException("An error occurred while getting the feature toggles from the server!"); } if (!response.IsSuccessStatusCode) { _featureToggleLoggingService.TrackException(new MogglesClientException("An error occurred while getting the feature toggles from the server!"), _mogglesConfigurationManager.GetApplicationName(), _mogglesConfigurationManager.GetEnvironment()); throw new MogglesClientException( "An error occurred while getting the feature toggles from the server!"); } return(JsonConvert.DeserializeObject <List <FeatureToggle> >(featureToggles)); } }
public void RegisterDeployedToggles() { var featureToggleNames = GetDeployedFeatureToggles(); var environment = _mogglesConfigurationManager.GetEnvironment(); var application = _mogglesConfigurationManager.GetApplicationName(); _busService.Publish(new RegisteredTogglesUpdate { AppName = application, Environment = environment, FeatureToggles = featureToggleNames }); }
public Task Consume(ConsumeContext <RefreshTogglesCache> context) { _featureToggleService = (MogglesToggleService)MogglesContainer.Resolve <MogglesToggleService>(); _featureToggleLoggingService = (IMogglesLoggingService)MogglesContainer.Resolve <IMogglesLoggingService>(); _mogglesConfigurationManager = (IMogglesConfigurationManager)MogglesContainer.Resolve <IMogglesConfigurationManager>(); var msg = context.Message; var currentApplication = _mogglesConfigurationManager.GetApplicationName(); var currentEnvironment = _mogglesConfigurationManager.GetEnvironment(); if (msg.ApplicationName.ToLowerInvariant() == currentApplication.ToLowerInvariant() && msg.Environment.ToLowerInvariant() == currentEnvironment.ToLowerInvariant()) { _featureToggleLoggingService.TrackEvent($"Handled cache refresh event for {msg.ApplicationName}/{msg.Environment}", currentApplication, currentEnvironment); _featureToggleService.CacheFeatureToggles(); } return(Task.FromResult(0)); }
public List <FeatureToggle> GetFeatureTogglesFromCache() { var featureToggles = _cache.GetFeatureTogglesFromCache(MogglesConfigurationKeys.FeatureTogglesCacheKey); if (FeatureTogglesExist(featureToggles)) { return(featureToggles); } var previouslyCachedFeatureToggles = _cache.GetFeatureTogglesFromCache(MogglesConfigurationKeys.PreviouslyCachedFeatureTogglesCacheKey); if (FeatureTogglesExist(previouslyCachedFeatureToggles)) { return(previouslyCachedFeatureToggles); } _featureToggleLoggingService.TrackException(new MogglesClientException("Feature toggles were not cached and previous values were not available!"), _mogglesConfigurationManager.GetApplicationName(), _mogglesConfigurationManager.GetEnvironment()); return(new List <FeatureToggle>()); }