aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjloup <jeanloup.jamet@gmail.com>2018-05-04 18:19:52 +0200
committerjloup <jeanloup.jamet@gmail.com>2018-05-04 18:19:52 +0200
commit69db77ca4054d80ba2156b774a0c1467ff661c81 (patch)
treeeae1b0f6d5aa421ae1b0125a7884f811c0a2acc6
parent35e1f63a03a1cf55fe72839523790d38c0cea21b (diff)
downloadFront-69db77ca4054d80ba2156b774a0c1467ff661c81.tar.gz
Front-69db77ca4054d80ba2156b774a0c1467ff661c81.tar.zst
Front-69db77ca4054d80ba2156b774a0c1467ff661c81.zip
Allow to configure the type of Postgres connection (tcp or unix).
-rw-r--r--cmd/ansible/conf.toml.j23
-rw-r--r--cmd/app/conf.toml3
-rw-r--r--db/db.go2
3 files changed, 6 insertions, 2 deletions
diff --git a/cmd/ansible/conf.toml.j2 b/cmd/ansible/conf.toml.j2
index 7c82f84..cddc257 100644
--- a/cmd/ansible/conf.toml.j2
+++ b/cmd/ansible/conf.toml.j2
@@ -7,10 +7,11 @@ port="8080"
7user="{{ postgres_user }}" 7user="{{ postgres_user }}"
8password="{{ postgres_password }}" 8password="{{ postgres_password }}"
9database="{{ postgres_database }}" 9database="{{ postgres_database }}"
10type="{{ postgres_connection_type }}" # tcp or unix
10address="localhost:5432" 11address="localhost:5432"
11 12
12[redis] 13[redis]
13type="{{ redis_adress_type }}" 14type="{{ redis_adress_type }}" # tcp or unix
14address="localhost:6379" 15address="localhost:6379"
15database=0 16database=0
16 17
diff --git a/cmd/app/conf.toml b/cmd/app/conf.toml
index 16087e5..847a075 100644
--- a/cmd/app/conf.toml
+++ b/cmd/app/conf.toml
@@ -6,10 +6,11 @@ log_out="stdout"
6user="cryptoportfolio" 6user="cryptoportfolio"
7password="cryptoportfolio-dev" 7password="cryptoportfolio-dev"
8database="cryptoportfolio" 8database="cryptoportfolio"
9type="tcp" # tcp or unix
9address="localhost:5432" 10address="localhost:5432"
10 11
11[redis] 12[redis]
12type="tcp" 13type="tcp" # tcp or unix
13address="cryptoportfolio.immae.eu:7617" 14address="cryptoportfolio.immae.eu:7617"
14database=0 15database=0
15 16
diff --git a/db/db.go b/db/db.go
index 2596dcb..25d404f 100644
--- a/db/db.go
+++ b/db/db.go
@@ -16,6 +16,7 @@ var (
16) 16)
17 17
18type DBConfig struct { 18type DBConfig struct {
19 Type string // tcp or unix
19 Address string 20 Address string
20 Database string 21 Database string
21 User string 22 User string
@@ -109,6 +110,7 @@ func connect(config DBConfig) *pg.DB {
109 User: config.User, 110 User: config.User,
110 Password: config.Password, 111 Password: config.Password,
111 Database: config.Database, 112 Database: config.Database,
113 Network: config.Type,
112 Addr: config.Address, 114 Addr: config.Address,
113 }) 115 })
114} 116}