未验证 提交 b7c32c09 编写于 作者: H Heejae Chang 提交者: GitHub

support feature flag service in IExperimentationService (#33964)

* support feature flag service in IExperimentationService

this will let us to create private ring of specific groups for new features until it is ready for bigger group.

once feature is ready for bigger group, this service can support VS experiment flight service which will let us to enable new features for bigger group.

once we are confident on the feature, we will enable it for general public

* remove extra blank line
上级 67cd7db8
......@@ -17,6 +17,7 @@ internal class VisualStudioExperimentationService : ForegroundThreadAffinitizedO
{
private readonly object _experimentationServiceOpt;
private readonly MethodInfo _isCachedFlightEnabledInfo;
private readonly IVsFeatureFlags _featureFlags;
[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
......@@ -25,11 +26,13 @@ public VisualStudioExperimentationService(IThreadingContext threadingContext, SV
{
object experimentationServiceOpt = null;
MethodInfo isCachedFlightEnabledInfo = null;
IVsFeatureFlags featureFlags = null;
threadingContext.JoinableTaskFactory.Run(async () =>
{
try
{
featureFlags = (IVsFeatureFlags)await ((IAsyncServiceProvider)serviceProvider).GetServiceAsync(typeof(SVsFeatureFlags)).ConfigureAwait(false);
experimentationServiceOpt = await ((IAsyncServiceProvider)serviceProvider).GetServiceAsync(typeof(SVsExperimentationService)).ConfigureAwait(false);
if (experimentationServiceOpt != null)
{
......@@ -42,6 +45,7 @@ public VisualStudioExperimentationService(IThreadingContext threadingContext, SV
}
});
_featureFlags = featureFlags;
_experimentationServiceOpt = experimentationServiceOpt;
_isCachedFlightEnabledInfo = isCachedFlightEnabledInfo;
}
......@@ -51,6 +55,20 @@ public bool IsExperimentEnabled(string experimentName)
ThisCanBeCalledOnAnyThread();
if (_isCachedFlightEnabledInfo != null)
{
try
{
var enabled = _featureFlags.IsFeatureEnabled(experimentName, defaultValue: false);
if (enabled)
{
return enabled;
}
}
catch
{
// featureFlags can throw if given name is in incorrect format which can happen for us
// since we use this for experimentation service as well
}
try
{
return (bool)_isCachedFlightEnabledInfo.Invoke(_experimentationServiceOpt, new object[] { experimentName });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册