From c58af8da568105ce1298391f93ce0bc638a5e1bd Mon Sep 17 00:00:00 2001
From: "Alex Ellis (VMware)" <alexellis2@gmail.com>
Date: Tue, 17 Jul 2018 09:59:25 +0100
Subject: [PATCH] Disable scaling from zero by default

This disables the scaling proxy by default since it is not the
default user-experience and is still under refinement.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
---
 gateway/server.go           | 20 ++++++++++++--------
 gateway/types/readconfig.go |  3 ---
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/gateway/server.go b/gateway/server.go
index 62a6a0e2..a3282707 100644
--- a/gateway/server.go
+++ b/gateway/server.go
@@ -115,16 +115,20 @@ func main() {
 	r := mux.NewRouter()
 	// max wait time to start a function = maxPollCount * functionPollInterval
 
-	scalingConfig := handlers.ScalingConfig{
-		MaxPollCount:         uint(1000),
-		FunctionPollInterval: time.Millisecond * 10,
-		CacheExpiry:          time.Second * 5, // freshness of replica values before going stale
-	}
+	functionProxy := faasHandlers.Proxy
+
+	if config.ScaleFromZero {
+		scalingConfig := handlers.ScalingConfig{
+			MaxPollCount:         uint(1000),
+			FunctionPollInterval: time.Millisecond * 10,
+			CacheExpiry:          time.Second * 5, // freshness of replica values before going stale
+		}
 
-	scalingProxy := handlers.MakeScalingHandler(faasHandlers.Proxy, queryFunction, scalingConfig)
+		functionProxy = handlers.MakeScalingHandler(faasHandlers.Proxy, queryFunction, scalingConfig)
+	}
 	// r.StrictSlash(false)	// This didn't work, so register routes twice.
-	r.HandleFunc("/function/{name:[-a-zA-Z_0-9]+}", scalingProxy)
-	r.HandleFunc("/function/{name:[-a-zA-Z_0-9]+}/", scalingProxy)
+	r.HandleFunc("/function/{name:[-a-zA-Z_0-9]+}", functionProxy)
+	r.HandleFunc("/function/{name:[-a-zA-Z_0-9]+}/", functionProxy)
 
 	r.HandleFunc("/system/info", handlers.MakeInfoHandler(handlers.MakeForwardingProxyHandler(
 		reverseProxy, forwardingNotifiers, urlResolver))).Methods(http.MethodGet)
diff --git a/gateway/types/readconfig.go b/gateway/types/readconfig.go
index 09a0d960..5f0986e9 100644
--- a/gateway/types/readconfig.go
+++ b/gateway/types/readconfig.go
@@ -150,16 +150,13 @@ type GatewayConfig struct {
 	// If set this will be used to resolve functions directly
 	DirectFunctionsSuffix string
 
-<<<<<<< HEAD
 	// If set, reads secrets from file-system for enabling basic auth.
 	UseBasicAuth bool
 
 	// SecretMountPath specifies where to read secrets from for embedded basic auth
 	SecretMountPath string
-=======
 	// Enable the gateway to scale any service from 0 replicas to its configured "min replicas"
 	ScaleFromZero bool
->>>>>>> Add scale_from_zero flag
 }
 
 // UseNATS Use NATSor not
-- 
GitLab