public void Start() { try { var orderBooks = _orderBookProviderApi.GetOrderBooks().GetAwaiter().GetResult() .GroupBy(x => x.AssetPairId) .Select(x => _convertService.Convert <ExternalOrderBookContract, ExternalOrderBook>( x.MaxBy(o => o.ReceiveTimestamp))) .ToList(); foreach (var externalOrderBook in orderBooks) { SetOrderbook(externalOrderBook); } _log.WriteInfo(nameof(LightweightExternalOrderbookService), nameof(Start), $"External order books cache initialized with {orderBooks.Count} items from OrderBooks Service"); } catch (Exception exception) { _log.WriteWarning(nameof(LightweightExternalOrderbookService), nameof(Start), "Failed to initialize cache from OrderBook Service", exception); } }
public async Task InitializeAsync() { try { var orderBooks = (await _orderBookProviderApi.GetOrderBooks()) .GroupBy(x => x.AssetPairId) .Select(x => _convertService.Convert <ExternalOrderBookContract, ExternalOrderBook>( x.MaxBy(o => o.ReceiveTimestamp))) .ToList(); foreach (var externalOrderBook in orderBooks) { SetOrderbook(externalOrderBook); } await _log.WriteInfoAsync(nameof(ExternalOrderbookService), nameof(InitializeAsync), $"External order books cache initialized with {orderBooks.Count} items from OrderBooks Service"); } catch (Exception exception) { await _log.WriteWarningAsync(nameof(ExternalOrderbookService), nameof(InitializeAsync), "Failed to initialize cache from OrderBook Service", exception); } }