@@ -2,17 +2,15 @@ package helpers
22
33import (
44 "github.com/joho/godotenv"
5- "github.com/siddontang/go-log/log"
65 "horgh-replicator/src/constants"
6+ "horgh-replicator/src/tools/exit"
77 "os"
88 "strconv"
99 "strings"
1010)
1111
1212type Credentials struct {
13- Type string
14- RetryTimeout int
15- RetryAttempts int
13+ Type string
1614}
1715
1816type CredentialsDB struct {
@@ -45,20 +43,13 @@ func MakeCredentials() {
4543 err := godotenv .Load ()
4644
4745 if err != nil {
48- log .Fatal ("Error loading .env file" )
46+ exit .Fatal ("Error loading .env file" )
4947 }
5048
51- var timeout , attempts int
52-
53- timeout , _ = strconv .Atoi (os .Getenv ("MASTER_RETRY_TIMEOUT" ))
54- attempts , _ = strconv .Atoi (os .Getenv ("MASTER_RETRY_ATTEMPTS" ))
55-
5649 masterPort , _ := strconv .Atoi (os .Getenv ("MASTER_PORT" ))
5750 master = CredentialsDB {
5851 Credentials {
5952 os .Getenv ("MASTER_TYPE" ),
60- timeout ,
61- attempts ,
6253 },
6354 os .Getenv ("MASTER_HOST" ),
6455 masterPort ,
@@ -67,14 +58,10 @@ func MakeCredentials() {
6758 os .Getenv ("MASTER_DBNAME" ),
6859 }
6960
70- timeout , _ = strconv .Atoi (os .Getenv ("REPLICATOR_RETRY_TIMEOUT" ))
71- attempts , _ = strconv .Atoi (os .Getenv ("REPLICATOR_RETRY_ATTEMPTS" ))
7261 replicationPort , _ := strconv .Atoi (os .Getenv ("REPLICATOR_PORT" ))
7362 replicator = CredentialsDB {
7463 Credentials {
7564 "mysql" ,
76- timeout ,
77- attempts ,
7865 },
7966 os .Getenv ("REPLICATOR_HOST" ),
8067 replicationPort ,
@@ -136,15 +123,11 @@ func GetMasterLogFilePrefix() string {
136123}
137124
138125func ParseDBConfig () {
139- timeout , _ := strconv .Atoi (os .Getenv ("SLAVE_RETRY_TIMEOUT" ))
140- attempts , _ := strconv .Atoi (os .Getenv ("SLAVE_RETRY_ATTEMPTS" ))
141126 slavePort , _ := strconv .Atoi (os .Getenv ("SLAVE_PORT" ))
142127
143128 slave = CredentialsDB {
144129 Credentials {
145130 os .Getenv ("SLAVE_TYPE" ),
146- timeout ,
147- attempts ,
148131 },
149132 os .Getenv ("SLAVE_HOST" ),
150133 slavePort ,
@@ -155,15 +138,11 @@ func ParseDBConfig() {
155138}
156139
157140func ParseAMQPConfig () {
158- timeout , _ := strconv .Atoi (os .Getenv ("SLAVE_RETRY_TIMEOUT" ))
159- attempts , _ := strconv .Atoi (os .Getenv ("SLAVE_RETRY_ATTEMPTS" ))
160141 slavePort , _ := strconv .Atoi (os .Getenv ("SLAVE_PORT" ))
161142
162143 slave = CredentialsAMQP {
163144 Credentials {
164145 os .Getenv ("SLAVE_TYPE" ),
165- timeout ,
166- attempts ,
167146 },
168147 os .Getenv ("SLAVE_HOST" ),
169148 slavePort ,
0 commit comments