Skip to content

Commit

Permalink
Merge pull request #219 from agco/remove-mongojs-from-eventsreader
Browse files Browse the repository at this point in the history
Use mongoose in events reader
  • Loading branch information
Juraci authored May 25, 2017
2 parents 9b04591 + cd00fd6 commit 038b8e8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/events-reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ let _ = require('lodash'),
Promise = require('bluebird'),
debug = require('debug')('events-reader'),
BSON = require('mongodb').BSONPure,
mongojs = require('mongojs'),
hl = require('highland'),
checkpointWriter = require('./events-reader-checkpoint-writer'),
Joi = require('joi');

const mongoose = require('mongoose');

module.exports = function(harvesterApp) {

return function(oplogMongodbUri) {
Expand All @@ -21,7 +22,9 @@ module.exports = function(harvesterApp) {
"d": 'delete'
};

var db = mongojs(oplogMongodbUri, ['oplog.rs'], {poolSize: 10, socketOptions: {keepAlive: 250}});
mongoose.connect(oplogMongodbUri, {poolSize: 10, socketOptions: {keepAlive: 250}})
.then(() => console.log('EventsReader connected to oplog'))
.catch((err) => console.log(err));

var docStream = hl();

Expand Down Expand Up @@ -99,9 +102,7 @@ module.exports = function(harvesterApp) {

time = {$gt: since};
query.ts = time;

return db.oplog.rs.find(query, options);

return mongoose.connection.db.collection('oplog.rs').find(query,options);
};

EventsReader.prototype.processDocHandlers = function(doc) {
Expand Down

0 comments on commit 038b8e8

Please sign in to comment.