/
allSystem.go
43 lines (36 loc) · 984 Bytes
/
allSystem.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package database
// this file is used for combining all the connection from different database system
//we create different types of databse connection here
func SystemConnection() map[string]interface{} {
listConnection := make(map[string]interface{})
var err error
// create redis connection
redisConn := RedisHost{
Address: "localhost:6379",
Password: "",
DB: 0,
}
redisConnection, err := redisConn.Connect()
if err != nil {
panic(err)
}
// create postgre connection
postgreConn := PostgreHost{
Driver: "postgres",
Database: "postgres",
Username: "postgres",
Ssl: "disable",
Password: "root",
}
postgreConnection := GetPostgreDb(&postgreConn)
//create mongodb connection
mongo := MongoHost{
Host: "127.0.0.1",
Port: "27017",
}
mongoConnection := mongo.Connect()
listConnection["redis"] = redisConnection
listConnection["postgre"] = postgreConnection
listConnection["mongodb"] = mongoConnection
return listConnection
}