mirror of
https://github.com/openfaas/faas.git
synced 2025-06-12 18:26:49 +00:00
Add upstream_timeout as env-var
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
This commit is contained in:
parent
30928739ee
commit
6efaee5b4f
@ -65,7 +65,8 @@ func forwardRequest(w http.ResponseWriter, r *http.Request, proxyClient *http.Cl
|
|||||||
defer r.Body.Close()
|
defer r.Body.Close()
|
||||||
upstreamReq.Body = r.Body
|
upstreamReq.Body = r.Body
|
||||||
}
|
}
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), timeout-time.Second*1)
|
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
res, resErr := proxyClient.Do(upstreamReq.WithContext(ctx))
|
res, resErr := proxyClient.Do(upstreamReq.WithContext(ctx))
|
||||||
|
@ -40,7 +40,7 @@ func main() {
|
|||||||
|
|
||||||
servicePollInterval := time.Second * 5
|
servicePollInterval := time.Second * 5
|
||||||
|
|
||||||
reverseProxy := types.NewHTTPClientReverseProxy(config.FunctionsProviderURL, config.ReadTimeout)
|
reverseProxy := types.NewHTTPClientReverseProxy(config.FunctionsProviderURL, config.UpstreamTimeout)
|
||||||
|
|
||||||
faasHandlers.Proxy = internalHandlers.MakeForwardingProxyHandler(reverseProxy, &metricsOptions)
|
faasHandlers.Proxy = internalHandlers.MakeForwardingProxyHandler(reverseProxy, &metricsOptions)
|
||||||
faasHandlers.RoutelessProxy = internalHandlers.MakeForwardingProxyHandler(reverseProxy, &metricsOptions)
|
faasHandlers.RoutelessProxy = internalHandlers.MakeForwardingProxyHandler(reverseProxy, &metricsOptions)
|
||||||
|
@ -58,11 +58,11 @@ func (ReadConfig) Read(hasEnv HasEnv) GatewayConfig {
|
|||||||
PrometheusPort: 9090,
|
PrometheusPort: 9090,
|
||||||
}
|
}
|
||||||
|
|
||||||
readTimeout := parseIntOrDurationValue(hasEnv.Getenv("read_timeout"), time.Second*8)
|
defaultDuration := time.Second * 8
|
||||||
writeTimeout := parseIntOrDurationValue(hasEnv.Getenv("write_timeout"), time.Second*8)
|
|
||||||
|
|
||||||
cfg.ReadTimeout = readTimeout
|
cfg.ReadTimeout = parseIntOrDurationValue(hasEnv.Getenv("read_timeout"), defaultDuration)
|
||||||
cfg.WriteTimeout = writeTimeout
|
cfg.WriteTimeout = parseIntOrDurationValue(hasEnv.Getenv("write_timeout"), defaultDuration)
|
||||||
|
cfg.UpstreamTimeout = parseIntOrDurationValue(hasEnv.Getenv("upstream_timeout"), defaultDuration)
|
||||||
|
|
||||||
if len(hasEnv.Getenv("functions_provider_url")) > 0 {
|
if len(hasEnv.Getenv("functions_provider_url")) > 0 {
|
||||||
var err error
|
var err error
|
||||||
@ -114,6 +114,9 @@ type GatewayConfig struct {
|
|||||||
// HTTP timeout for writing a response from functions.
|
// HTTP timeout for writing a response from functions.
|
||||||
WriteTimeout time.Duration
|
WriteTimeout time.Duration
|
||||||
|
|
||||||
|
// UpstreamTimeout maximum duration of HTTP call to upstream URL
|
||||||
|
UpstreamTimeout time.Duration
|
||||||
|
|
||||||
// URL for alternate functions provider.
|
// URL for alternate functions provider.
|
||||||
FunctionsProviderURL *url.URL
|
FunctionsProviderURL *url.URL
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user