Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Generic parameter parser for scalers #5388

Closed
wants to merge 8 commits into from

Conversation

wozniakjan
Copy link
Member

@wozniakjan wozniakjan commented Jan 16, 2024

This PR intends to further improve the work related to refactoring of scalers accomplished by #5319 and #5228. This depends on #5319 and requires a rebase after that PR merges first because this contains commits from that PR.

All unique changes proposed here are in the last commit f03313c can be summarized in following points:

  • dropping reflections argument from getParameterFromConfigV2 in favour of generics
  • adding a type constraint to catch bugs from calling getParameterFromConfigV2 with types not supported by convertToType during compile time
  • implicit type conversion so the rest of the code doesn't need type assertions

this means following invocation changes from

activationLagThreshold, err := getParameterFromConfigV2(config, activationLagThresholdMetricName, true, false, false, true, int64(defaultKafkaActivationLagThreshold), reflect.TypeOf(int64(64)))
if activationLagThreshold.(int64) < 0 {
...
}

to slightly simpler

activationLagThreshold, err := getParameterFromConfigV2(config, activationLagThresholdMetricName, true, false, false, true, defaultKafkaActivationLagThreshold)
if activationLagThreshold < 0 {
...
}

Checklist

Relates to #5037

dttung2905 and others added 8 commits January 15, 2024 16:19
Signed-off-by: dttung2905 <[email protected]>
Signed-off-by: dttung2905 <[email protected]>
Signed-off-by: dttung2905 <[email protected]>
Signed-off-by: dttung2905 <[email protected]>
Signed-off-by: dttung2905 <[email protected]>
Signed-off-by: dttung2905 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants