Exemplo n.º 1
0
 public OrderBookAggregator(
     ILogger <OrderBookAggregator> logger,
     MyNoSqlGrpcDataWriter writer, IPublisher <MyJetWallet.Domain.Prices.BidAsk> pricePublisher, IPublisher <SimpleTrading.Abstraction.BidAsk.IBidAsk> candlePublisher)
 {
     _logger          = logger;
     _writer          = writer;
     _pricePublisher  = pricePublisher;
     _candlePublisher = candlePublisher;
 }
        public OutgoingEventJob(
            ISubscriber <IReadOnlyList <ME.Contracts.OutgoingMessages.OutgoingEvent> > subscriber,
            ILogger <OutgoingEventJob> logger,
            ITradeVolumeAggregator tradeVolumeAggregator,
            MyNoSqlGrpcDataWriter lastSeqWriter,
            IOrderBookAggregator orderBookAggregator)
        {
            _logger = logger;
            _tradeVolumeAggregator = tradeVolumeAggregator;
            _lastSeqWriter         = lastSeqWriter;
            _orderBookAggregator   = orderBookAggregator;

            _maxBatchSize = Program.Settings.MaxMeEventsBatchSize;

            subscriber.Subscribe(HandleEvents);
        }
        protected override void Load(ContainerBuilder builder)
        {
            var serviceBusClient = builder.RegisterMyServiceBusTcpClient(Program.ReloadedSettings(e => e.SpotServiceBusHostPort), ApplicationEnvironment.HostName, Program.LogFactory);

            builder.RegisterMeEventSubscriber(serviceBusClient, "price-source-3", TopicQueueType.PermanentWithSingleConnection);

            builder.RegisterType <OutgoingEventJob>().AutoActivate().SingleInstance();

            builder
            .RegisterType <OrderBookAggregator>()
            .As <IOrderBookAggregator>()
            .AsSelf()
            .SingleInstance();

            builder
            .RegisterType <TradeVolumeAggregator>()
            .As <ITradeVolumeAggregator>()
            .As <IStartable>()
            .AutoActivate()
            .SingleInstance();

            builder.RegisterMatchingEngineGrpcClient();


            MyNoSqlGrpcDataWriter noSqlWriter = MyNoSqlGrpcDataWriterFactory
                                                .CreateNoSsl(Program.Settings.MyNoSqlWriterGrpc)
                                                .RegisterSupportedEntity <OrderBookNoSql>(OrderBookNoSql.TableName)
                                                .RegisterSupportedEntity <BidAskNoSql>(BidAskNoSql.TableName);


            builder.RegisterInstance(noSqlWriter).AsSelf().SingleInstance();


            builder.RegisterMatchingEngineGrpcClient(orderBookServiceGrpcUrl: Program.Settings.OrderBookServiceGrpcUrl);

            builder.RegisterBidAskPublisher(serviceBusClient);
            builder.RegisterTradeVolumePublisher(serviceBusClient);

            RegisterCandlePublisher(builder);
        }