Vendor new queue-worker version

Introduces 0.4.6 of queue-worker - see upstream repo for changes.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis (VMware)
2018-06-18 20:09:33 +01:00
parent 41bda568a7
commit 223c561706
81 changed files with 4701 additions and 1323 deletions

View File

@ -15,15 +15,26 @@ type NatsQueue struct {
nc stan.Conn
}
type NatsConfig interface {
GetClientID() string
}
type DefaultNatsConfig struct {
}
func (DefaultNatsConfig) GetClientID() string {
val, _ := os.Hostname()
return "faas-publisher-" + val
}
// CreateNatsQueue ready for asynchronous processing
func CreateNatsQueue(address string, port int) (*NatsQueue, error) {
func CreateNatsQueue(address string, port int, clientConfig NatsConfig) (*NatsQueue, error) {
queue1 := NatsQueue{}
var err error
natsURL := fmt.Sprintf("nats://%s:%d", address, port)
log.Printf("Opening connection to %s\n", natsURL)
val, _ := os.Hostname()
clientID := "faas-publisher-" + val
clientID := clientConfig.GetClientID()
clusterID := "faas-cluster"
nc, err := stan.Connect(clusterID, clientID, stan.NatsURL(natsURL))