mirror of
https://github.com/openfaas/faas.git
synced 2025-06-21 00:06:38 +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:
8
gateway/vendor/github.com/openfaas/nats-queue-worker/handler/nats_queue.go
generated
vendored
8
gateway/vendor/github.com/openfaas/nats-queue-worker/handler/nats_queue.go
generated
vendored
@ -7,7 +7,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/nats-io/go-nats-streaming"
|
||||
stan "github.com/nats-io/go-nats-streaming"
|
||||
"github.com/openfaas/faas/gateway/queue"
|
||||
)
|
||||
|
||||
@ -48,6 +48,8 @@ func (q *NATSQueue) Queue(req *queue.Request) error {
|
||||
}
|
||||
|
||||
func (q *NATSQueue) connect() error {
|
||||
log.Printf("Connect: %s\n", q.NATSURL)
|
||||
|
||||
nc, err := stan.Connect(
|
||||
q.ClusterID,
|
||||
q.ClientID,
|
||||
@ -71,8 +73,10 @@ func (q *NATSQueue) connect() error {
|
||||
}
|
||||
|
||||
func (q *NATSQueue) reconnect() {
|
||||
log.Printf("Reconnect\n")
|
||||
|
||||
for i := 0; i < q.maxReconnect; i++ {
|
||||
time.Sleep(time.Second * time.Duration(i) * q.reconnectDelay)
|
||||
time.Sleep(time.Duration(i) * q.reconnectDelay)
|
||||
|
||||
if err := q.connect(); err == nil {
|
||||
log.Printf("Reconnecting (%d/%d) to %s. OK\n", i+1, q.maxReconnect, q.NATSURL)
|
||||
|
Reference in New Issue
Block a user