Skip to content

Commit de07d52

Browse files
authored
Merge pull request #255 from tysonrm/main
Revert "Update datasource-mongodb.js"
2 parents 206c9bc + 753d4c0 commit de07d52

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

src/adapters/datasources/datasource-mongodb.js

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class DataSourceMongoDb extends DataSource {
7272
})
7373
}
7474

75-
async connection({ rotate = true }) {
75+
async connection() {
7676
try {
7777
while (connections.length < (dsOptions.numConns || 1)) {
7878
const client = new MongoClient(this.url, this.mongoOpts)
@@ -82,8 +82,8 @@ export class DataSourceMongoDb extends DataSource {
8282
callVolume: 1,
8383
intervalMs: 10000,
8484
testDelay: 300000,
85-
fallbackFn: () => client.emit('connectionClosed')
86-
}
85+
//fallbackFn: () => client.emit('connectionClosed')
86+
},
8787
}
8888
const breaker = CircuitBreaker(
8989
'mongodb.connect',
@@ -96,22 +96,17 @@ export class DataSourceMongoDb extends DataSource {
9696
connections.splice(connections.indexOf(client), 1)
9797
)
9898
}
99-
let client
100-
if (rotate) {
101-
client = connections.shift()
102-
connections.push(client)
103-
} else {
104-
client = connections[0]
105-
}
99+
const client = connections.shift()
100+
connections.push(client)
106101
return client
107102
} catch (error) {
108103
console.error({ fn: this.connection.name, error })
109104
}
110105
}
111106

112-
async collection(options) {
107+
async collection() {
113108
try {
114-
return (await this.connection(options)).db(this.namespace).collection(this.name)
109+
return (await this.connection()).db(this.namespace).collection(this.name)
115110
} catch {}
116111
}
117112

@@ -173,7 +168,7 @@ export class DataSourceMongoDb extends DataSource {
173168

174169
if (operations.length > 0) {
175170
try {
176-
const col = await ctx.collection({ rotate: false })
171+
const col = await ctx.collection()
177172
const result = await col.bulkWrite(operations)
178173
console.log(result.getRawResponse())
179174
objects = []

0 commit comments

Comments
 (0)