Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create sync endpoint/websocket for sync #2204

Open
githubbob42 opened this issue May 4, 2019 · 1 comment
Open

create sync endpoint/websocket for sync #2204

githubbob42 opened this issue May 4, 2019 · 1 comment
Labels

Comments

@githubbob42
Copy link
Owner

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:

  • 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)

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
Copy link
Owner Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant