lettuce
lettuce copied to clipboard
Refactor timeout handling
Right now, connection timeouts are held in RedisChannelHandler
and CommandExpiryWriter
. Especially when setting the timeout, we need to propagate the timeout into CommandExpiryWriter
to ensure that the connection timeout gets considered. By introducing CommandListenerWriter
, we wrap CommandExpiryWriter
and that requires further casting.
We should ideally store the timeout in a delegate/state object so that we can simplify the setTimeout
code.
Worth considering: Timeouts in multi-connection arrangements (Cluster, Master/Replica) could benefit as well from the state object to share a single configured timeout. Individual connections use that timeout value until setTimeout
gets called on the individual connection object.
Yes, I think it makes sense to refactor timeout propagation. However, I don't know for sure where this state object should be held, because current places suit not so good for accessing and mutating timeout. Some kind of singleton object to hold it not so good either because it suites bad in case of multiple shards/sources. @mp911de maybe you know the most appropriate place to keep such data?