Skip to content

feat(Gax)!: make ClientOptions extensible and fluid, remove modifyClientOptions - #9752

Open
bshaffer wants to merge 16 commits into
gax-v2from
gax-v2-client-options
Open

bshaffer wants to merge 16 commits into
gax-v2from
gax-v2-client-options

Conversation

@bshaffer

@bshaffer bshaffer commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Make ClientOptions, CallOptions, and *TransportOptions extensible and fluent so custom veneers and service clients can subclass ClientOptions instead of mutating arrays in ClientOptionsTrait::modifyClientOptions():

  • Make properties protected and setters fluent (: static) across ClientOptions, CallOptions, and *TransportOptions, with deep-cloning __clone() on ClientOptions and TransportOptions
  • Make ClientOptions::fromArray() public and fluent (: static) while keeping explicit setter calls so subclasses can extend it via parent::fromArray()
  • Remove ClientOptionsTrait::modifyClientOptions() in favor of createClientOptions() and getClientOptions()

@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
Comment thread Gax/src/Options/ClientOptions.php Outdated
unset($arr['serviceAddress']);
}

foreach ($arr as $key => $value) {

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.

I honestly prefer the other way over this one. It makes it verbose? Yeah, but this kinda hides what we are actually setting.

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 extend client options for other service clients, e.g.

class ExperimentalFeatureClientOptions extends ClientOptions
{
    public function setMyExperimentalFeatureFlag(bool $myExperimentalFeatureFlag)
    {
    }
}

But I agree that it looks a bit messy and I prefer the explicit versions... maybe we can think of a way to have both

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