Swarmlab docs

Application development in a distributed system

Development of Distributed Systems from Design to Application


You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

57 lines
956 B

= readmongo_service
== App
src: readmongo/swarmlab-app/src/run/
=== stream2mongo
[source,javascript]
----
async function onCollectionNew(err, collection) {
let options = {
tailable: true,
awaitdata: true,
numberOfRetries: -1,
tailableRetryInterval: 500,
};
var cursor = collection.find({}, options).stream();
var itemsProcessed = 0;
var room = this.user;
var sid = this.id;
console.log("Inside callback: " + room + " Id: " + sid);
var rep = setUser(sid, room);
cursor.on("data", async function (data) {
cursor.pause();
var res = await getkey(sid);
if (res == "1") {
cursor.resume();
var obj = JSON.parse(JSON.stringify(data));
io.in(room).emit("logsend", obj);
} else if (res == "2") {
cursor.resume();
console.log("Cursor is closing...");
cursor.close();
}
});
}
----
=== restart
To make changes become effective a restart is *not* required