Fix lookup of RabbitMQ for dispatch in CF
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"strings"
|
"strings"
|
||||||
|
"errors"
|
||||||
|
|
||||||
"github.com/streadway/amqp"
|
"github.com/streadway/amqp"
|
||||||
"github.com/instana/go-sensor"
|
"github.com/instana/go-sensor"
|
||||||
@@ -184,18 +185,28 @@ func main() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Printf("Cloud Foundry detected")
|
||||||
|
|
||||||
|
bindingFound := false
|
||||||
|
|
||||||
services := appEnv.Services
|
services := appEnv.Services
|
||||||
for _, service := range services {
|
for _, service := range services {
|
||||||
for _, serviceBinding := range service {
|
for _, serviceBinding := range service {
|
||||||
bindingName, ok := serviceBinding.CredentialString("binding_name")
|
bindingName := serviceBinding.Name
|
||||||
|
|
||||||
if ok {
|
if strings.Compare(bindingName, "dispatch_queue") == 0 {
|
||||||
if strings.Compare(bindingName, "dispatch_queue") == 0 {
|
bindingFound = true
|
||||||
amqpUri, _ = serviceBinding.CredentialString("uri")
|
|
||||||
}
|
log.Printf("RabbitMQ service binding '%s' found", bindingName)
|
||||||
|
|
||||||
|
amqpUri, _ = serviceBinding.CredentialString("uri")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !bindingFound {
|
||||||
|
panic(errors.New("Service binding 'dispatch_queue' not found!"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get error threshold from environment
|
// get error threshold from environment
|
||||||
|
Reference in New Issue
Block a user