Skip to content

feat(Gax)!: refactor OperationResponse with OperationsClientInterface and CustomOperationsClient - #9753

Open
bshaffer wants to merge 14 commits into
gax-v2-client-optionsfrom
gax-v2-operation-response
Open

bshaffer wants to merge 14 commits into
gax-v2-client-optionsfrom
gax-v2-operation-response

Conversation

@bshaffer

@bshaffer bshaffer commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Add OperationsClientInterface, OperationsClientWrapperInterface, and CustomOperationsClient to encapsulate custom LRO RPC options while preserving full backwards compatibility for GAPIC and custom LRO clients (e.g. Compute):

  • Add Google\ApiCore\OperationsClientInterface and Google\ApiCore\OperationsClientWrapperInterface
  • Add Google\ApiCore\CustomOperationsClient implementing OperationsClientWrapperInterface
  • Unwrap OperationsClientWrapperInterface in OperationResponse::getOperationsClient() so custom LRO clients still return their underlying operations client
  • Require non-null $operationName (string) and $operationsClient (object) in OperationResponse::__construct() and tighten return types (getName(): string, getError(): ?Status, getLastProtoResponse(): ?object, getOperationsClient(): object)

@bshaffer
bshaffer requested a review from a team as a code owner September 30, 2026 21:52
@bshaffer
bshaffer added this pull request to stack #9758 October 1, 2026 19:11
@bshaffer bshaffer added the v2 label Oct 16, 2026
Comment on lines +118 to +119
$isStandardClient = $operationsClient instanceof OperationsClient
|| $operationsClient instanceof OperationsClientInterface;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this really necessary? Isn't an instance of OperationsClient also an instance of the OperationsClientInterface?

@bshaffer bshaffer Nov 6, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was done so that we could support google/longrunning:0.4 in composer.json, as it will be google/longrunning:1.0 that adds support for OperationsClientInterface.

So, I think it's best to leave this as-is for now, with maybe the addition of a @TODO to say we can remove this once we drop support for google/longrunning:0.4

EDIT: After further consideration, I THINK we can go ahead and require google/longrunning:1.0 right away. The issue is, that package can't be released until AFTER we release GAX V2, so it's a bit of a chicken-egg situation

Comment thread Gax/src/OperationResponse.php Outdated
? $this->operationsClient
: new CustomOperationsClient($this->operationsClient, $options);
$lastProtoResponse = $customClient->toOperation($lastProtoResponse);
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This means that if the $lastProtoResponse is not an instance of \Google\LongRunning\Operation we are transforming it into one.

From what I gather, Compute has its own custom LRO class, if we go ahead and perform this conversion and the end user loses access to the original object and methods that that object had, wouldn't it?

Preserve the raw custom operation response (e.g. Compute's Operation) for custom operation clients:
- Store the raw response in CustomOperationsClient
- Return the raw response in OperationResponse::getLastProtoResponse() with ?object typehint
- Update MIGRATING.md to document the return type
- Use lastProtoResponse consistently instead of separate lastCustomResponse
- Remove duplicate lastCustomResponse property from OperationResponse
- Delegate to CustomOperationsClient::getLastProtoResponse() in OperationResponse
@bshaffer bshaffer changed the title feat(Gax)!: refactor OperationResponse with OperationsClientInterface and CustomOperationsClient feat(Gax)!: add OperationsClientInterface and tighten OperationResponse types Nov 6, 2026
@bshaffer bshaffer changed the title feat(Gax)!: add OperationsClientInterface and tighten OperationResponse types feat(Gax)!: refactor OperationResponse with OperationsClientInterface and CustomOperationsClient Nov 6, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants