public CollectionTransitHandler(ISourceRepositoryFactory sourceRepositoryFactory, IDestinationRepositoryFactory destinationRepositoryFactory, ICollectionPreparationHandler preparationHandler, IDocumentsWriterFactory documentsWriterFactory, IProgressManager manager, ILogger logger, CollectionTransitOptions options) { _manager = manager; _logger = logger; _options = options; _destination = destinationRepositoryFactory.Create(_logger); _source = sourceRepositoryFactory.Create(_logger); _preparationHandler = preparationHandler; _documentsWriterFactory = documentsWriterFactory; }
private static ICollectionTransitHandler CreateCollectionHandler(CollectionTransitOptions currentOptions, IProgressManager progressManager, ILogger logger) { var collectionLogger = logger.ForContext("Scope", currentOptions.Collection); var sourceFactory = new SourceRepositoryFactory(currentOptions.SourceConnectionString, currentOptions.Database, currentOptions.Collection); var destFactory = new DestinationRepositoryFactory(currentOptions.DestinationConnectionString, currentOptions.Database, currentOptions.Collection); var preparationHandler = new CollectionPreparationHandler(currentOptions.Collection, destFactory.Create(logger), sourceFactory.Create(logger), logger); var workersCount = currentOptions.Workers * Environment.ProcessorCount; var workerPoolFactory = new DocumentsWriterFactory(workersCount, workersCount, currentOptions.Collection, destFactory, logger); // ReSharper disable once ConstantNullCoalescingCondition var handler = new CollectionTransitHandler(sourceFactory, destFactory, preparationHandler, workerPoolFactory, progressManager, collectionLogger, currentOptions); return(handler); }