Create a new sync endpoint (or websocket) for initializing long-running sync downloads. The endpoint itself will not perform any of the interaction with SFDC - it should simply insert a sync request into a queue for later processing.
The sync request should contain:
oauth token (which contains the user id and org id)
timestamp when the sync request was made
correlation id (perhaps the socket id if using web sockets) to coordinate the response with the original request (or with the original websocket)
// when a connection to the client is made
io.on('connection', function (socket) {
// subscribe to the client syncing
socket.on('SYNC\_GET', function(data, ack) {
var session \= socket.handshake.session,
oauth \= session.oauth;
// add the sync request to the queue
queue.add({ oauth: oauth, timestamp: new Date(), correlationId: socket.id }, function(err, id) {
// notify the client of any errors adding to the queue so they can try again
if(err) socket.emit('status', { error: err });
// when the item is safely in the queue, notify the client
if(ack && !err) ack();
});
});
});
Mingle Card: 2447 See #2439 for story details.
Task
Create a new sync endpoint (or websocket) for initializing long-running sync downloads. The endpoint itself will not perform any of the interaction with SFDC - it should simply insert a sync request into a queue for later processing.
The sync request should contain:
Using socket.io and mongodb-queue, this might look like this: