Skip to content
Snippets Groups Projects

Update mongo driver and fix deprecations

Merged Ghost User requested to merge fix-deprecations into master
7 files
+ 28
18
Compare changes
  • Side-by-side
  • Inline
Files
7
@@ -20,16 +20,11 @@ const (
@@ -20,16 +20,11 @@ const (
// GetMongoConnection Retrieves a client to the MongoDB.
// GetMongoConnection Retrieves a client to the MongoDB.
func GetMongoConnection() (*mongo.Client, context.Context, context.CancelFunc) {
func GetMongoConnection() (*mongo.Client, context.Context, context.CancelFunc) {
mongoConnection := config.DatabaseConnection
mongoConnection := config.DatabaseConnection
client, err := mongo.NewClient(options.Client().ApplyURI(mongoConnection))
if err != nil {
log.Printf("Failed to create client: %v", err)
}
ctx, cancel := context.WithTimeout(context.Background(), connectTimeout*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), connectTimeout*time.Second)
err = client.Connect(ctx)
client, err := mongo.Connect(ctx, options.Client().ApplyURI(mongoConnection))
if err != nil {
if err != nil {
log.Printf("Failed to connect to cluster: %v", err)
log.Printf("Failed to create client: %v", err)
}
}
// Force a connection to verify our connection string
// Force a connection to verify our connection string
Loading