Update nats-queue-worker package to 0.4.7

This package version supports running OpenFaas on hosts the contain `.`
in their hostname i.e. computer-a.acme.com

Signed-off-by: Edward Wilde <ewilde@gmail.com>
This commit is contained in:
Edward Wilde
2018-06-21 20:30:28 +01:00
committed by Alex Ellis
parent 08d57de1f6
commit e39dbd9584
6 changed files with 37 additions and 6 deletions

View File

@ -8,6 +8,7 @@ import (
"github.com/nats-io/go-nats-streaming"
"github.com/openfaas/faas/gateway/queue"
"regexp"
)
// NatsQueue queue for work
@ -22,9 +23,11 @@ type NatsConfig interface {
type DefaultNatsConfig struct {
}
var supportedCharacters, _ = regexp.Compile("[^a-zA-Z0-9-_]+")
func (DefaultNatsConfig) GetClientID() string {
val, _ := os.Hostname()
return "faas-publisher-" + val
return getClientId(val)
}
// CreateNatsQueue ready for asynchronous processing
@ -58,3 +61,7 @@ func (q *NatsQueue) Queue(req *queue.Request) error {
return err
}
func getClientId(hostname string) string {
return "faas-publisher-" + supportedCharacters.ReplaceAllString(hostname, "_")
}