mirror of
https://github.com/openfaas/faas.git
synced 2025-06-21 14:23:25 +00:00
Bump to nats-queue-worker 0.7.0
Includes fix for reconnection bug to NATS Streaming Signed-off-by: Alex Ellis <alexellis2@gmail.com>
This commit is contained in:
31
gateway/vendor/github.com/openfaas/nats-queue-worker/readconfig.go
generated
vendored
31
gateway/vendor/github.com/openfaas/nats-queue-worker/readconfig.go
generated
vendored
@ -11,6 +11,10 @@ import (
|
||||
type ReadConfig struct {
|
||||
}
|
||||
|
||||
const DefaultMaxReconnect = 120
|
||||
|
||||
const DefaultReconnectDelay = time.Second * 2
|
||||
|
||||
func (ReadConfig) Read() QueueWorkerConfig {
|
||||
cfg := QueueWorkerConfig{
|
||||
AckWait: time.Second * 30,
|
||||
@ -58,6 +62,31 @@ func (ReadConfig) Read() QueueWorkerConfig {
|
||||
}
|
||||
}
|
||||
|
||||
cfg.MaxReconnect = DefaultMaxReconnect
|
||||
|
||||
if value, exists := os.LookupEnv("faas_max_reconnect"); exists {
|
||||
val, err := strconv.Atoi(value)
|
||||
|
||||
if err != nil {
|
||||
log.Println("converting faas_max_reconnect to int error:", err)
|
||||
} else {
|
||||
cfg.MaxReconnect = val
|
||||
}
|
||||
}
|
||||
|
||||
cfg.ReconnectDelay = DefaultReconnectDelay
|
||||
|
||||
if value, exists := os.LookupEnv("faas_reconnect_delay"); exists {
|
||||
reconnectDelayVal, durationErr := time.ParseDuration(value)
|
||||
|
||||
if durationErr != nil {
|
||||
log.Println("parse env var: faas_reconnect_delay as time.Duration error:", durationErr)
|
||||
|
||||
} else {
|
||||
cfg.ReconnectDelay = reconnectDelayVal
|
||||
}
|
||||
}
|
||||
|
||||
if val, exists := os.LookupEnv("ack_wait"); exists {
|
||||
ackWaitVal, durationErr := time.ParseDuration(val)
|
||||
if durationErr != nil {
|
||||
@ -78,4 +107,6 @@ type QueueWorkerConfig struct {
|
||||
WriteDebug bool
|
||||
MaxInflight int
|
||||
AckWait time.Duration
|
||||
MaxReconnect int
|
||||
ReconnectDelay time.Duration
|
||||
}
|
||||
|
Reference in New Issue
Block a user