-
Notifications
You must be signed in to change notification settings - Fork 618
compute onComplete example should show "the right way" to attach handlers? #921
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
Comments
If we actually want to support "wait until it's done no matter what", we can maybe just say "pass maxAttempts: 0", which we can change our code to treat as "infinite"? |
I think both are good things to do... It seems kind of weird that we have a handler called |
The error should really be considered as "OPERATION_DID_NOT_COMPLETE_WITHIN_ALLOWED_TIME". The concept of how the method works, re: attempts/being called with an error, is explained in the method description:
That makes sense, but I think we'd hear from developers saying "I need to know when all attempts are exhausted"-- it's just a way to give control/progress updates back to the user. Supporting "call only when it's complete" would be ideal, but since it can be error-prone to implement-- I think the easiest thing to do is what you originally wanted (:smile:); I'll just send a PR showing how to call // @callmehiphop if you have any thoughts on how this should work. |
Shouldn't that be |
That's interesting... we could turn it into a true event emitter: zone.createVM(function(err, vm, operation) {
operation
.on('complete', function(metadata) {})
.on('error', function(err) {})
.on('timeout', function() {
if (something) {
this.startPolling(); // start again
}
});
operation.startPolling([options]);
}); |
+1 to that.
|
I agree, a real event emitter would be much nicer imo |
On https://googlecloudplatform.github.io/gcloud-node/#/docs/v0.24.1/compute/operation?method=onComplete
This example doesn't really show me how I'm supposed to continue attaching handlers (and I would actually need to redesign the flow of my code to make this work).
Can we update the example to show exactly what "the right way" to do this is?
The text was updated successfully, but these errors were encountered: