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

[TT-9360] Changing Timeout from time.Duration to int #696

Merged
merged 8 commits into from
Aug 1, 2023
Merged

Conversation

mativm02
Copy link
Contributor

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • Make sure you are requesting to pull a topic/feature/bugfix branch (right side). If pulling from your own
    fork, don't request your master!
  • Make sure you are making a pull request against the master branch (left side). Also, you should start
    your branch off our latest master.
  • My change requires a change to the documentation.
    • If you've changed APIs, describe what needs to be updated in the documentation.
  • I have updated the documentation accordingly.
  • Modules and vendor dependencies have been updated; run go mod tidy && go mod vendor
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • Check your code additions will not fail linting checks:
    • go fmt -s
    • go vet

@sredxny sredxny self-requested a review July 28, 2023 16:36
@@ -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
Copy link
Contributor Author

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") != "" {
Copy link
Contributor Author

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

Copy link
Contributor

@sredxny sredxny left a 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
Comment on lines 146 to 156
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
}

Copy link
Contributor

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?

Copy link
Contributor Author

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

@mativm02 mativm02 merged commit 91dd8a0 into master Aug 1, 2023
10 checks passed
@mativm02 mativm02 deleted the TT-9360 branch August 1, 2023 12:40
@mativm02
Copy link
Contributor Author

mativm02 commented Sep 7, 2023

/release to release-1.8

@tykbot
Copy link

tykbot bot commented Sep 7, 2023

Working on it! Note that it can take a few minutes.

tykbot bot pushed a commit that referenced this pull request Sep 7, 2023
* 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)
@tykbot
Copy link

tykbot bot commented Sep 7, 2023

@mativm02 Succesfully merged PR

buger added a commit that referenced this pull request Sep 7, 2023
… to int (#696)

[TT-9360] Changing Timeout from time.Duration to int (#696)

* Updating storage to v1.0.7

* Changing Timeout from time.Duration to int

* changing timeout type to interface

* linting

* handling numbers in format string
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