mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-03 02:42:19 +08:00
fix: import the enough param
This commit is contained in:
parent
cd3a564477
commit
8963d3ba9b
@ -38,7 +38,8 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Mongo struct {
|
type Mongo struct {
|
||||||
db *mongo.Client
|
db *mongo.Client
|
||||||
|
config *config.GlobalConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewMongo Initialize MongoDB connection.
|
// NewMongo Initialize MongoDB connection.
|
||||||
@ -58,7 +59,7 @@ func NewMongo(config *config.GlobalConfig) (*Mongo, error) {
|
|||||||
if err = mongoClient.Ping(ctx, nil); err != nil {
|
if err = mongoClient.Ping(ctx, nil); err != nil {
|
||||||
return nil, errs.Wrap(err, uri)
|
return nil, errs.Wrap(err, uri)
|
||||||
}
|
}
|
||||||
return &Mongo{db: mongoClient}, nil
|
return &Mongo{db: mongoClient, config: config}, nil
|
||||||
}
|
}
|
||||||
if shouldRetry(err) {
|
if shouldRetry(err) {
|
||||||
time.Sleep(time.Second) // exponential backoff could be implemented here
|
time.Sleep(time.Second) // exponential backoff could be implemented here
|
||||||
@ -135,7 +136,7 @@ func (m *Mongo) CreateMsgIndex() error {
|
|||||||
|
|
||||||
// createMongoIndex creates an index in a MongoDB collection.
|
// createMongoIndex creates an index in a MongoDB collection.
|
||||||
func (m *Mongo) createMongoIndex(collection string, isUnique bool, keys ...string) error {
|
func (m *Mongo) createMongoIndex(collection string, isUnique bool, keys ...string) error {
|
||||||
db := m.GetDatabase().Collection(collection)
|
db := m.GetDatabase(m.config.Mongo.Database).Collection(collection)
|
||||||
opts := options.CreateIndexes().SetMaxTime(10 * time.Second)
|
opts := options.CreateIndexes().SetMaxTime(10 * time.Second)
|
||||||
indexView := db.Indexes()
|
indexView := db.Indexes()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user