mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Refactor MongoConnection options: oplogUrl, not isOplog
Move hacky use of env var to a slightly more appropriate place
This commit is contained in:
@@ -149,12 +149,11 @@ MongoConnection = function (url, options) {
|
||||
|
||||
self._docFetcher = new DocFetcher(self);
|
||||
self._oplogHandle = null;
|
||||
// XXX we should NOT be reading directly from the env here (this should be an
|
||||
// argument to MongoConnection eg) but I want to wait for the AppConfig API to
|
||||
// settle a little before thinking too hard about this
|
||||
if (process.env.XXX_OPLOG_URL && !options.isOplog) {
|
||||
|
||||
if (options.oplogUrl) {
|
||||
// XXX this parse fails on mongo URLs with commas!
|
||||
var dbName = Npm.require('url').parse(url).pathname.substr(1);
|
||||
self._startOplogTailing(process.env.XXX_OPLOG_URL, dbName);
|
||||
self._startOplogTailing(options.oplogUrl, dbName);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -295,7 +294,7 @@ MongoConnection.prototype._startOplogTailing = function (oplogUrl, dbName) {
|
||||
|
||||
// Actually setting up the connection and tail blocks, so we do it "later".
|
||||
Meteor.defer(function () {
|
||||
var oplogConnection = new MongoConnection(oplogUrl, {isOplog: true});
|
||||
var oplogConnection = new MongoConnection(oplogUrl);
|
||||
|
||||
// Find the last oplog entry. Blocks until the connection is ready.
|
||||
var lastOplogEntry = oplogConnection.findOne(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
MongoInternals.RemoteCollectionDriver = function (mongo_url) {
|
||||
MongoInternals.RemoteCollectionDriver = function (
|
||||
mongo_url, options) {
|
||||
var self = this;
|
||||
self.mongo = new MongoConnection(mongo_url);
|
||||
self.mongo = new MongoConnection(mongo_url, options);
|
||||
};
|
||||
|
||||
_.extend(MongoInternals.RemoteCollectionDriver.prototype, {
|
||||
@@ -32,5 +33,11 @@ MongoInternals.defaultRemoteCollectionDriver = _.once(function () {
|
||||
if (! mongoUrl)
|
||||
throw new Error("MONGO_URL must be set in environment");
|
||||
|
||||
return new MongoInternals.RemoteCollectionDriver(mongoUrl);
|
||||
var connectionOptions = {};
|
||||
// XXX we should NOT be reading directly from the env here; need to consult
|
||||
// with naomi re: AppConfig
|
||||
if (process.env.XXX_OPLOG_URL)
|
||||
connectionOptions.oplogUrl = process.env.XXX_OPLOG_URL;
|
||||
|
||||
return new MongoInternals.RemoteCollectionDriver(mongoUrl, connectionOptions);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user