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

Adding default Read/WriteTimeouts & configs for overriding #37

Merged
merged 6 commits into from
Mar 21, 2016

Conversation

jprobinson
Copy link
Contributor

The existing Gizmo SimpleServer and RPCServer had no timeouts (and no options to set timeouts) for their HTTP Servers.

This PR adds a 10s default timeout for both and the ability to override them via config.Server.

readTimeout = 10 * time.Second
// writeTimeout is used by the http server to set a maximum duration before
// timing out write of the response. The default timeout is 10 seconds.
writeTimeout = 10 * time.Second
// JSONContentType is the content type that will be used for JSONEndpoints.
Copy link
Contributor

Choose a reason for hiding this comment

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

Might as well just change the comment to jsonContentType while you're at it.

@oliver-nyt
Copy link
Contributor

LGTM

@jprobinson
Copy link
Contributor Author

@oliver-nyt, I got that comment (33b39b8), thanks!

@oliver-nyt
Copy link
Contributor

🎉 🚙

@@ -112,6 +112,8 @@ func (s *SimpleServer) Start() error {
srv := http.Server{
Handler: RegisterAccessLogger(s.cfg, s),
MaxHeaderBytes: maxHeaderBytes,
ReadTimeout: readTimeout,
WriteTimeout: writeTimeout,
Copy link
Contributor

Choose a reason for hiding this comment

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

The values in this http.Server struct are duplicated here and server/rpc_server.go. It's not a big deal, but if they're always going to be synchronized, it might be worth extracting to some other place.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe even get rid of those global vars that are used to configure the servers.

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 agree, RPC needs some love and refactoring, but it's a bit out of the scope of this change. (Maybe we make an issue/enhancement?)

In the end, I imagine/hope the guts of the RPC server would get replaced by a bunch of go-kit transports and middleware, which is why I haven't coupled the two servers thus far.

@coveralls
Copy link

Coverage Status

Coverage increased (+1.0%) to 41.064% when pulling 43fe027 on timeout into 970f99b on master.

jprobinson added a commit that referenced this pull request Mar 21, 2016
Adding default Read/WriteTimeouts & configs for overriding
@jprobinson jprobinson merged commit 5e9125b into master Mar 21, 2016
@jprobinson jprobinson deleted the timeout branch March 21, 2016 20:06
@jprobinson
Copy link
Contributor Author

For future reference, some of the changes in this PR are to deal with: golang/go#12933

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.

None yet

4 participants