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

batch commands in 0.4.1 #75

Closed
afirstenberg opened this issue Aug 6, 2013 · 4 comments
Closed

batch commands in 0.4.1 #75

afirstenberg opened this issue Aug 6, 2013 · 4 comments
Assignees
Labels
🚨 This issue needs some love. triage me I really want to be triaged.

Comments

@afirstenberg
Copy link

Commands that are called using a direct command work, while using the same command with the batch commands fail.

For example, this function sets up a client mirror subscription command (in a module later required as "glass"):

exports.subscribeGlassCallbacksCmd = function( user ){
  var baseUrl = exports.BASE_URL;
  var subscribeUrl = baseUrl+"/incoming/callback";
  if( subscribeUrl.indexOf("http:") === 0 ){
    subscribeUrl = "https://mirrornotifications.appspot.com/forward?url="+subscribeUrl;
  }

  // Subscribe to updates from Glass
  var subscription = {
    collection: "timeline",
    callbackUrl: subscribeUrl,
    userToken: user.id
  };
  console.log( 'subscribeGlassCallbacksCmd', subscription );

  var cmd = client.mirror.subscriptions.insert(subscription);
  return cmd;
};

Calling it directly using these commands appear to work:

    var subc = glass.subscribeGlassCallbacksCmd(req.user);
    subc.withAuthClient(req.user.auth).execute(function(err,result){
      console.log( 'subc', err, result );
    });

err is null and result is set to the JSON representing the subscription:

subc null { kind: 'mirror#subscription',
  id: 'timeline',
  updated: '2013-08-06T11:33:56.772Z',
  collection: 'timeline',
  callbackUrl: 'https://prisoner.com/dev/glass-drive/incoming/callback',
  userToken: '101852559274654726533' }

Calling it using the following batch commands, however, don't:

    var batch = client.newBatchRequest();
    batch.add( glass.subscribeGlassCallbacksCmd(req.user) );
    batch.withAuthClient(req.user.auth).execute(cb);

the error that gets returned is

{ errors: 
   [ { domain: 'global',
       reason: 'required',
       message: 'collection field is required for Subscription' },
     { domain: 'global',
       reason: 'required',
       message: 'callbackUrl field is required for Subscription' } ],
  code: 400,
  message: 'collection field is required for Subscription' }

I've tried other combinations of the parameters to the call to list, but they don't appear to work any better.

@rakyll
Copy link
Contributor

rakyll commented Aug 6, 2013

@afirstenberg, batch is experimental at the moment is not faster than making individual requests alone. Could you use async.parallel or github.com/visionmedia/batch instead of clien'ts OData batch implementation while this is being fixed?

@afirstenberg
Copy link
Author

Yup, I'll probably be trying to implement it with async.parallel instead. I knew batch was a work in progress, but wanted to document the issue in case it helped document how to improve it.

@travischoma
Copy link

any progress on this issue?

@ryanseys
Copy link
Contributor

We've removed support for batch requests in version 1.0.0 so this is now a WONTFIX.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚨 This issue needs some love. triage me I really want to be triaged.
Projects
None yet
Development

No branches or pull requests

5 participants