From 69db77ca4054d80ba2156b774a0c1467ff661c81 Mon Sep 17 00:00:00 2001 From: jloup Date: Fri, 4 May 2018 18:19:52 +0200 Subject: [PATCH] Allow to configure the type of Postgres connection (tcp or unix). --- cmd/ansible/conf.toml.j2 | 3 ++- cmd/app/conf.toml | 3 ++- 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" user="{{ postgres_user }}" password="{{ postgres_password }}" database="{{ postgres_database }}" +type="{{ postgres_connection_type }}" # tcp or unix address="localhost:5432" [redis] -type="{{ redis_adress_type }}" +type="{{ redis_adress_type }}" # tcp or unix address="localhost:6379" database=0 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" user="cryptoportfolio" password="cryptoportfolio-dev" database="cryptoportfolio" +type="tcp" # tcp or unix address="localhost:5432" [redis] -type="tcp" +type="tcp" # tcp or unix address="cryptoportfolio.immae.eu:7617" database=0 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 ( ) type DBConfig struct { + Type string // tcp or unix Address string Database string User string @@ -109,6 +110,7 @@ func connect(config DBConfig) *pg.DB { User: config.User, Password: config.Password, Database: config.Database, + Network: config.Type, Addr: config.Address, }) } -- 2.41.0