Commit d4c5b841 authored by Timo Bechtel's avatar Timo Bechtel
Browse files

refactor(db): refactor db to directly connect to db

parent 4d86a60d
Pipeline #1811 failed with stages
in 57 seconds
......@@ -17,14 +17,10 @@ func CreateDBClient(timeout time.Duration) (client *mongo.Client, ctx context.Co
mongoURL := GetEnv("MONGO_URL", "mongodb://127.0.0.1:27017")
client, err := mongo.NewClient(options.Client().ApplyURI(mongoURL))
if err != nil {
log.Fatal(err)
}
ctx, cancel := CreateTimeoutCTX(timeout)
defer cancel()
err = client.Connect(ctx)
client, err := mongo.Connect(ctx, options.Client().ApplyURI(mongoURL))
if err != nil {
log.Fatal("[MONGODB] timeout ", err)
}
......@@ -34,7 +30,6 @@ func CreateDBClient(timeout time.Duration) (client *mongo.Client, ctx context.Co
if err != nil {
log.Fatal(err)
} else {
log.Println("[MONGODB] connected")
databases, err := client.ListDatabaseNames(ctx, bson.M{})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment