mirror of
https://github.com/openfaas/faas.git
synced 2025-06-21 00:06:38 +00:00
Re-vendor queue-worker publisher for reconnect
- re-vendor queue-worker for publisher via 0.6.0 - bump queue-worker version to 0.6.0 in docker-compose.yml for AMD64 - use new naming for NATS of nats -> NATS in variables where required - add default reconnect of 60 times, 2 seconds apart. Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
This commit is contained in:
committed by
Alex Ellis
parent
e63150ef70
commit
b4a550327d
81
gateway/vendor/github.com/openfaas/nats-queue-worker/readconfig.go
generated
vendored
Normal file
81
gateway/vendor/github.com/openfaas/nats-queue-worker/readconfig.go
generated
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ReadConfig constitutes config from env variables
|
||||
type ReadConfig struct {
|
||||
}
|
||||
|
||||
func (ReadConfig) Read() QueueWorkerConfig {
|
||||
cfg := QueueWorkerConfig{
|
||||
AckWait: time.Second * 30,
|
||||
MaxInflight: 1,
|
||||
}
|
||||
|
||||
if val, exists := os.LookupEnv("faas_nats_address"); exists {
|
||||
cfg.NatsAddress = val
|
||||
} else {
|
||||
cfg.NatsAddress = "nats"
|
||||
}
|
||||
|
||||
if val, exists := os.LookupEnv("faas_gateway_address"); exists {
|
||||
cfg.GatewayAddress = val
|
||||
} else {
|
||||
cfg.GatewayAddress = "gateway"
|
||||
}
|
||||
|
||||
if val, exists := os.LookupEnv("faas_function_suffix"); exists {
|
||||
cfg.FunctionSuffix = val
|
||||
}
|
||||
|
||||
if val, exists := os.LookupEnv("faas_print_body"); exists {
|
||||
if val == "1" || val == "true" {
|
||||
cfg.DebugPrintBody = true
|
||||
} else {
|
||||
cfg.DebugPrintBody = false
|
||||
}
|
||||
}
|
||||
|
||||
if val, exists := os.LookupEnv("write_debug"); exists {
|
||||
if val == "1" || val == "true" {
|
||||
cfg.WriteDebug = true
|
||||
} else {
|
||||
cfg.WriteDebug = false
|
||||
}
|
||||
}
|
||||
|
||||
if value, exists := os.LookupEnv("max_inflight"); exists {
|
||||
val, err := strconv.Atoi(value)
|
||||
if err != nil {
|
||||
log.Println("max_inflight error:", err)
|
||||
} else {
|
||||
cfg.MaxInflight = val
|
||||
}
|
||||
}
|
||||
|
||||
if val, exists := os.LookupEnv("ack_wait"); exists {
|
||||
ackWaitVal, durationErr := time.ParseDuration(val)
|
||||
if durationErr != nil {
|
||||
log.Println("ack_wait error:", durationErr)
|
||||
} else {
|
||||
cfg.AckWait = ackWaitVal
|
||||
}
|
||||
}
|
||||
|
||||
return cfg
|
||||
}
|
||||
|
||||
type QueueWorkerConfig struct {
|
||||
NatsAddress string
|
||||
GatewayAddress string
|
||||
FunctionSuffix string
|
||||
DebugPrintBody bool
|
||||
WriteDebug bool
|
||||
MaxInflight int
|
||||
AckWait time.Duration
|
||||
}
|
Reference in New Issue
Block a user