public TodoController(ILogger <TodoController> logger, ITodoServiceAsyncContext serviceContext, IConfiguration configuration, IWebHostEnvironment webHostEnvironment, IFeatureFlags featureFlags) { _configuration = configuration; _logger = logger; _serviceAgent = new TodoServiceAsyncAgent(serviceContext); _version = configuration["TodoControllerVersion"]; _environment = webHostEnvironment.EnvironmentName; _featureFlagsInUse = featureFlags; }
public FeatureFlags(IConfiguration configuration, ITodoServiceAsyncContext context) { _featureFlags = FeatureFlagsFactory.GetFeatureFlagsInUse(configuration, context); }
public static IEnumerable <FeatureFlagViewModel> GetFeatureFlagsInUse(IConfiguration configuration, ITodoServiceAsyncContext context) { if (null == LaunchDarklyCredentials) { InitializeFeatureFlagConfiguration(configuration); } // We can only activate feature flags when all pre-req features are active // If pre-req flags is empty, the flag is only implemented inside this servive var featurFlagsInUse = CloneFlags(_webuiSupportedFeatureFlags); IEnumerable <FeatureFlagViewModel> apiSupportedFeatureFlags = GetServiceSupportedFeatureFlags(context); //Validate pre req foreach (var apiFlag in featurFlagsInUse) { foreach (var dbFlag in apiFlag.PreReqKeys) { var preReq = apiSupportedFeatureFlags.SingleOrDefault(f => f.Key == dbFlag.Key); if (preReq != null) { dbFlag.State = preReq.State; } } } if (LaunchDarklyCredentials.LdClient != null) { foreach (var featureFlag in featurFlagsInUse) { featureFlag.State = LaunchDarklyCredentials.LdClient.BoolVariation(featureFlag.Key, LaunchDarklyCredentials.LdUser, false); } } return(featurFlagsInUse); }
private static IEnumerable <FeatureFlagViewModel> GetServiceSupportedFeatureFlags(ITodoServiceAsyncContext serviceAgent) { var task = Task.Run(() => serviceAgent.SupportedFeatureFlags()); var flags = (IEnumerable <Service.Models.FeatureFlagDTO>)task.GetType().GetProperty("Result").GetValue(task); IEnumerable <FeatureFlagViewModel> serviceSupportedFeatureFlags = flags.ToList().ConvertAll(new Converter <Service.Models.FeatureFlagDTO, FeatureFlagViewModel>(ViewModelFeatureFlagMapper.Map)); return(serviceSupportedFeatureFlags); }
public TodoServiceAsyncAgent(ITodoServiceAsyncContext context) { Context = context; }