githubbob42 / mingle2github2

0 stars 1 forks source link

create sync endpoint/websocket for sync #2204

Open githubbob42 opened 5 years ago

githubbob42 commented 5 years ago

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:

 // 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();

      });

    });

  });
githubbob42 commented 5 years ago

Story: #2196 User initiates a sync request on the client (Mingle)