public StartupManager(
            ILog log,
            ICandlesCacheInitalizationService cacheInitalizationService,
            ICandlesSubscriber candlesSubscriber,
            ISnapshotSerializer snapshotSerializer,
            ICandlesPersistenceQueueSnapshotRepository persistenceQueueSnapshotRepository,
            ICandlesPersistenceQueue persistenceQueue,
            ICandlesPersistenceManager persistenceManager,
            bool migrationEnabled,
            ICqrsEngine cqrsEngine)
        {
            if (log == null)
            {
                throw new ArgumentNullException(nameof(log));
            }
            _log = log.CreateComponentScope(nameof(StartupManager)) ?? throw new InvalidOperationException("Couldn't create a component scope for logging.");

            _cacheInitalizationService          = cacheInitalizationService ?? throw new ArgumentNullException(nameof(cacheInitalizationService));
            _candlesSubscriber                  = candlesSubscriber ?? throw new ArgumentNullException(nameof(candlesSubscriber));
            _snapshotSerializer                 = snapshotSerializer ?? throw new ArgumentNullException(nameof(snapshotSerializer));
            _persistenceQueueSnapshotRepository = persistenceQueueSnapshotRepository ?? throw new ArgumentNullException(nameof(persistenceQueueSnapshotRepository));
            _persistenceQueue   = persistenceQueue ?? throw new ArgumentNullException(nameof(persistenceQueue));
            _persistenceManager = persistenceManager ?? throw new ArgumentNullException(nameof(persistenceManager));
            _migrationEnabled   = migrationEnabled;
            _cqrsEngine         = cqrsEngine ?? throw new ArgumentNullException(nameof(cqrsEngine));
        }
Example #2
0
        public StartupManager(
            ILogFactory logFactory,
            ICandlesCacheInitalizationService cacheInitalizationService,
            RedisCacheCaretaker cacheCaretaker,
            ICandlesSubscriber candlesSubscriber,
            ISnapshotSerializer snapshotSerializer,
            ICandlesPersistenceQueueSnapshotRepository persistenceQueueSnapshotRepository,
            ICandlesPersistenceQueue persistenceQueue,
            ICandlesPersistenceManager persistenceManager,
            bool migrationEnabled)
        {
            if (logFactory == null)
            {
                throw new ArgumentNullException(nameof(logFactory));
            }

            _log = logFactory.CreateLog(this);

            _cacheInitalizationService          = cacheInitalizationService ?? throw new ArgumentNullException(nameof(cacheInitalizationService));
            _cacheCaretaker                     = cacheCaretaker ?? throw new ArgumentNullException(nameof(cacheCaretaker));
            _candlesSubscriber                  = candlesSubscriber ?? throw new ArgumentNullException(nameof(candlesSubscriber));
            _snapshotSerializer                 = snapshotSerializer ?? throw new ArgumentNullException(nameof(snapshotSerializer));
            _persistenceQueueSnapshotRepository = persistenceQueueSnapshotRepository ?? throw new ArgumentNullException(nameof(persistenceQueueSnapshotRepository));
            _persistenceQueue                   = persistenceQueue ?? throw new ArgumentNullException(nameof(persistenceQueue));
            _persistenceManager                 = persistenceManager ?? throw new ArgumentNullException(nameof(persistenceManager));
            _migrationEnabled                   = migrationEnabled;
        }
 public CandlesSubscriber(
     ILogFactory logFactory,
     ICandlesManager candlesManager,
     ICandlesChecker checker,
     RabbitEndpointSettings settings,
     ICandlesCacheInitalizationService candlesCacheInitalizationService)
 {
     _log                       = logFactory.CreateLog(this);
     _logFactory                = logFactory;
     _candlesManager            = candlesManager;
     _candlesChecker            = checker;
     _settings                  = settings;
     _cacheInitalizationService = candlesCacheInitalizationService;
 }
 public StartupManager(
     ILog log,
     ICandlesCacheInitalizationService cacheInitalizationService,
     ICandlesSubscriber candlesSubscriber,
     ISnapshotSerializer snapshotSerializer,
     ICandlesPersistenceQueueSnapshotRepository persistenceQueueSnapshotRepository,
     ICandlesPersistenceQueue persistenceQueue,
     ICandlesPersistenceManager persistenceManager)
 {
     _log = log.CreateComponentScope(nameof(StartupManager));
     _cacheInitalizationService          = cacheInitalizationService;
     _candlesSubscriber                  = candlesSubscriber;
     _snapshotSerializer                 = snapshotSerializer;
     _persistenceQueueSnapshotRepository = persistenceQueueSnapshotRepository;
     _persistenceQueue   = persistenceQueue;
     _persistenceManager = persistenceManager;
 }
Example #5
0
        public RedisCacheCaretaker(
            ICandlesHistoryRepository historyRepository,
            ICandlesCacheService redisCacheService,
            ICandlesCacheInitalizationService cacheInitalizationService,
            TimeSpan cacheCheckupPeriod,
            Dictionary <CandleTimeInterval, int> amountOfCandlesToStore,
            MarketType marketType,
            ILogFactory logFactory)
        {
            _historyRepository         = historyRepository ?? throw new ArgumentNullException(nameof(historyRepository));
            _redisCacheService         = redisCacheService ?? throw new ArgumentNullException(nameof(redisCacheService));
            _cacheInitalizationService = cacheInitalizationService ?? throw new ArgumentNullException(nameof(cacheInitalizationService));
            _amountOfCandlesToStore    = amountOfCandlesToStore;
            _marketType = marketType;

            _maintainTicker            = new TimerTrigger(nameof(RedisCacheCaretaker), cacheCheckupPeriod, logFactory);
            _maintainTicker.Triggered += MaintainTickerOnTriggered;
        }
        public void InitializeTest()
        {
            var logMock = new Mock <ILog>();

            _dateTimeProviderMock     = new Mock <IClock>();
            _cacheServiceMock         = new Mock <ICandlesCacheService>();
            _historyRepositoryMock    = new Mock <ICandlesHistoryRepository>();
            _candlesAmountManagerMock = new Mock <ICandlesAmountManager>();
            _assetPairsManagerMock    = new Mock <IAssetPairsManager>();
            _candlesShardValidator    = new Mock <ICandlesShardValidator>();

            _assetPairs = new List <AssetPair>
            {
                new AssetPair {
                    Id = "EURUSD", Accuracy = 3
                },
                new AssetPair {
                    Id = "USDCHF", Accuracy = 2
                },
                new AssetPair {
                    Id = "EURRUB", Accuracy = 2
                }
            };

            _assetPairsManagerMock
            .Setup(m => m.GetAllEnabledAsync())
            .ReturnsAsync(() => _assetPairs);
            _assetPairsManagerMock
            .Setup(m => m.TryGetEnabledPairAsync(It.IsAny <string>()))
            .ReturnsAsync((string assetPairId) => _assetPairs.SingleOrDefault(a => a.Id == assetPairId));

            _service = new CandlesCacheInitalizationService(
                logMock.Object,
                _assetPairsManagerMock.Object,
                _dateTimeProviderMock.Object,
                _cacheServiceMock.Object,
                _historyRepositoryMock.Object,
                _candlesAmountManagerMock.Object,
                _candlesShardValidator.Object);
        }
Example #7
0
        public void InitializeTest()
        {
            _dateTimeProviderMock  = new Mock <IClock>();
            _cacheServiceMock      = new Mock <ICandlesCacheService>();
            _historyRepositoryMock = new Mock <ICandlesHistoryRepository>();
            _assetPairsManagerMock = new Mock <IAssetPairsManager>();

            _assetPairs = new List <AssetPair>
            {
                new AssetPair {
                    Id = "EURUSD", Accuracy = 3
                },
                new AssetPair {
                    Id = "USDCHF", Accuracy = 2
                },
                new AssetPair {
                    Id = "EURRUB", Accuracy = 2
                }
            };

            _assetPairsManagerMock
            .Setup(m => m.GetAllAsync())
            .ReturnsAsync(() => _assetPairs);
            _assetPairsManagerMock
            .Setup(m => m.TryGetAssetPairAsync(It.IsAny <string>()))
            .ReturnsAsync((string assetPairId) => _assetPairs.SingleOrDefault(a => a.Id == assetPairId));

            _service = new CandlesCacheInitalizationService(
                new CandlesCacheSemaphore(),
                EmptyLogFactory.Instance,
                _assetPairsManagerMock.Object,
                _dateTimeProviderMock.Object,
                _cacheServiceMock.Object,
                _historyRepositoryMock.Object,
                _amountOfCandlesToStore,
                MarketType,
                new DateTime(2016, 05, 01));
        }