motiv-labs / janus

An API Gateway written in Go
https://hellofresh.gitbooks.io/janus
MIT License
2.79k stars 317 forks source link

Add Timeouts functionality #323

Closed italolelis closed 6 years ago

italolelis commented 6 years ago

What does this PR do?

For Janus server:

#[respondingTimeouts]
# readTimeout is the maximum duration for reading the entire request, including the body.
#
# Optional
# Default: "0s"
#
# readTimeout = "5s"

# writeTimeout is the maximum duration before timing out writes of the response.
#
# Optional
# Default: "0s"
#
# writeTimeout = "5s"

# idleTimeout is the maximum duration an idle (keep-alive) connection will remain idle before closing itself.
#
# Optional
# Default: "180s"
#
# idleTimeout = "360s"

Per endpoint:

{
"forwarding_timeouts": {"dial_timeout": "30s", "response_header_timeout": "60s"} 
}
codecov[bot] commented 6 years ago

Codecov Report

Merging #323 into master will increase coverage by 1.02%. The diff coverage is 39.47%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #323      +/-   ##
==========================================
+ Coverage   40.72%   41.75%   +1.02%     
==========================================
  Files          72       74       +2     
  Lines        2512     2467      -45     
==========================================
+ Hits         1023     1030       +7     
+ Misses       1427     1376      -51     
+ Partials       62       61       -1
Impacted Files Coverage Δ
pkg/web/provider.go 0% <ø> (ø) :arrow_up:
pkg/web/options.go 0% <ø> (ø) :arrow_up:
pkg/plugin/oauth2/oauth_introspection.go 0% <0%> (ø) :arrow_up:
pkg/plugin/oauth2/setup.go 7.86% <0%> (ø) :arrow_up:
pkg/proxy/register_options.go 0% <0%> (ø)
pkg/proxy/register.go 0% <0%> (ø) :arrow_up:
pkg/proxy/reverse_proxy.go 0% <0%> (ø)
pkg/plugin/oauth2/loader.go 0% <0%> (ø) :arrow_up:
pkg/plugin/cors/setup.go 88.88% <100%> (ø) :arrow_up:
pkg/plugin/responsetransformer/middleware.go 100% <100%> (ø) :arrow_up:
... and 19 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update f3b78ab...2a434db. Read the comment docs.

vgarvardt commented 6 years ago

@italolelis can you pls split this PR into 2 or 3 to make changes more granular and review a bit easier?

E.g. extract -race, enable_load_balancing and Debug related changes into the first PR, balancing changes/refactoring into another and Timeout functionality into the third one.

italolelis commented 6 years ago

@vgarvardt The timeouts and balancer transport refactors have to be on the same PR, they are dependent. I could split the race stuff but they are tiny, that's why they are in the same PR. If you want I can split the -race, enable_load_balancing and Debug but not the other two