Skip to content

Commit

Permalink
Add setting to flush fabio buffer regardless headers (#531)
Browse files Browse the repository at this point in the history
  • Loading branch information
samm-git authored and aaronhurt committed Sep 19, 2018
1 parent 6d90015 commit 2ac1992
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 8 deletions.
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ type Proxy struct {
ResponseHeaderTimeout time.Duration
KeepAliveTimeout time.Duration
FlushInterval time.Duration
GlobalFlushInterval time.Duration
LocalIP string
ClientIPHeader string
TLSHeader string
Expand Down
15 changes: 8 additions & 7 deletions config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ var defaultConfig = &Config{
},
},
Proxy: Proxy{
MaxConn: 10000,
Strategy: "rnd",
Matcher: "prefix",
NoRouteStatus: 404,
DialTimeout: 30 * time.Second,
FlushInterval: time.Second,
LocalIP: LocalIPString(),
MaxConn: 10000,
Strategy: "rnd",
Matcher: "prefix",
NoRouteStatus: 404,
DialTimeout: 30 * time.Second,
FlushInterval: time.Second,
GlobalFlushInterval: 0,
LocalIP: LocalIPString(),
},
Registry: Registry{
Backend: "consul",
Expand Down
1 change: 1 addition & 0 deletions config/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ func load(cmdline, environ, envprefix []string, props *properties.Properties) (c
f.DurationVar(&readTimeout, "proxy.readtimeout", defaultValues.ReadTimeout, "read timeout for incoming requests")
f.DurationVar(&writeTimeout, "proxy.writetimeout", defaultValues.WriteTimeout, "write timeout for outgoing responses")
f.DurationVar(&cfg.Proxy.FlushInterval, "proxy.flushinterval", defaultConfig.Proxy.FlushInterval, "flush interval for streaming responses")
f.DurationVar(&cfg.Proxy.GlobalFlushInterval, "proxy.globalflushinterval", defaultConfig.Proxy.GlobalFlushInterval, "flush interval for non-streaming responses")
f.StringVar(&cfg.Log.AccessFormat, "log.access.format", defaultConfig.Log.AccessFormat, "access log format")
f.StringVar(&cfg.Log.AccessTarget, "log.access.target", defaultConfig.Log.AccessTarget, "access log target")
f.StringVar(&cfg.Log.RoutesFormat, "log.routes.format", defaultConfig.Log.RoutesFormat, "log format of routing table updates")
Expand Down
7 changes: 7 additions & 0 deletions config/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,13 @@ func TestLoad(t *testing.T) {
return cfg
},
},
{
args: []string{"-proxy.globalflushinterval", "5ms"},
cfg: func(cfg *Config) *Config {
cfg.Proxy.GlobalFlushInterval = 5 * time.Millisecond
return cfg
},
},
{
args: []string{"-proxy.maxconn", "555"},
cfg: func(cfg *Config) *Config {
Expand Down
10 changes: 10 additions & 0 deletions docs/content/ref/proxy.globalflushinterval.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: "proxy.globalflushinterval"
---

`proxy.globalflushinterval` configures periodic flushing of the
response buffer for proxied non-SSE connections. By default it is disabled.

The default is

proxy.globalflushinterval = 0
6 changes: 6 additions & 0 deletions fabio.properties
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,12 @@
#
# proxy.flushinterval = 1s

# proxy.globalflushinterval configures periodic flushing of the
# response buffer for non-SSE connections. By default it is not enabled.
#
# The default is
#
# proxy.globalflushinterval = 0

# proxy.maxconn configures the maximum number of cached
# incoming and outgoing connections.
Expand Down
2 changes: 1 addition & 1 deletion proxy/http_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (p *HTTPProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
h = newHTTPProxy(targetURL, tr, p.Config.FlushInterval)

default:
h = newHTTPProxy(targetURL, tr, time.Duration(0))
h = newHTTPProxy(targetURL, tr, p.Config.Proxy.GlobalFlushInterval)
}

if p.Config.GZIPContentTypes != nil {
Expand Down

0 comments on commit 2ac1992

Please sign in to comment.