public void ConfigureServices(ContainerBuilder builder, ILog log)
        {
            var mq = settings.BrokerQuoteFeed.RabbitMq;
            var connectionsString  = $"amqp://{mq.Username}:{mq.Password}@{mq.Host}:{mq.Port}";
            var subscriberSettings = new RabbitMqSubscriberSettings()
            {
                ConnectionString = connectionsString,
                QueueName        = mq.ExchangeOrderbook + ".quotefeedbroker",
                ExchangeName     = mq.ExchangeOrderbook,
                IsDurable        = true
            };
            var publisherSettings = new RabbitMqPublisherSettings
            {
                ConnectionString = connectionsString,
                ExchangeName     = mq.QuoteFeed
            };

            var subscriber = new RabbitMqSubscriber <OrderBook>(subscriberSettings);
            var publisher  = new RabbitMqPublisher <Quote>(publisherSettings);
            var broker     = new Broker(subscriber, publisher, log);

            builder.RegisterInstance(subscriber)
            .As <IStartable>()
            .As <IStopable>();

            builder.RegisterInstance(publisher)
            .As <IStartable>()
            .As <IStopable>();
        }
 public HistoryOperationSubscruber(IHistoryOperationService historyOperationService,
                                   RabbitMqSubscriberSettings settings, ILogFactory logFactory)
 {
     _historyOperationService = historyOperationService;
     _settings   = settings;
     _logFactory = logFactory;
     _log        = logFactory.CreateLog(this);
 }
Example #3
0
 public TickPricesSubscriber(RabbitMqSubscriberSettings settings,
                             ILogFactory logFactory, ICandlesRepository candlesRepository,
                             AssetPairSettings[] assetPairsSettings)
 {
     _logFactory        = logFactory;
     _log               = logFactory.CreateLog(this);
     _settings          = settings;
     _candlesRepository = candlesRepository;
     _assetPairs        = assetPairsSettings.Select(p => p.AssetPairId).ToArray();
 }
Example #4
0
        public void ConfigureServices(ContainerBuilder builder, ILog log)
        {
            var mq = settings.FeedCandlesHistoryWriterBroker.RabbitMq;
            RabbitMqSubscriberSettings subscriberSettings = new RabbitMqSubscriberSettings()
            {
                ConnectionString = $"amqp://{mq.Username}:{mq.Password}@{mq.Host}:{mq.Port}",
                QueueName        = mq.QuoteFeed + ".candleshistorywriter",
                ExchangeName     = mq.QuoteFeed,
                IsDurable        = true
            };

            var dictRepo = new AssetPairsRepository(new AzureTableStorage <AssetPairEntity>(
                                                        settings.FeedCandlesHistoryWriterBroker.ConnectionStrings.DictsConnectionString,
                                                        settings.FeedCandlesHistoryWriterBroker.DictionaryTableName,
                                                        log));

            var env        = new Environment(dictRepo, log, ApplicationName);
            var subscriber = new RabbitMqSubscriber <Quote>(subscriberSettings);

            this.controller = new CandleGenerationController(log, ApplicationName, env);
            this.monitor    = new QueueMonitor(log, this.controller, settings.FeedCandlesHistoryWriterBroker.QueueWarningSize, ApplicationName);
            this.broker     = new Broker(subscriber, log, this.controller, ApplicationName);

            builder.Register(c => new CandleHistoryRepositoryResolver((asset, tableName) => {
                string connString;
                if (!settings.CandleHistoryAssetConnections.TryGetValue(asset, out connString) ||
                    string.IsNullOrEmpty(connString))
                {
                    throw new AppSettingException(string.Format("Connection string for asset pair '{0}' is not specified.", asset));
                }

                var storage = new AzureTableStorage <CandleTableEntity>(connString, tableName, log);
                // Preload table info
                var res = storage.GetDataAsync(asset, "1900-01-01").Result;
                return(storage);
            })).As <ICandleHistoryRepository>();

            builder.RegisterInstance(subscriber)
            .As <IStartable>()
            .As <IStopable>();

            builder.RegisterInstance(this.controller)
            .As <IStartable>()
            .As <IStopable>();

            builder.RegisterInstance(this.monitor)
            .As <IStartable>()
            .As <IStopable>();

            builder.RegisterInstance(this.broker)
            .As <IStartable>()
            .As <IStopable>()
            .As <IPersistent>();
        }