mirror of
https://github.com/openfaas/faas.git
synced 2025-06-10 01:06:47 +00:00
- 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>
32 lines
719 B
Go
32 lines
719 B
Go
package handler
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"sync"
|
|
)
|
|
|
|
// CreateNATSQueue ready for asynchronous processing
|
|
func CreateNATSQueue(address string, port int, clientConfig NATSConfig) (*NATSQueue, error) {
|
|
var err error
|
|
natsURL := fmt.Sprintf("nats://%s:%d", address, port)
|
|
log.Printf("Opening connection to %s\n", natsURL)
|
|
|
|
clientID := clientConfig.GetClientID()
|
|
clusterID := "faas-cluster"
|
|
|
|
queue1 := NATSQueue{
|
|
ClientID: clientID,
|
|
ClusterID: clusterID,
|
|
NATSURL: natsURL,
|
|
Topic: "faas-request",
|
|
maxReconnect: clientConfig.GetMaxReconnect(),
|
|
reconnectDelay: clientConfig.GetReconnectDelay(),
|
|
ncMutex: &sync.RWMutex{},
|
|
}
|
|
|
|
err = queue1.connect()
|
|
|
|
return &queue1, err
|
|
}
|