-
Notifications
You must be signed in to change notification settings - Fork 83
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
[TT-9360] Changing Timeout from time.Duration to int #696
Conversation
@@ -137,9 +142,21 @@ func (k *KafkaPump) Init(config interface{}) error { | |||
k.log.WithField("SASL-Mechanism", k.kafkaConf.SASLMechanism).Warn("Tyk pump doesn't support this SASL mechanism.") | |||
} | |||
|
|||
// Timeout is an interface type to allow both time.Duration and float values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we add a default value here? there wasn't a default one before this change
@@ -90,6 +91,10 @@ func (k *KafkaPump) Init(config interface{}) error { | |||
} | |||
|
|||
processPumpEnvVars(k, k.log, k.kafkaConf, kafkaDefaultENV) | |||
// This interface field is not reached by envconfig library, that's why we manually check it | |||
if os.Getenv("TYK_PMP_PUMPS_KAFKA_META_TIMEOUT") != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not too fond of this way of getting the env var, but envconfig
library isn't getting the env var if the data type is an interface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check tests failing
pumps/kafka.go
Outdated
var timeout time.Duration | ||
switch k.kafkaConf.Timeout.(type) { | ||
case string: | ||
timeout, err = time.ParseDuration(k.kafkaConf.Timeout.(string)) | ||
if err != nil { | ||
k.log.Fatal("Failed to parse timeout: ", err) | ||
} | ||
case float64: | ||
timeout = time.Duration(k.kafkaConf.Timeout.(float64)) * time.Second | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not string or float, it will default to 0s
is that expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sredxny it was the previous behavior before this change. Just in case, 0s
means no timeout from the Kafka library documentation
/release to release-1.8 |
Working on it! Note that it can take a few minutes. |
* Updating storage to v1.0.7 * Changing Timeout from time.Duration to int * changing timeout type to interface * linting * handling numbers in format string (cherry picked from commit 91dd8a0)
@mativm02 Succesfully merged PR |
Description
Changing Timeout from time.Duration to int
Related Issue
https://tyktech.atlassian.net/jira/software/c/projects/TT/boards/42?modal=detail&selectedIssue=TT-9360
Motivation and Context
How This Has Been Tested
Screenshots (if appropriate)
Types of changes
Checklist
fork, don't request your
master
!master
branch (left side). Also, you should startyour branch off our latest
master
.go mod tidy && go mod vendor
go fmt -s
go vet