gax-nodejs
gax-nodejs copied to clipboard
feat: support Diregapic long running operation
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.
Thanks @summer-ji-eng, it looks great! Left some comments, mostly style+readability. I'll defer reviewing the DIREGAPIC-specific logic to @vam-google.