Skip to content

Commit ee09b69

Browse files
gcf-owl-bot[bot]feywind
authored andcommitted
fix: simplify logic for HTTP/1.1 REST fallback option (#1809)
* fix: simplify logic for HTTP/1.1 REST fallback option For the `fallback` parameter, all values considered as `true` in Boolean context will enable HTTP/1.1 REST fallback, since the other fallback transport, proto over HTTP, is removed from `google-gax` v4. PiperOrigin-RevId: 559812260 Source-Link: googleapis/googleapis@6a6fd29 Source-Link: googleapis/googleapis-gen@56c1665 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNTZjMTY2NTdlN2E1OTEyMmIxZGE5NDc3MWE5ZWY0MDk4OWMyODJjMCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 6efeb2c commit ee09b69

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

src/v1/publisher_client.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,15 @@ export class PublisherClient {
9494
* API remote host.
9595
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
9696
* Follows the structure of {@link gapicConfig}.
97-
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
98-
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
97+
* @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode.
9998
* For more information, please check the
10099
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
101100
* @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you
102101
* need to avoid loading the default gRPC version and want to use the fallback
103102
* HTTP implementation. Load only fallback version and pass it to the constructor:
104103
* ```
105104
* const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
106-
* const client = new PublisherClient({fallback: 'rest'}, gax);
105+
* const client = new PublisherClient({fallback: true}, gax);
107106
* ```
108107
*/
109108
constructor(
@@ -170,7 +169,7 @@ export class PublisherClient {
170169
}
171170
if (!opts.fallback) {
172171
clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
173-
} else if (opts.fallback === 'rest') {
172+
} else {
174173
clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`);
175174
}
176175
if (opts.libName && opts.libVersion) {

src/v1/schema_service_client.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,15 @@ export class SchemaServiceClient {
9393
* API remote host.
9494
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
9595
* Follows the structure of {@link gapicConfig}.
96-
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
97-
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
96+
* @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode.
9897
* For more information, please check the
9998
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
10099
* @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you
101100
* need to avoid loading the default gRPC version and want to use the fallback
102101
* HTTP implementation. Load only fallback version and pass it to the constructor:
103102
* ```
104103
* const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
105-
* const client = new SchemaServiceClient({fallback: 'rest'}, gax);
104+
* const client = new SchemaServiceClient({fallback: true}, gax);
106105
* ```
107106
*/
108107
constructor(
@@ -169,7 +168,7 @@ export class SchemaServiceClient {
169168
}
170169
if (!opts.fallback) {
171170
clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
172-
} else if (opts.fallback === 'rest') {
171+
} else {
173172
clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`);
174173
}
175174
if (opts.libName && opts.libVersion) {

src/v1/subscriber_client.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,15 @@ export class SubscriberClient {
9595
* API remote host.
9696
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
9797
* Follows the structure of {@link gapicConfig}.
98-
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
99-
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
98+
* @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode.
10099
* For more information, please check the
101100
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
102101
* @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you
103102
* need to avoid loading the default gRPC version and want to use the fallback
104103
* HTTP implementation. Load only fallback version and pass it to the constructor:
105104
* ```
106105
* const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
107-
* const client = new SubscriberClient({fallback: 'rest'}, gax);
106+
* const client = new SubscriberClient({fallback: true}, gax);
108107
* ```
109108
*/
110109
constructor(
@@ -171,7 +170,7 @@ export class SubscriberClient {
171170
}
172171
if (!opts.fallback) {
173172
clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
174-
} else if (opts.fallback === 'rest') {
173+
} else {
175174
clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`);
176175
}
177176
if (opts.libName && opts.libVersion) {
@@ -222,7 +221,7 @@ export class SubscriberClient {
222221
this.descriptors.stream = {
223222
streamingPull: new this._gaxModule.StreamDescriptor(
224223
this._gaxModule.StreamType.BIDI_STREAMING,
225-
opts.fallback === 'rest'
224+
!!opts.fallback
226225
),
227226
};
228227

0 commit comments

Comments
 (0)