1313using NuGet . Jobs ;
1414using NuGet . Jobs . Configuration ;
1515using NuGet . Jobs . Validation ;
16+ using NuGet . Services . Logging ;
17+ using NuGet . Services . ServiceBus ;
18+ using NuGet . Services . Validation ;
1619using NuGetGallery ;
1720
1821namespace NuGet . Services . Revalidate
@@ -26,6 +29,8 @@ public class Job : JsonConfigurationJob
2629 private const string VerifyInitializationArgumentName = "VerifyInitialization" ;
2730 private const string JobConfigurationSectionName = "RevalidateJob" ;
2831
32+ private static readonly TimeSpan RetryLaterSleepDuration = TimeSpan . FromMinutes ( 5 ) ;
33+
2934 private bool _initialize ;
3035 private bool _verifyInitialization ;
3136
@@ -75,17 +80,23 @@ public override async Task Run()
7580 }
7681 else
7782 {
78- // TODO: https://github.com/NuGet/Engineering/issues/1443
79- // Send revalidation requests to the Orchestrator.
80- throw new NotImplementedException ( ) ;
83+ Logger . LogInformation ( "Running the revalidation service..." ) ;
84+
85+ await scope . ServiceProvider
86+ . GetRequiredService < IRevalidationService > ( )
87+ . RunAsync ( ) ;
88+
89+ Logger . LogInformation ( "Revalidation service finished running" ) ;
8190 }
8291 }
8392 }
8493
8594 protected override void ConfigureJobServices ( IServiceCollection services , IConfigurationRoot configurationRoot )
8695 {
8796 services . Configure < RevalidationConfiguration > ( configurationRoot . GetSection ( JobConfigurationSectionName ) ) ;
97+ services . AddSingleton ( provider => provider . GetRequiredService < IOptionsSnapshot < RevalidationConfiguration > > ( ) . Value ) ;
8898 services . AddSingleton ( provider => provider . GetRequiredService < IOptionsSnapshot < RevalidationConfiguration > > ( ) . Value . Initialization ) ;
99+ services . AddSingleton ( provider => provider . GetRequiredService < IOptionsSnapshot < RevalidationConfiguration > > ( ) . Value . Queue ) ;
89100
90101 services . AddScoped < IGalleryContext > ( provider =>
91102 {
@@ -94,9 +105,31 @@ protected override void ConfigureJobServices(IServiceCollection services, IConfi
94105 return new GalleryContext ( config . ConnectionString , readOnly : false ) ;
95106 } ) ;
96107
97- services . AddScoped < IRevalidationStateService , RevalidationStateService > ( ) ;
98- services . AddScoped < IPackageFinder , PackageFinder > ( ) ;
99- services . AddScoped < InitializationManager > ( ) ;
108+ // Core
109+ services . AddTransient < ITelemetryService , TelemetryService > ( ) ;
110+ services . AddTransient < ITelemetryClient , TelemetryClientWrapper > ( ) ;
111+
112+ services . AddTransient < IRevalidationStateService , RevalidationStateService > ( ) ;
113+
114+ // Initialization
115+ services . AddTransient < IPackageFinder , PackageFinder > ( ) ;
116+ services . AddTransient < InitializationManager > ( ) ;
117+
118+ // Revalidation
119+ services . AddTransient < IHealthService , HealthService > ( ) ;
120+ services . AddTransient < IRevalidationQueue , RevalidationQueue > ( ) ;
121+ services . AddTransient < IRevalidationService , RevalidationService > ( ) ;
122+ services . AddTransient < IRevalidationThrottler , RevalidationThrottler > ( ) ;
123+ services . AddTransient < ISingletonService , SingletonService > ( ) ;
124+
125+ services . AddTransient < IPackageValidationEnqueuer , PackageValidationEnqueuer > ( ) ;
126+ services . AddTransient < IServiceBusMessageSerializer , ServiceBusMessageSerializer > ( ) ;
127+ services . AddTransient < ITopicClient > ( provider =>
128+ {
129+ var config = provider . GetRequiredService < IOptionsSnapshot < ServiceBusConfiguration > > ( ) . Value ;
130+
131+ return new TopicClientWrapper ( config . ConnectionString , config . TopicPath ) ;
132+ } ) ;
100133 }
101134
102135 protected override void ConfigureAutofacServices ( ContainerBuilder containerBuilder )
0 commit comments