Ejemplo n.º 1
0
 public override async Task GetHistoricalPriceStreams(HistoricalPriceRequest request,
                                                      IServerStreamWriter <HistoricalPrice> responseStream, ServerCallContext context)
 {
     Logger.Here().Information("BGN");
     try {
         var response = quoteService.GetHistoricalPriceStreams(request).ResponseStream;
         while (await response.MoveNext())
         {
             await responseStream.WriteAsync(response.Current);
         }
     } catch (Exception e) {
         Logger.Here().Warning(e.Message);
         throw new RpcException(new Status(StatusCode.Internal, e.Message));
     }
 }
Ejemplo n.º 2
0
 public override async Task GetHistoricalPriceStreams(HistoricalPriceRequest request,
                                                      IServerStreamWriter <HistoricalPrice> responseStream, ServerCallContext context)
 {
     Logger.Here().Information("BGN");
     try {
         while (!context.CancellationToken.IsCancellationRequested)
         {
             String key = Constants.Redis.HISTORIC_PRICE + PriceType.TenSeconds +
                          "_" + request.Ticker;
             var secondPrice = redis.StringGet(key);
             if (secondPrice.HasValue)
             {
                 byte[]          bytes   = (RedisValue)secondPrice;
                 HistoricalPrice current = HistoricalPrice.Parser.ParseFrom(bytes);
                 await responseStream.WriteAsync(current);
             }
             //await Task.Delay(1 * 1000); // HACK: This should be an observable and not sleeping
         }
     } catch (Exception e) {
         Logger.Here().Warning(e.Message);
         throw new RpcException(new Status(StatusCode.Internal, e.Message));
     }
 }
 public HistoricalPriceResponse(WebResponse web_response, HistoricalPriceRequest historical_price_request)
 {
     HistoricalPriceRequest = historical_price_request;
     WebResponse            = web_response;
 }