Skip to content

Commit

Permalink
Replace NewClient with mongo.Connect
Browse files Browse the repository at this point in the history
  • Loading branch information
gaby authored Nov 16, 2023
1 parent 4b89c87 commit 9190b12
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Golangci Lint Check
name: Golangci-Lint Check

on:
push:
Expand Down Expand Up @@ -32,7 +32,7 @@ jobs:
DIRECTORIES=$(find . -type d -not -path '*/\.*' | jq -R -s -c 'split("\n")[:-1]')
echo "matrix=${DIRECTORIES}" >> $GITHUB_OUTPUT
golangci-lint:
lint:
needs: generate-matrix
runs-on: ubuntu-latest
strategy:
Expand Down
10 changes: 6 additions & 4 deletions mongodb/mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ func New(config ...Config) *Storage {
}

// Set mongo options
opt := options.Client()
opt.ApplyURI(dsn)
opt := options.Client().ApplyURI(dsn)

// Create mongo client
client, err := mongo.NewClient(opt)
// Create and connect the mongo client in one step
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
defer cancel()

client, err := mongo.Connect(ctx, opt)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit 9190b12

Please sign in to comment.