Pass empty string over nil for Redis eval script
What does this MR do and why?
This MR explicitly replaces the nil
argument in duplicate-job middleware to an empty string. The nil
is converted into an empty string by Redis::Connection::CommandHelper
but that will helper be removed in redis v5. This MR cleans up the type-conversion to reduce the diffs in !134862 (diffs).
Issue: gitlab-com/gl-infra/scalability#2586 (closed)
Note: to_f
is not ideal since tonumber
in lua converts 0.0
to 0
. The correct representation in the lua script for a nil
wal diff should be nil
.
➜ gitlab git:(master) ✗ luajit
LuaJIT 2.1.1696795921 -- Copyright (C) 2005-2023 Mike Pall. https://luajit.org/
JIT: ON fold cse dce fwd dse narrow loop abc sink fuse
> print(tonumber('123'))
123
> print(tonumber(''))
nil
> print(tonumber(nil))
nil
> print(tonumber('0.0'))
0
>
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.