Skip to content

Commit

Permalink
Accept Redis db variable
Browse files Browse the repository at this point in the history
  • Loading branch information
henrod committed May 29, 2017
1 parent 5372d7e commit 3de446f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ENV MQTTHISTORY_ELASTICSEARCH_SNIFF false

ENV MQTTHISTORY_REDIS_HOST localhost
ENV MQTTHISTORY_REDIS_PORT 6379
ENV MQTTHISTORY_REDIS_DB 0
ENV MQTTHISTORY_API_TLS false
ENV MQTTHISTORY_API_CERTFILE ./misc/example.crt
ENV MQTTHISTORY_API_KEYFILE ./misc/example.key
Expand Down
1 change: 1 addition & 0 deletions config/local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ redis:
port: 4444
password: ""
maxPoolSize: 10
db: 0
logger:
level: "debug"
1 change: 1 addition & 0 deletions config/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ redis:
port: 4444
password: ""
maxPoolSize: 10
db: 0
logger:
level: "debug"
4 changes: 2 additions & 2 deletions redisclient/redisclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ func GetRedisClient(redisHost string, redisPort int, redisPass string) *RedisCli
client.Pool = redis.NewPool(func() (redis.Conn, error) {
if viper.GetString("redis.password") != "" {
c, err := redis.Dial("tcp", fmt.Sprintf("%s:%d", viper.GetString("redis.host"),
viper.GetInt("redis.port")), redis.DialPassword(viper.GetString("redis.password")))
viper.GetInt("redis.port")), redis.DialPassword(viper.GetString("redis.password")), redis.DialDatabase(viper.GetInt("redis.db")))
if err != nil {
logger.Logger.Error(err.Error())
}
return c, err
}
c, err := redis.Dial("tcp", redisAddress)
c, err := redis.Dial("tcp", redisAddress, redis.DialDatabase(viper.GetInt("redis.db")))
if err != nil {
if err != nil {
logger.Logger.Error(err.Error())
Expand Down

0 comments on commit 3de446f

Please sign in to comment.