Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
/ NuGet.Jobs Public archive

SubscriptionProcessor is now set up to use ScopedMessageHandler #473

Merged
merged 3 commits into from
Jul 3, 2018
Merged

Conversation

agr
Copy link
Contributor

@agr agr commented Jun 29, 2018

Addresses https://github.com/NuGet/Engineering/issues/1501 and https://github.com/NuGet/Engineering/issues/1486

No more copying the same DI setup for injecting the ScopedMessageHandler into SubscriptionProcessor in every job that derives from SubcriptionProcessorJob<T>, easy to forget to do that setup and the consequences are weird.

…fault, so that individual jobs don't have to do same setup over and over.

internal override void ConfigureAutofacServicesInternal(ContainerBuilder containerBuilder)
{
const string validateCertificateBindingKey = "SubscriptionProcessorJob_SubscriptionProcessorKey";
Copy link
Contributor

Choose a reason for hiding this comment

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

How about just 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.

Done

protected abstract void ConfigureJobServices(IServiceCollection services, IConfigurationRoot configurationRoot);
internal virtual void ConfigureAutofacServicesInternal(ContainerBuilder containerBuilder)
Copy link
Contributor

@loic-sharma loic-sharma Jun 29, 2018

Choose a reason for hiding this comment

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

No one except JsonConfigurationJob should call ConfigureAutofacServicesInternal, right? Instead of adding ConfigureAutofacServicesInternal, what do you think of calling base.ConfigureAutofacServices in all the jobs? The message handler could then be configured in that method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is even easier to forget to call base.ConfigureAutofacServices than to forget to set up the scope message handler. The idea was that it would work without any effort on the job side, and effort us required to opt out of the behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was rewritten so SubcriptionProcessorJob<T> now provides the ConfigureDefaultSubscriptionProcessor with default configuration and it is individual job's task to call it when needed. Checks are in place that suggest proper setup.

@@ -184,7 +185,12 @@ private void ConfigureLibraries(IServiceCollection services)
services.AddLogging();
}

protected abstract void ConfigureAutofacServices(ContainerBuilder containerBuilder);
protected virtual void ConfigureAutofacServices(ContainerBuilder containerBuilder)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add comments for the purpose of these two methods? Why is the internal one needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

… not configured in the DI, suggesting to use the default setup from `SubcriptionProcessorJob<T>`.

Update jobs code to include a call to that helper method.
@agr
Copy link
Contributor Author

agr commented Jul 3, 2018

Tested affected services in dev.

@agr agr merged commit 5dbe2c6 into dev Jul 3, 2018
@agr agr deleted the agr-scopes branch July 3, 2018 23:22
joelverhagen pushed a commit that referenced this pull request Sep 27, 2019
[ReleasePrep][2019.01.14] RI dev to master. Take 2
joelverhagen pushed a commit that referenced this pull request Oct 26, 2020
* SubscriptionProcessor is now set up to use ScopedMessageHandler by default, so that individual jobs don't have to do same setup over and over.

* Added specific check for the case when `ISubscriptionProcessor<T>` is not configured in the DI, suggesting to use the default setup from `SubcriptionProcessorJob<T>`.
Update jobs code to include a call to that helper method.
joelverhagen pushed a commit that referenced this pull request Oct 26, 2020
[ReleasePrep][2019.01.14] RI dev to master. Take 2
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants