Skip to content

Commit

Permalink
Merge pull request #18 from Talento90/feature-redis-config
Browse files Browse the repository at this point in the history
Feature redis config
  • Loading branch information
Talento90 authored Feb 1, 2019
2 parents ccedd6b + 47519ec commit c85978a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ clean:

.PHONY: deps
deps:
go mod download
go get github.com/golang/lint/golint
go get honnef.co/go/tools/cmd/megacheck
go get github.com/fzipp/gocyclo
Expand Down
12 changes: 6 additions & 6 deletions config/config_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package config

import (
"os"
"strconv"
"time"

goredis "github.com/go-redis/redis"
"github.com/talento90/imgart/httpapi"
"github.com/talento90/imgart/log"
"github.com/talento90/imgart/repository/mongo"
Expand Down Expand Up @@ -44,16 +44,16 @@ func GetMongoConfiguration() (mongo.Configuration, error) {

// GetRedisConfiguration returns the redis configuration
func GetRedisConfiguration() (redis.Configuration, error) {
db, err := strconv.Atoi(getEnv("REDIS_SERVICE_DB", "0"))
db, err := goredis.ParseURL(getEnv("REDIS_URL", "localhost:6379"))

if err != nil {
db = 0
return redis.Configuration{}, err
}

config := redis.Configuration{
Address: getEnv("REDIS_URL", "localhost:6379"),
Password: getEnv("REDIS_PASSWORD", ""),
Database: db,
Address: db.Addr,
Password: db.Password,
Database: db.DB,
}

return config, config.Validate()
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
ports:
- "4005:4005"
environment:
- REDIS_URL=redis-db:6379
- REDIS_URL=redis://redis-db:6379/0
- MONGO_URL=mongo-db:27017
command: ["gin", "-d", "/go/src/github.com/talento90/imgart/cmd/imgartapi/", "-p", "4005", "-i"]
volumes:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ require (
github.com/sirupsen/logrus v1.1.0
github.com/talento90/go-health v0.2.0
golang.org/x/crypto v0.0.0-20180927165925-5295e8364332 // indirect
golang.org/x/image v0.0.0-20180926015637-991ec62608f3
golang.org/x/image v0.0.0-20190118043309-183bebdce1b2
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7 // indirect
golang.org/x/net v0.0.0-20180926154720-4dfa2610cdf3 // indirect
golang.org/x/sys v0.0.0-20180927150500-dad3d9fb7b6e // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ golang.org/x/crypto v0.0.0-20180927165925-5295e8364332 h1:hvQVdF6P9DX4OiKA5tpehl
golang.org/x/crypto v0.0.0-20180927165925-5295e8364332/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/image v0.0.0-20180926015637-991ec62608f3 h1:5IfA9fqItkh2alJW94tvQk+6+RF9MW2q9DzwE8DBddQ=
golang.org/x/image v0.0.0-20180926015637-991ec62608f3/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
golang.org/x/image v0.0.0-20190118043309-183bebdce1b2 h1:FNSSV4jv1PrPsiM2iKGpqLPPgYACqh9Muav7Pollk1k=
golang.org/x/image v0.0.0-20190118043309-183bebdce1b2/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7 h1:00BeQWmeaGazuOrq8Q5K5d3/cHaGuFrZzpaHBXfrsUA=
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down

0 comments on commit c85978a

Please sign in to comment.