diff options
author | jloup <jeanloup.jamet@gmail.com> | 2018-05-04 18:19:52 +0200 |
---|---|---|
committer | jloup <jeanloup.jamet@gmail.com> | 2018-05-04 18:19:52 +0200 |
commit | 69db77ca4054d80ba2156b774a0c1467ff661c81 (patch) | |
tree | eae1b0f6d5aa421ae1b0125a7884f811c0a2acc6 | |
parent | 35e1f63a03a1cf55fe72839523790d38c0cea21b (diff) | |
download | Front-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.j2 | 3 | ||||
-rw-r--r-- | cmd/app/conf.toml | 3 | ||||
-rw-r--r-- | db/db.go | 2 |
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" | |||
7 | user="{{ postgres_user }}" | 7 | user="{{ postgres_user }}" |
8 | password="{{ postgres_password }}" | 8 | password="{{ postgres_password }}" |
9 | database="{{ postgres_database }}" | 9 | database="{{ postgres_database }}" |
10 | type="{{ postgres_connection_type }}" # tcp or unix | ||
10 | address="localhost:5432" | 11 | address="localhost:5432" |
11 | 12 | ||
12 | [redis] | 13 | [redis] |
13 | type="{{ redis_adress_type }}" | 14 | type="{{ redis_adress_type }}" # tcp or unix |
14 | address="localhost:6379" | 15 | address="localhost:6379" |
15 | database=0 | 16 | database=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" | |||
6 | user="cryptoportfolio" | 6 | user="cryptoportfolio" |
7 | password="cryptoportfolio-dev" | 7 | password="cryptoportfolio-dev" |
8 | database="cryptoportfolio" | 8 | database="cryptoportfolio" |
9 | type="tcp" # tcp or unix | ||
9 | address="localhost:5432" | 10 | address="localhost:5432" |
10 | 11 | ||
11 | [redis] | 12 | [redis] |
12 | type="tcp" | 13 | type="tcp" # tcp or unix |
13 | address="cryptoportfolio.immae.eu:7617" | 14 | address="cryptoportfolio.immae.eu:7617" |
14 | database=0 | 15 | database=0 |
15 | 16 | ||
@@ -16,6 +16,7 @@ var ( | |||
16 | ) | 16 | ) |
17 | 17 | ||
18 | type DBConfig struct { | 18 | type 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 | } |