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

Feat: custom timeout config #373

Closed
wants to merge 6 commits into from

Conversation

fengkx
Copy link

@fengkx fengkx commented May 10, 2019

configurable timeout for bad network environment #302

config/config.go Outdated
@@ -230,12 +233,19 @@ func (c *Config) ArchiveReadDays() int {
return getIntValue("ARCHIVE_READ_DAYS", defaultArchiveReadDays)
}

// RequestTimeout returns a Duration.time represent the request timeout
func (c *Config) RequestTimeout() time.Duration {
requestTimout := getIntValue("REQUEST_MAX_TIMEOUT", defaultRequestTimeout)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can name the variable HTTP_CLIENT_TIMEOUT to be more explicit. In the future, the HTTP server timeout could be also configurable...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

// 15MB max.
maxBodySize = 1024 * 1024 * 15
)

var cfg = config.NewConfig()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum.. I should refactor this config package. This is going to parse the config values twice during the process startup.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it when I wrote this.

It seem the config never change after the process startup. So it is OK to work though not so good. For now I cannot find out a way without parsing the config value again. Looking forward to your good news

@fguillot
Copy link
Member

fguillot commented Jun 4, 2019

Thank you for you pull-request but the config package has been rewritten to simplify to addition of features like this one.

In the master branch, you can now configure the HTTP client timeout with HTTP_CLIENT_TIMEOUT, and the body size with HTTP_CLIENT_MAX_BODY_SIZE.

@fguillot fguillot closed this Jun 4, 2019
@ghost ghost locked and limited conversation to collaborators Jun 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants