Hi,
When I tried this plugin with mongodb it's started throwing error. When I debugged much further, I found out that there is problem how we are getting db
object in dbclient.js
. I am using mongodb connection URI without any authentication (e.g. mongodb://host/dbName).
Please note that MongoClient.connect API has been changed https://github.com/mongodb/node-mongodb-native/blob/master/CHANGES_3.0.0.md.
Here is existing code looks like
return MongoClient.connect(options.lock.url).then((db) => {
const leader = new MongoLeader.Leader(db, {
ttl: options.lock.ttl,
wait: options.lock.retry,
key: options.lock.key
});
I made quick fix that looked like this.
return MongoClient.connect(options.lock.url)
.then(client => client.db(options.lock.db))
.then((db) => {
console.log('dbclient', db);
const leader = new MongoLeader.Leader(db, {
ttl: options.lock.ttl,
wait: options.lock.retry,
key: options.lock.key
});
I have added db
option in plugin options.
I will raise a pull request, if you think this fix looks good.