LO:TECH response involving failed symbols#131
Conversation
Apply changes from #130 to the lo-tech module. Also, move cleanup upon timeout error from the call sites to the shared cache.
Improve lo-tech module logic by activating price feeds once ack messages are received. Also rename variables and improve comments for clarity.
3ce65b1 to
790be55
Compare
Previously, getOrWaitPrice was called sequentially in a loop, causing the timeouts to accumulate when multiple invalid symbols were requested.
790be55 to
bde8f24
Compare
| const now = yield* Clock.currentTimeMillis; | ||
| MutableHashMap.set(lastRequestToPriceFeed, symbol.value, now); |
There was a problem hiding this comment.
Is this correct? It reads a little weird that a message from lo-tech->proxy updates a map that tracks requests from client->proxy
There was a problem hiding this comment.
So with this change we update the price feed subscription map and the last request map upon receiving ack to avoid updating these maps for invalid symbols that we have failed to subscribe for. Previously, we were tracking last request times for all the invalid symbols we receive from clients, even though there were no active price feeds for those.
There was a problem hiding this comment.
Ah check, so if I understand it correctly the flow now is:
- Request for symbol
X - If new symbol, create new feedId (monotonically increasing counter) and store in
priceFeedIds - Receive ack for an ID
- Check if
priceFeedIdscontains the ID - If yes, make the pricefeed 'official' by adding mapping entry in
priceFeeds - And mark it as the first request by setting a timestamp in
lastRequestToPriceFeed
If this is correct I find it a little hard to get this from the code, but I also don't have an idea on how to express it differently.
I do have one question; what happens to priceFeedIds that never receive an ack? Is that a potential source of an unbounded map that doesn't get cleaned?
There was a problem hiding this comment.
Yes and yes, unfortunately. The ack message doesn't contain the symbol, so there is no way to avoid storing a symbol in priceFeedIds every time we send a subscription request.
But now that I think about it, we could handle this issue by handling the subscription failure errors we receive from the upstream. I will try that
Handle subscription failure error message from LO:TECH and remove the corresponding entry from the `priceFeedIds` map so that the map does not grow unbounded with invalid symbols. Also includes some refactor to improve organization of message parsing and handler dispatching.
Explanation of Changes
Explanation of the three commits in order:
Testing