예제 #1
0
        private void ConfigureCommonComponents(IMogglesLoggingService loggingService)
        {
            _featureToggleLoggingService = loggingService ?? new TelemetryClientService(_mogglesConfigurationManager);
            MogglesContainer.Register(_featureToggleLoggingService);

            _featureToggleProvider = new MogglesServerProvider(_featureToggleLoggingService, _mogglesConfigurationManager);
            MogglesContainer.Register(_featureToggleProvider);
        }
예제 #2
0
        private void ConfigureComponentsForMessaging()
        {
            _busService = CreateBusService();
            MogglesContainer.Register(_busService);

            _featureToggleEnvironmentDetector = new FeatureToggleEnvironmentDetector(_featureToggleLoggingService, _mogglesConfigurationManager, _busService);
            MogglesContainer.Register(_featureToggleEnvironmentDetector);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        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));
        }
예제 #7
0
        public static void ConfigureForTestingMode(IConfiguration configuration)
        {
            IMogglesConfigurationManager mogglesConfigurationManager = new NetCoreMogglesConfigurationManager(configuration);

            MogglesContainer.Register(mogglesConfigurationManager);
        }
예제 #8
0
        public static void ConfigureForTestingMode(IMogglesConfigurationManager configurationManager = null)
        {
            IMogglesConfigurationManager mogglesConfigurationManager = configurationManager ?? new NetFullMogglesConfigurationManager();

            MogglesContainer.Register(mogglesConfigurationManager);
        }