tdex-network / tdex-analytics

Analytics and Historical data feed about TDEX Network
MIT License
0 stars 6 forks source link

Return empty reference prices if price feed not responding for long time #30

Closed tiero closed 2 years ago

tiero commented 2 years ago

Clients using gRPC get randomly the below error calling the MarketPrice endpoint

{
  "error": "full url: https://tdexa.tdex.network:443/tdexa.v1.Analytics/MarketsPrices, code: 13, err: error code: 1015"
}
tiero commented 2 years ago

cc/ @sekulicd any ideas?

sekulicd commented 2 years ago

Do we have exact request that failed? @tiero

mattiaferrari02 commented 2 years ago

The request body was

{
  "time_range": {
    "predefined_period": 2
  },
  "market_ids": [
    "1", "6", "5", "2"
  ],
  "reference_currency": "eur",
  "page": {
    "page_size": 288
  }
}
sekulicd commented 2 years ago

Could be maybe related to rate limit error by external exchange rate api.

tiero commented 2 years ago

Would be best to catch this? Maybe best to return anyway data we have, to prevent external dependency halt our response? eventually we can return the reference price converted empty when it happens?

sekulicd commented 2 years ago

@tiero yeah, lets refactor a bit this by having some cache of prices from which we will fetch data and refresh it periodically.

tiero commented 2 years ago

@tiero yeah, lets refactor a bit this by having some cache of prices from which we will fetch data and refresh it periodically.

I think it's important having not huge window of refresh: if happens a cached price too "old" (like more than 5 minutes?) best to return empty, than a wrong/old price

tiero commented 2 years ago

Would you take this? @altafan