Reputation: 63687
In the setup, Python writes to a database (mongo) every second and Meteor.js must react to the new record insertion immediately.
Problem: However using cursor.observe()
as shown below, the console outputs only 4-5 seconds after the new record has been inserted.
Question: Is it possible to increase the update frequency of cursor.observe
? If not, what will be an alternative?
server/news.js
var newsCursor = News.find({});
var newsHandle = newsCursor.observe({
added: function() {
console.log('New news added!');
}
});
Upvotes: 0
Views: 191
Reputation: 7680
Meteor's mongo-driver package makes cursors update immediately when changed from the mongo app. It also polls the database every 10 seconds to check for database changes from outside the meteor app, such as from your python code.
The smart collections atmosphere package is a simple rewrite which implements Mongo's oplog API, which allows the Meteor app to be immediately updated when the database is updated from outside the app. This is also important for scaling, because it allows multiple meteor processes to update the database and have those results immediately appear on other processes. By 1.0, Meteor will natively use the oplog. So until then, you need to use smart collections.
Upvotes: 1