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

RFC - Simplify GAPIC options #899

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,54 @@ Google Cloud BigQuery Data Transfer **must** be installed separately by requirin
$ composer require google/cloud-bigquerydatatransfer
```

## Generated Client Configuration Options

Any methods which trigger a network request in our generated clients accept the same set of configuration options. Please see the details below for the accepted options:

#### Accepted Options

##### headers

Headers to send along with the call.

Accepted Types: `array`

##### transportOptions

Options proxied through to the underlying transport. Please specify a key with the transport type (either `rest` or `grpc`) along with the corresponding options. For example, the default HTTP handler for REST is [Guzzle](http://docs.guzzlephp.org/en/stable/), as a result any options supplied under the `rest` key will be proxied through to Guzzle.

Accepted Types: `array`

##### retrySettings

Retry settings to use for this call. Can be a [Google\ApiCore\RetrySettings](https://github.com/googleapis/gax-php/blob/master/src/ApiCore/RetrySettings.php) object, or an associative array of retry settings parameters. See the documentation on [Google\ApiCore\RetrySettings](https://github.com/googleapis/gax-php/blob/master/src/ApiCore/RetrySettings.php) for example usage.

Accepted Types: [`Google\ApiCore\RetrySettings`](https://github.com/googleapis/gax-php/blob/master/src/ApiCore/RetrySettings.php)|`array`

##### timeoutMillis
Timeout to use for this ca
ll.

Accepted Types: `int`

#### Preview

```php
require 'vendor/autoload.php';

use Google\Cloud\PubSub\V1\PublisherClient;

$publisher = new PublisherClient();

$publisher->createTopic('my-topic', [
'transportOptions' => [
'rest'=> [
'proxy' => 'https://localhost:8100'
]
]
]);
```

## Caching Access Tokens

By default the library will use a simple in-memory caching implementation, however it is possible to override this behavior by passing a [PSR-6](http://www.php-fig.org/psr/psr-6/) caching implementation in to the desired client.
Expand Down
61 changes: 17 additions & 44 deletions src/PubSub/V1/Gapic/PublisherGapicClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,49 +247,26 @@ public static function parseName($formattedName, $template = null)
* Constructor.
*
* @param array $options {
* Optional. Options for configuring the service API wrapper.
*
* @type string $serviceAddress The domain name of the API remote host.
* Default 'pubsub.googleapis.com'.
* @type mixed $port The port on which to connect to the remote host. Default 443.
* @type Channel $channel
* A `Channel` object. If not specified, a channel will be constructed.
* NOTE: This option is only valid when utilizing the gRPC transport.
* @type ChannelCredentials $sslCreds
* A `ChannelCredentials` object for use with an SSL-enabled channel.
* Default: a credentials object returned from
* \Grpc\ChannelCredentials::createSsl().
* NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel
* optional argument is specified, then this argument is unused.
* @type bool $forceNewChannel
* If true, this forces gRPC to create a new channel instead of using a persistent channel.
* Defaults to false.
* NOTE: This option is only valid when utilizing the gRPC transport. Also, if the $channel
* optional argument is specified, then this option is unused.
* @type CredentialsLoader $credentialsLoader
* A CredentialsLoader object created using the Google\Auth library.
* Options for configuring the service API wrapper.
*
* @type string $serviceAddress The address of the API remote host.

This comment was marked as spam.

This comment was marked as spam.

* Default 'pubsub.googleapis.com:443'.
* @type string[] $scopes A string array of scopes to use when acquiring credentials.
* Defaults to the scopes for the Google Cloud Pub/Sub API.
* Defaults to the scopes for the Google Cloud Pub/Sub API.
* @type array $keyFile The contents of the service account credentials

This comment was marked as spam.

This comment was marked as spam.

* .json file retrieved from the Google Developer's Console.
* Ex: `json_decode(file_get_contents($path), true)`.
* @type string $keyFilePath The full path to your service account
* credentials .json file retrieved from the Google Developers
* Console.
* @type string $clientConfigPath
* Path to a JSON file containing client method configuration, including retry settings.
* Specify this setting to specify the retry behavior of all methods on the client.
* By default this settings points to the default client config file, which is provided
* in the resources folder. The retry settings provided in this option can be overridden
* by settings in $retryingOverride
* @type array $retryingOverride
* An associative array in which the keys are method names (e.g. 'createFoo'), and
* the values are retry settings to use for that method. The retry settings for each
* method can be a {@see Google\ApiCore\RetrySettings} object, or an associative array
* of retry settings parameters. See the documentation on {@see Google\ApiCore\RetrySettings}
* for example usage. Passing a value of null is equivalent to a value of
* ['retriesEnabled' => false]. Retry settings provided in this setting override the
* settings in $clientConfigPath.
* @type callable $authHttpHandler A handler used to deliver PSR-7 requests specifically
* for authentication. Should match a signature of
* `function (RequestInterface $request, array $options) : ResponseInterface`.
* @type callable $httpHandler A handler used to deliver PSR-7 requests. Should match a

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

* signature of `function (RequestInterface $request, array $options) : PromiseInterface`.
* NOTE: This option is only valid when utilizing the REST transport.
* in the resources folder.
* @type bool $disableRetries Determines whether or not retries defined

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

* by the client configuration should be disabled. Defaults to
* `false`.
* @type string|TransportInterface $transport The transport used for executing network
* requests. May be either the string `rest` or `grpc`. Additionally, it is possible
* to pass in an already instantiated transport. Defaults to `grpc` if gRPC support is
Expand Down Expand Up @@ -323,15 +300,11 @@ public function __construct($options = [])
* signs (`%`). It must be between 3 and 255 characters in length, and it
* must not start with `"goog"`.
* @param array $optionalArgs {
* Optional.
* Optional. For options that apply to all requests, please see
* [here](https://github.com/GoogleCloudPlatform/google-cloud-php#generated-client-configuration-options).
*
* @type array $labels
* User labels.
* @type RetrySettings|array $retrySettings
* Retry settings to use for this call. Can be a
* {@see Google\ApiCore\RetrySettings} object, or an associative array
* of retry settings parameters. See the documentation on
* {@see Google\ApiCore\RetrySettings} for example usage.
* }
*
* @return \Google\Cloud\PubSub\V1\Topic
Expand Down