Merge branch 'devel' into oplog

Conflicts:
	packages/application-configuration/config.js
	packages/minimongo/minimongo.js
This commit is contained in:
David Glasser
2013-12-03 15:01:37 -08:00
2 changed files with 31 additions and 25 deletions

View File

@@ -59,9 +59,6 @@ try {
'mongo-livedata': {
url: process.env.MONGO_URL,
oplog: process.env.MONGO_OPLOG_URL
},
'email': {
url: process.env.MAIL_URL
}
}
};
@@ -84,10 +81,13 @@ AppConfig.getAppConfig = function () {
AppConfig.configurePackage = function (packageName, configure) {
var appConfig = AppConfig.getAppConfig(); // Will either be based in the env var,
// or wait for galaxy to connect.
var lastConfig = appConfig && appConfig.packages && appConfig.packages[packageName];
if (lastConfig) {
configure(lastConfig);
}
var lastConfig =
(appConfig && appConfig.packages && appConfig.packages[packageName]) || {};
// Always call the configure callback "soon" even if the initial configuration
// is empty (synchronously, though deferred would be OK).
// XXX make sure that all callers of configurePackage deal well with multiple
// callback invocations! eg, email does not
configure(lastConfig);
var configureIfDifferent = function (app) {
if (!EJSON.equals(app.config && app.config.packages && app.config.packages[packageName],
lastConfig)) {

View File

@@ -33,19 +33,26 @@ var makePool = function (mailUrlString) {
// We construct smtpPool at the first call to Email.send, so that
// Meteor.startup code can set $MAIL_URL.
var smtpPool = null;
var maybeMakePool = function () {
// We check MAIL_URL in case someone else set it in Meteor.startup code.
var poolFuture = new Future();
AppConfig.configurePackage('email', function (config) {
// TODO: allow reconfiguration.
if (!smtpPool && (config.url || process.env.MAIL_URL)) {
smtpPool = makePool(config.url || process.env.MAIL_URL);
}
poolFuture.return();
});
var smtpPoolFuture = new Future;;
var configured = false;
poolFuture.wait();
var getPool = function () {
// We check MAIL_URL in case someone else set it in Meteor.startup code.
if (!configured) {
configured = true;
AppConfig.configurePackage('email', function (config) {
// XXX allow reconfiguration when the app config changes
if (smtpPoolFuture.isResolved())
return;
var url = config.url || process.env.MAIL_URL;
var pool = null;
if (url)
pool = makePool(url);
smtpPoolFuture.return(pool);
});
}
return smtpPoolFuture.wait();
};
var next_devmode_mail_id = 0;
@@ -81,8 +88,8 @@ var devModeSend = function (mc) {
future.wait();
};
var smtpSend = function (mc) {
smtpPool._future_wrapped_sendMail(mc).wait();
var smtpSend = function (pool, mc) {
pool._future_wrapped_sendMail(mc).wait();
};
/**
@@ -141,10 +148,9 @@ Email.send = function (options) {
mc.addHeader(name, value);
});
maybeMakePool();
if (smtpPool) {
smtpSend(mc);
var pool = getPool();
if (pool) {
smtpSend(pool, mc);
} else {
devModeSend(mc);
}