我正在使用 angular-meteor 编写一个约会安排应用程序。其中一项要求是向预约的客户发送短信通知。客户提供手机号码。但基本上,我想做的就是在预约时间前 X 分钟发送一封电子邮件。运行 Angular meteor 堆栈,最好的方法是什么?所有预约信息都保存到 mongo 数据库中。
最佳答案
您可能对 Meteor job-collection 感兴趣包(不特定于 angle-meteor):
A persistent and reactive job queue for Meteor, supporting distributed workers that can run anywhere.
job-collection is a powerful and easy to use job manager designed and built for Meteor.js.
It solves the following problems (and more):
- Schedule jobs to run (and repeat) in the future, persisting across server restarts
- […]
特别是job.after(someTimeBeforeAppointment)
// Server
var myJobs = JobCollection('myJobQueue');
// Start the myJobs queue running
myJobs.startJobServer();
// Create a Job (e.g. in a Meteor method)
var job = new Job(myJobs, 'jobType', jobData);
// Specify when it can run and save it.
job.after(someTimeBeforeAppointment).save();
// Server (or could be a different server!)
// How jobs should be processed.
myJobs.processJobs('jobType', function (job, done) {
var jobData = job.data;
// Do something… could be asynchronous.
job.done(); // or job.fail();
// Call done when work on this job has finished.
done();
});
可以在 processJobs
options 中指定 pollInterval
。默认为每 5 秒一次。
关于node.js - 使用 Angular-Meteor 运行预定作业的最理想方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43481842/