Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Statistics]Adding Support for other reports from alternate container #8472

Merged
merged 1 commit into from
Apr 1, 2021

Conversation

ryuyu
Copy link
Contributor

@ryuyu ryuyu commented Mar 30, 2021

Adds support for sourcing other reports from the alternate stats container.
Currently, feature flagging is all-or-nothing.

@@ -707,27 +707,41 @@ private static void RegisterDeleteAccountService(ContainerBuilder builder, Confi

private static void RegisterStatisticsServices(ContainerBuilder builder, IGalleryConfigurationService configuration, ITelemetryService telemetryService)
{
// when running on Windows Azure, download counts come from the downloads.v1.json blob
Copy link
Contributor

@zhhyu zhhyu Mar 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment here looks a little confused, is it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment was around this block when i initially made code changes. I'm not sure where it went, but it's back here. I imagine this was originally here to note the difference from running locally, where stats come from DB.

_readAccessGeoRedundant = readAccessGeoRedundant;
_featureFlagService = featureFlagService ?? throw new ArgumentNullException(nameof(featureFlagService));
_primaryStorageConfiguration = primaryBlobStorageConfiguration ?? throw new ArgumentNullException(nameof(primaryBlobStorageConfiguration));
_alternateBlobStorageConfiguration = alternateBlobStorageConfiguration;
Copy link
Contributor

@zhhyu zhhyu Mar 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it be better if we also do the null check here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did no null check intentionally to not force alternate blob storage configuration to have to be set so that it works in place with current config.

_readAccessGeoRedundant = readAccessGeoRedundant;
_featureFlagService = featureFlagService ?? throw new ArgumentNullException(nameof(featureFlagService));
_primaryStorageConfiguration = primaryBlobStorageConfiguration ?? throw new ArgumentNullException(nameof(primaryBlobStorageConfiguration));
_alternateBlobStorageConfiguration = alternateBlobStorageConfiguration;
Copy link
Contributor

@zhhyu zhhyu Mar 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it be better if we also do the null check here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did no null check intentionally to not force alternate blob storage configuration to have to be set so that it works in place with current config.

builder.RegisterInstance(new JsonAggregateStatsService(configuration.Current.AzureStorage_Statistics_ConnectionString, configuration.Current.AzureStorageReadAccessGeoRedundant))
builder.Register(c =>
{
var primaryConfiguration = c.ResolveKeyed<IBlobStorageConfiguration>(BindingKeys.PrimaryStatisticsKey);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

primaryConfiguration [](start = 20, length = 20)

What do you think about using attributes for resolving keyed dependencies: https://autofaccn.readthedocs.io/en/latest/advanced/keyed-services.html#resolving-with-attributes ?
We might be able to eliminate the creation of JsonAggregateStatsService class here and simply register it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it could be good idea, and might make this block a bit easier to read. I'll experiment with it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we typically use WithParameter for this:

.WithParameter(new ResolvedParameter(
(pi, ctx) => pi.ParameterType.IsAssignableFrom(typeof(IFileStorageService)),
(pi, ctx) => ctx.ResolveKeyed<IFileStorageService>(dependent.BindingKey)))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having a little trouble getting this to work right now. I've filed #8477 to make this change after things are in place (if I am understanding this correctly, we should be able to make this change independent of the overall functionality.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, we have two arguments of type IBlobStorageConfiguration here, so it won't work directly.

var featureFlagService = c.Resolve<IFeatureFlagService>();
var jsonAggregateStatsService = new JsonAggregateStatsService(featureFlagService, primaryConfiguration, alternateConfiguration);
return jsonAggregateStatsService;
})
.AsSelf()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need all those .AsSelf()? Does any service directly depend on JsonAggregateStatsService?

@ryuyu ryuyu merged commit 91c68fe into dev Apr 1, 2021
@ryuyu ryuyu mentioned this pull request Apr 8, 2021
9 tasks
@ryuyu ryuyu deleted the ryuyu-enable-altCloudReport-fixed branch March 16, 2024 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants