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

draft: Support operations for compute v2 with Reflection #570

Closed
wants to merge 4 commits into from

Conversation

bshaffer
Copy link
Contributor

@bshaffer bshaffer commented May 20, 2024

Alternative implementation to #569 which uses ReflectionMethod instead of Request class configuration

Pros

  • does not require a change to the existing longRunning descriptors
  • fixing LRO for Compute does not require regenerating and re-releasing the compute client

Cons

  • Uses ReflectionMethod to determine first argument Request class

Alternatives Considered
We could add the options getRequestClass, cancelRequestClass, and deleteRequestClass to the descriptors via gapic-generator-php, which would be more efficient (no calls to ReflectionMethod) and better. See #569 and googleapis/gapic-generator-php#712

$args = array_merge([$firstArgument], $this->additionalArgs);
$args = array_merge([$this->getName()], array_values($this->additionalArgs));
if ($requestClass) {
$request = call_user_func_array($requestClass . '::build', $args);
Copy link
Contributor

Choose a reason for hiding this comment

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

This assumes the request class has a builder method generated from the google.api.method_signature, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it does! And I've confirmed all our existing Request classes have this. However, if something were introduced which didn't support this (or someone supplied the wrong Request class), this would throw a PHP Fatal Error.

it may be a good idea to add an exception here when build doesn't exist on the request class, rather than potentially throwing a PHP fatal error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 66e4a77 (for the other PR)

@bshaffer
Copy link
Contributor Author

Closing because I don't like this option

@bshaffer bshaffer closed this May 22, 2024
@bshaffer bshaffer deleted the support-operations-for-compute-v2-reflection branch May 22, 2024 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants