Fix Workhorse Redis Sentinel role checks
Part of gitlab-com/gl-infra/scalability#1919 (closed).
Workhorse was configured to check the Redis replication role of the Redis server it connects to before every Redis command. This is too often. The Redis documentation recommends to check the role just once, immediately after establishing the connection. https://redis.io/docs/reference/sentinel-clients/
The source of the bad configuration is an incorrect example in the documentation of the Sentinel library we are using.
This MR moves the role check from the TestOnBorrow callback to the Dial callback.
I have manually tested that Workhorse can connect to a Sentinel cluster before and after. Using redis-cli monitor
I also observed that the ROLE
commands moved from happening before every GET
to happening just once after Workhorse starts up.