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

feat: support Diregapic long running operation #1119

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

summer-ji-eng
Copy link
Contributor

@summer-ji-eng summer-ji-eng commented Sep 30, 2021

Before the implementation, diregapic LRO return unary with compute.v1.Operation. It require manual code to poll the operation until it finish.

async function waitGlobalOperation(operation, project) {
  const globalClient = new compute.GlobalOperationsClient({fallback: 'rest'});
  for (;;) {
    const [getResp] = await globalClient.get({
      project,
      operation: operation.name,
    });
    if (getResp.status === 'DONE') {
      break;
    } else {
      await new Promise(resolve => setTimeout(resolve, 4000));
    }
  }
}

After, the sample code to call insert LRO method

const [operation] = await client.insert({
    project,
    firewallResource: resource,
  });
  const [response, metadata, third] = await operation.promise();
  console.log(response.status === 'DONE') --------> output: true;

It support Compute 4 operation polling service:
GlobalOperations
RegionOperations
ZonalOperations
GlobalOrganizationOperations

This version is not support dynamic diregapic lro, will modify with gapic-generator-typescript recognize diregapic LRO with annotation.

@summer-ji-eng summer-ji-eng requested a review from a team as a code owner September 30, 2021 21:46
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Sep 30, 2021
): void;
}

// TODO(summerji): check with Vadym the error compose;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving a comment to make sure this does not get checked in :)

}
}

_isComputeOperationDone(op: ComputeLROOperation): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method should either be static or be defined outside of the class since it never accesses this.

@@ -129,13 +160,14 @@ export class Operation extends EventEmitter {
* request.
*/
cancel() {
if (this.currentCallPromise_) {
this.currentCallPromise_.cancel();
if (!this.diregapic && this.currentCallPromise_) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe there is no cancellation for diregapic. Can we just throw?

if (this.diregapic) { 
  throw new Error("Cancellation is not supported for this method");
}

@vam-google what do you think?

// Polling request require fields has been checked in the LRO method before
// operation.promise() has been called. Transcoding will throw error if any required
// fields missing.
_composeComputeRequest(): ComputeOperationRequest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summoning @vam-google to check the logic of this method.

@@ -698,3 +773,512 @@ describe('longrunning', () => {
});
});
});

describe('diregapic longrunning', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I ask you to move this to a separate file? 1000+ lines is a lot :) This will also simplify all the test initialization code since you won't need to do if (diregapic) in it.

@alexander-fenster
Copy link
Contributor

alexander-fenster commented Oct 1, 2021

Thanks @summer-ji-eng, it looks great! Left some comments, mostly style+readability. I'll defer reviewing the DIREGAPIC-specific logic to @vam-google.

@bcoe bcoe added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Feb 4, 2022
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Feb 4, 2022
@bcoe bcoe added the kokoro:run Add this label to force Kokoro to re-run the tests. label Feb 4, 2022
@yoshi-kokoro yoshi-kokoro removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Feb 13, 2022
@product-auto-label product-auto-label bot added the size: l Pull request size is large. label Jun 13, 2022
@alexander-fenster alexander-fenster added kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Jun 14, 2022
@yoshi-kokoro yoshi-kokoro removed kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Jun 14, 2022
@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. and removed size: l Pull request size is large. labels Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement. size: xl Pull request size is extra large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants