Skip to content

Commit

Permalink
adding rabbitmq configuration in config file
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshu144141 committed Oct 7, 2016
1 parent 0c133e0 commit d24257b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
11 changes: 9 additions & 2 deletions app/DAL/clients/rabbitmq/rabbitmq.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package rabbitmq

import "github.com/streadway/amqp"
import (
"github.com/crowdflux/angel/app/config"
"github.com/streadway/amqp"
)

var rabbitmqConn *amqp.Connection

Expand All @@ -10,7 +13,11 @@ func init() {

func initRabbitMqClient() *amqp.Connection {

conn, err := amqp.Dial("amqp://guest:guest@localhost:5672/")
username := config.RABBITMQ_USERNAME.Get()
password := config.RABBITMQ_PASSWORD.Get()
host := config.RABBITMQ_HOST.Get()

conn, err := amqp.Dial("amqp://" + username + ":" + password + "@" + host + ":5672/")
if err != nil {
panic(err)
}
Expand Down
4 changes: 4 additions & 0 deletions app/config/config_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ const (
PLOG_LEVEL = configKey("plog.log_level")

NEW_RELIC_KEY = configKey("newrelic.key")

RABBITMQ_USERNAME = configKey("rabbitmq.username")
RABBITMQ_PASSWORD = configKey("rabbitmq.password")
RABBITMQ_HOST = configKey("rabbitmq.host")
)

// Gets the value for given key from the config file.
Expand Down
7 changes: 6 additions & 1 deletion app/config/development_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@
"log_level" : "<log_level>"
},
"newrelic" : {
"key" : "<newrelic_licence_key>"
"key": "<newrelic_licence_key>"
},
"rabbitmq" : {
"username" : "guest",
"password" : "guest",
"host" : "localhost"
}
}

0 comments on commit d24257b

Please sign in to comment.