public DatabasePackageStatusOutdatedCheckSource( ReadWriteCursor cursor, IGalleryDatabaseQueryService galleryDatabase) : base(cursor) { _galleryDatabaseQueryService = galleryDatabase ?? throw new ArgumentNullException(nameof(galleryDatabase)); }
public PackageRegistrationMetadataResourceDatabaseFeedProvider( IGalleryDatabaseQueryService queryService) : base(typeof(IPackageRegistrationMetadataResource), nameof(IPackageRegistrationMetadataResource)) { _queryService = queryService ?? throw new ArgumentNullException(nameof(queryService)); }
public PackageTimestampMetadataResourceDatabase( IGalleryDatabaseQueryService galleryDatabase, ILogger <PackageTimestampMetadataResourceDatabase> logger) { _galleryDatabase = galleryDatabase ?? throw new ArgumentNullException(nameof(galleryDatabase)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public PackageTimestampMetadataResourceDatabaseProvider( IGalleryDatabaseQueryService galleryDatabaseQueryService, ILoggerFactory loggerFactory) : base(typeof(IPackageTimestampMetadataResource)) { _galleryDatabase = galleryDatabaseQueryService ?? throw new ArgumentNullException(nameof(galleryDatabaseQueryService)); _loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory)); }
protected override void Init(IDictionary <string, string> arguments, CancellationToken cancellationToken) { var verbose = arguments.GetOrDefault(Arguments.Verbose, false); _maxRequeueQueueSize = arguments.GetOrDefault(Arguments.MaxRequeueQueueSize, DefaultMaxQueueSize); CommandHelpers.AssertAzureStorage(arguments); var monitoringStorageFactory = CommandHelpers.CreateStorageFactory(arguments, verbose); _statusService = CommandHelpers.GetPackageMonitoringStatusService(arguments, monitoringStorageFactory, LoggerFactory); _packageValidatorContextQueue = CommandHelpers.CreateStorageQueue <PackageValidatorContext>(arguments, PackageValidatorContext.Version); Logger.LogInformation( "CONFIG storage: {Storage}", monitoringStorageFactory); _monitoringCursor = ValidationFactory.GetFront(monitoringStorageFactory); _galleryCursor = CreateCursor(monitoringStorageFactory, GalleryCursorFileName); _deletedCursor = CreateCursor(monitoringStorageFactory, DeletedCursorFileName); var connectionString = arguments.GetOrThrow <string>(Arguments.ConnectionString); var galleryDbConnection = new AzureSqlConnectionFactory( connectionString, SecretInjector, LoggerFactory.CreateLogger <AzureSqlConnectionFactory>()); var packageContentUriBuilder = new PackageContentUriBuilder( arguments.GetOrThrow <string>(Arguments.PackageContentUrlFormat)); var timeoutInSeconds = arguments.GetOrDefault(Arguments.SqlCommandTimeoutInSeconds, 300); _galleryDatabaseQueryService = new GalleryDatabaseQueryService( galleryDbConnection, packageContentUriBuilder, TelemetryService, timeoutInSeconds); var auditingStorageFactory = CommandHelpers.CreateSuffixedStorageFactory( "Auditing", arguments, verbose, new SemaphoreSlimThrottle(new SemaphoreSlim(ServicePointManager.DefaultConnectionLimit))); _auditingStorage = auditingStorageFactory.Create(); var messageHandlerFactory = CommandHelpers.GetHttpMessageHandlerFactory(TelemetryService, verbose); _client = new CollectorHttpClient(messageHandlerFactory()); }
public static void RegisterSourceRepositories( this ContainerBuilder builder, string galleryUrl, string indexUrl, IGalleryDatabaseQueryService galleryDatabase) { if (string.IsNullOrEmpty(galleryUrl)) { throw new ArgumentException(Strings.ArgumentMustNotBeNullOrEmpty, nameof(galleryUrl)); } if (string.IsNullOrEmpty(indexUrl)) { throw new ArgumentException(Strings.ArgumentMustNotBeNullOrEmpty, nameof(indexUrl)); } builder .RegisterInstance(new PackageSource(galleryUrl)) .Keyed <PackageSource>(FeedType.HttpV2); builder .RegisterInstance(new PackageSource(indexUrl)) .Keyed <PackageSource>(FeedType.HttpV3); builder .RegisterInstance(galleryDatabase) .AsImplementedInterfaces() .AsSelf(); builder.RegisterDefaultResourceProviders(); builder.RegisterV2ResourceProviders(); builder.RegisterV3ResourceProviders(); builder.RegisterSourceRepository(FeedType.HttpV2); builder.RegisterSourceRepository(FeedType.HttpV3); builder .RegisterType <ValidationSourceRepositories>() .WithParameter( (pi, ctx) => pi.Name == "v2", (pi, ctx) => ctx.ResolveKeyed <SourceRepository>(FeedType.HttpV2)) .WithParameter( (pi, ctx) => pi.Name == "v3", (pi, ctx) => ctx.ResolveKeyed <SourceRepository>(FeedType.HttpV3)) .AsSelf(); }
public static PackageValidator CreatePackageValidator( string galleryUrl, string indexUrl, StorageFactory auditingStorageFactory, ValidatorConfiguration validatorConfig, EndpointConfiguration endpointConfig, Func <HttpMessageHandler> messageHandlerFactory, IGalleryDatabaseQueryService galleryDatabase, ILoggerFactory loggerFactory) { if (auditingStorageFactory == null) { throw new ArgumentNullException(nameof(auditingStorageFactory)); } var collection = new ServiceCollection(); collection.AddSingleton(loggerFactory); collection.AddSingleton(typeof(ILogger <>), typeof(Logger <>)); var builder = new ContainerBuilder(); builder.Populate(collection); builder.RegisterValidatorConfiguration(validatorConfig); builder.RegisterEndpointConfiguration(endpointConfig); builder.RegisterMessageHandlerFactory(messageHandlerFactory); builder.RegisterEndpoints(endpointConfig); builder.RegisterSourceRepositories(galleryUrl, indexUrl, galleryDatabase); builder.RegisterValidators(endpointConfig); builder .RegisterInstance(auditingStorageFactory) .AsSelf() .As <StorageFactory>(); builder.RegisterType <PackageValidator>(); var container = builder.Build(); return(container.Resolve <PackageValidator>()); }
protected override void Init(IDictionary <string, string> arguments, CancellationToken cancellationToken) { Verbose = arguments.GetOrDefault(Arguments.Verbose, false); StartDate = arguments.GetOrDefault(Arguments.StartDate, Constants.DateTimeMinValueUtc); Top = arguments.GetOrDefault(Arguments.CursorSize, 20); SkipCreatedPackagesProcessing = arguments.GetOrDefault(Arguments.SkipCreatedPackagesProcessing, false); StorageFactory preferredPackageSourceStorageFactory = null; var preferAlternatePackageSourceStorage = arguments.GetOrDefault(Arguments.PreferAlternatePackageSourceStorage, false); if (preferAlternatePackageSourceStorage) { preferredPackageSourceStorageFactory = CommandHelpers.CreateSuffixedStorageFactory( "PreferredPackageSourceStorage", arguments, Verbose, new SemaphoreSlimThrottle(new SemaphoreSlim(ServicePointManager.DefaultConnectionLimit))); } var catalogStorageFactory = CommandHelpers.CreateStorageFactory( arguments, Verbose, new SemaphoreSlimThrottle(new SemaphoreSlim(ServicePointManager.DefaultConnectionLimit))); var auditingStorageFactory = CommandHelpers.CreateSuffixedStorageFactory( "Auditing", arguments, Verbose, new SemaphoreSlimThrottle(new SemaphoreSlim(ServicePointManager.DefaultConnectionLimit))); Logger.LogInformation("CONFIG source: \"{ConfigSource}\" storage: \"{Storage}\" preferred package source storage: \"{PreferredPackageSourceStorage}\"", GalleryDbConnection, catalogStorageFactory, preferredPackageSourceStorageFactory); CatalogStorage = catalogStorageFactory.Create(); AuditingStorage = auditingStorageFactory.Create(); if (preferAlternatePackageSourceStorage) { PreferredPackageSourceStorage = preferredPackageSourceStorageFactory.Create(); } Destination = catalogStorageFactory.BaseAddress; TelemetryService.GlobalDimensions[TelemetryConstants.Destination] = Destination.AbsoluteUri; // Setup gallery database access PackageContentUriBuilder = new PackageContentUriBuilder( arguments.GetOrThrow <string>(Arguments.PackageContentUrlFormat)); var connectionString = arguments.GetOrThrow <string>(Arguments.ConnectionString); GalleryDbConnection = new AzureSqlConnectionFactory( connectionString, SecretInjector, LoggerFactory.CreateLogger <AzureSqlConnectionFactory>()); var timeoutInSeconds = arguments.GetOrDefault(Arguments.SqlCommandTimeoutInSeconds, 300); Timeout = TimeSpan.FromSeconds(timeoutInSeconds); GalleryDatabaseQueryService = new GalleryDatabaseQueryService( GalleryDbConnection, PackageContentUriBuilder, TelemetryService, timeoutInSeconds); }
public PackageRegistrationMetadataResourceDatabase( IGalleryDatabaseQueryService galleryDatabase) { _galleryDatabase = galleryDatabase ?? throw new ArgumentNullException(nameof(galleryDatabase)); }