public AssetPairMigrationManager( IHealthService healthService, ICandlesPersistenceQueue candlesPersistenceQueue, MigrationCandlesGenerator candlesGenerator, AssetPairMigrationTelemetryService telemetryService, IAssetPair assetPair, ILog log, BidAskHCacheService bidAskHCacheService, IHistoryProvider historyProvider, ICandlesHistoryMigrationService candlesHistoryMigrationService, Action <string> onStoppedAction, MigrationSettings settings) { _healthService = healthService; _candlesPersistenceQueue = candlesPersistenceQueue; _candlesGenerator = candlesGenerator; _telemetryService = telemetryService; _assetPair = assetPair; _log = log; _bidAskHCacheService = bidAskHCacheService; _historyProvider = historyProvider; _candlesHistoryMigrationService = candlesHistoryMigrationService; _onStoppedAction = onStoppedAction; _settings = settings; _cts = new CancellationTokenSource(); }
public async Task <string> MigrateAsync(string assetPairId, IHistoryProvider historyProvider) { if (!MigrationEnabled) { return(string.Empty); } if (!_candlesHistoryRepository.CanStoreAssetPair(assetPairId)) { return($"Connection string for the asset pair '{assetPairId}' not configuer"); } var assetPair = await _assetPairsManager.TryGetAssetPairAsync(assetPairId); if (assetPair == null) { return($"Asset pair '{assetPairId}' not found"); } lock (_assetManagers) { if (_assetManagers.ContainsKey(assetPairId)) { return($"{assetPairId} already being processed"); } var telemetryService = new AssetPairMigrationTelemetryService(_logFactory, assetPairId); var assetManager = new AssetPairMigrationManager( _healthService, _candlesPersistenceQueue, _candlesGenerator, telemetryService, assetPair, _logFactory, new BidAskHCacheService(), historyProvider, _candlesHistoryMigrationService, OnMigrationStopped, _settings); assetManager.Start(); _assetHealthServices.Add(assetPairId, telemetryService); _assetManagers.Add(assetPairId, assetManager); return($"{assetPairId} processing is started"); } }