private void ConfigureCommonComponents(IMogglesLoggingService loggingService) { _featureToggleLoggingService = loggingService ?? new TelemetryClientService(_mogglesConfigurationManager); MogglesContainer.Register(_featureToggleLoggingService); _featureToggleProvider = new MogglesServerProvider(_featureToggleLoggingService, _mogglesConfigurationManager); MogglesContainer.Register(_featureToggleProvider); }
private void ConfigureComponentsForMessaging() { _busService = CreateBusService(); MogglesContainer.Register(_busService); _featureToggleEnvironmentDetector = new FeatureToggleEnvironmentDetector(_featureToggleLoggingService, _mogglesConfigurationManager, _busService); MogglesContainer.Register(_featureToggleEnvironmentDetector); }
private void RegisterComponentsForNetCore(IConfiguration configuration, IMogglesLoggingService loggingService) { _mogglesConfigurationManager = new NetCoreMogglesConfigurationManager(configuration); MogglesContainer.Register(_mogglesConfigurationManager); ConfigureCommonComponents(loggingService); var cache = new NetCoreCache(); _featureToggleService = new MogglesToggleService(cache, _featureToggleProvider, _featureToggleLoggingService, _mogglesConfigurationManager); MogglesContainer.Register(_featureToggleService); }
public static Moggles ConfigureAndStartClient(IConfiguration configuration, IMogglesLoggingService loggingService = null) { lock (Padlock) { var instance = (Moggles)MogglesContainer.Resolve <Moggles>(); if (instance == null) { instance = new Moggles(configuration, loggingService); MogglesContainer.Register(instance); } return(instance); } }
private bool IsFeatureToggleEnabled() { var featureToggleService = (MogglesToggleService)MogglesContainer.Resolve <MogglesToggleService>(); var configurationManager = (IMogglesConfigurationManager)MogglesContainer.Resolve <IMogglesConfigurationManager>(); if (configurationManager.IsApplicationInTestingMode()) { return(configurationManager.GetFeatureToggleValueFromConfig(_name)); } var featureToggleValue = featureToggleService.GetFeatureTogglesFromCache() ?.FirstOrDefault(x => x.FeatureToggleName == _name); return(featureToggleValue?.IsEnabled ?? false); }
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 static void ConfigureForTestingMode(IConfiguration configuration) { IMogglesConfigurationManager mogglesConfigurationManager = new NetCoreMogglesConfigurationManager(configuration); MogglesContainer.Register(mogglesConfigurationManager); }
public static void ConfigureForTestingMode(IMogglesConfigurationManager configurationManager = null) { IMogglesConfigurationManager mogglesConfigurationManager = configurationManager ?? new NetFullMogglesConfigurationManager(); MogglesContainer.Register(mogglesConfigurationManager); }