mirror of
https://github.com/openfaas/faas.git
synced 2025-06-08 16:26:47 +00:00
Introduce welcome message and change default timeout
The welcome message shows the difference between Pro and CE. The timeout of 8 seconds was never going to be useful as a default, so changing to 60 seconds. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
This commit is contained in:
parent
9fccc67b9c
commit
4604271076
@ -27,10 +27,6 @@ const NameExpression = "-a-zA-Z_0-9."
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
if len(version.GitCommitMessage) == 0 {
|
|
||||||
version.GitCommitMessage = "See GitHub for latest changes"
|
|
||||||
}
|
|
||||||
|
|
||||||
osEnv := types.OsEnv{}
|
osEnv := types.OsEnv{}
|
||||||
readConfig := types.ReadConfig{}
|
readConfig := types.ReadConfig{}
|
||||||
config, configErr := readConfig.Read(osEnv)
|
config, configErr := readConfig.Read(osEnv)
|
||||||
@ -38,15 +34,18 @@ func main() {
|
|||||||
if configErr != nil {
|
if configErr != nil {
|
||||||
log.Fatalln(configErr)
|
log.Fatalln(configErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("HTTP Read Timeout: %s", config.ReadTimeout)
|
|
||||||
log.Printf("HTTP Write Timeout: %s", config.WriteTimeout)
|
|
||||||
|
|
||||||
if !config.UseExternalProvider() {
|
if !config.UseExternalProvider() {
|
||||||
log.Fatalln("You must provide an external provider via 'functions_provider_url' env-var.")
|
log.Fatalln("You must provide an external provider via 'functions_provider_url' env-var.")
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Binding to external function provider: %s", config.FunctionsProviderURL)
|
fmt.Printf("OpenFaaS Gateway - Community Edition (CE)\n"+
|
||||||
|
"\nVersion: %s Commit: %s\nTimeouts: read=%s\twrite=%s\tupstream=%s\nFunction provider: %s\n\n",
|
||||||
|
version.BuildVersion(),
|
||||||
|
version.GitCommitSHA,
|
||||||
|
config.ReadTimeout,
|
||||||
|
config.WriteTimeout,
|
||||||
|
config.UpstreamTimeout,
|
||||||
|
config.FunctionsProviderURL)
|
||||||
|
|
||||||
// credentials is used for service-to-service auth
|
// credentials is used for service-to-service auth
|
||||||
var credentials *auth.BasicAuthCredentials
|
var credentials *auth.BasicAuthCredentials
|
||||||
@ -67,9 +66,6 @@ func main() {
|
|||||||
|
|
||||||
servicePollInterval := time.Second * 5
|
servicePollInterval := time.Second * 5
|
||||||
|
|
||||||
metadataQuery := metrics.NewMetadataQuery(credentials)
|
|
||||||
fmt.Println(metadataQuery)
|
|
||||||
|
|
||||||
metricsOptions := metrics.BuildMetricsOptions()
|
metricsOptions := metrics.BuildMetricsOptions()
|
||||||
exporter := metrics.NewExporter(metricsOptions, credentials, config.Namespace)
|
exporter := metrics.NewExporter(metricsOptions, credentials, config.Namespace)
|
||||||
exporter.StartServiceWatcher(*config.FunctionsProviderURL, metricsOptions, "func", servicePollInterval)
|
exporter.StartServiceWatcher(*config.FunctionsProviderURL, metricsOptions, "func", servicePollInterval)
|
||||||
|
@ -59,7 +59,7 @@ func (ReadConfig) Read(hasEnv HasEnv) (*GatewayConfig, error) {
|
|||||||
PrometheusPort: 9090,
|
PrometheusPort: 9090,
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultDuration := time.Second * 8
|
defaultDuration := time.Second * 60
|
||||||
|
|
||||||
cfg.ReadTimeout = parseIntOrDurationValue(hasEnv.Getenv("read_timeout"), defaultDuration)
|
cfg.ReadTimeout = parseIntOrDurationValue(hasEnv.Getenv("read_timeout"), defaultDuration)
|
||||||
cfg.WriteTimeout = parseIntOrDurationValue(hasEnv.Getenv("write_timeout"), defaultDuration)
|
cfg.WriteTimeout = parseIntOrDurationValue(hasEnv.Getenv("write_timeout"), defaultDuration)
|
||||||
|
@ -198,13 +198,16 @@ func TestRead_EmptyTimeoutConfig(t *testing.T) {
|
|||||||
|
|
||||||
config, _ := readConfig.Read(defaults)
|
config, _ := readConfig.Read(defaults)
|
||||||
|
|
||||||
if (config.ReadTimeout) != time.Duration(8)*time.Second {
|
want := time.Second * 60
|
||||||
t.Log("ReadTimeout incorrect")
|
got := config.ReadTimeout
|
||||||
t.Fail()
|
if got != want {
|
||||||
|
t.Fatalf("config.ReadTimeout want: %s, but got: %s", want, got)
|
||||||
}
|
}
|
||||||
if (config.WriteTimeout) != time.Duration(8)*time.Second {
|
|
||||||
t.Log("WriteTimeout incorrect")
|
want = time.Second * 60
|
||||||
t.Fail()
|
got = config.WriteTimeout
|
||||||
|
if got != want {
|
||||||
|
t.Fatalf("config.WriteTimeout want: %s, but got: %s", want, got)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ var (
|
|||||||
GitCommitSHA string
|
GitCommitSHA string
|
||||||
|
|
||||||
// GitCommitMessage as read from the latest tag/release
|
// GitCommitMessage as read from the latest tag/release
|
||||||
GitCommitMessage string
|
GitCommitMessage = "See GitHub for latest changes"
|
||||||
|
|
||||||
// DevVersion string for the development version
|
// DevVersion string for the development version
|
||||||
DevVersion = "dev"
|
DevVersion = "dev"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user