Support customising the NATS Streaming channel.

Signed-off-by: Bruno Miguel Custódio <brunomcustodio@gmail.com>
This commit is contained in:
Bruno Miguel Custódio
2019-12-10 11:06:47 +00:00
committed by Alex Ellis
parent 3422bdcce9
commit 03dc8824d2
7 changed files with 39 additions and 7 deletions

View File

@ -7,18 +7,23 @@ import (
)
// CreateNATSQueue ready for asynchronous processing
func CreateNATSQueue(address string, port int, clusterName string, clientConfig NATSConfig) (*NATSQueue, error) {
func CreateNATSQueue(address string, port int, clusterName, channel string, 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()
// If 'channel' is empty, use the previous default.
if channel == "" {
channel = "faas-request"
}
queue1 := NATSQueue{
ClientID: clientID,
ClusterID: clusterName,
NATSURL: natsURL,
Topic: "faas-request",
Topic: channel,
maxReconnect: clientConfig.GetMaxReconnect(),
reconnectDelay: clientConfig.GetReconnectDelay(),
ncMutex: &sync.RWMutex{},