From 1e33bd1221a5f98b7b342f3c8647be4c5d13af4d Mon Sep 17 00:00:00 2001 From: Summer Ji Date: Thu, 3 Feb 2022 11:59:12 -0800 Subject: [PATCH 1/2] fix: manual generate library for ongoing stream on closed client --- .github/generated-files-bot.yml | 4 +- .github/workflows/ci.yaml | 2 +- README.md | 26 +- samples/README.md | 18 +- .../snippet_metadata.google.bigtable.v2.json | 327 ++++++++++++++++++ src/v2/bigtable_client.ts | 21 +- test/gapic_bigtable_v2.ts | 78 +++++ 7 files changed, 449 insertions(+), 27 deletions(-) create mode 100644 samples/generated/v2/snippet_metadata.google.bigtable.v2.json diff --git a/.github/generated-files-bot.yml b/.github/generated-files-bot.yml index 992ccef4a..7bb7ce54c 100644 --- a/.github/generated-files-bot.yml +++ b/.github/generated-files-bot.yml @@ -8,9 +8,9 @@ generatedFiles: - path: '.github/generated-files-bot.+(yml|yaml)' message: '`.github/generated-files-bot.(yml|yaml)` should be updated in [`synthtool`](https://github.com/googleapis/synthtool)' - path: 'README.md' - message: '`README.md` is managed by [`synthtool`](https://github.com/googleapis/synthtool). However, a partials file can be used to update the README, e.g.: https://github.com/googleapis/nodejs-storage/blob/main/.readme-partials.yaml' + message: '`README.md` is managed by [`synthtool`](https://github.com/googleapis/synthtool). However, a partials file can be used to update the README, e.g.: https://github.com/googleapis/nodejs-storage/blob/master/.readme-partials.yaml' - path: 'samples/README.md' - message: '`samples/README.md` is managed by [`synthtool`](https://github.com/googleapis/synthtool). However, a partials file can be used to update the README, e.g.: https://github.com/googleapis/nodejs-storage/blob/main/.readme-partials.yaml' + message: '`samples/README.md` is managed by [`synthtool`](https://github.com/googleapis/synthtool). However, a partials file can be used to update the README, e.g.: https://github.com/googleapis/nodejs-storage/blob/master/.readme-partials.yaml' ignoreAuthors: - 'gcf-owl-bot[bot]' - 'yoshi-automation' diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a9517884b..397792ed8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,7 +1,7 @@ on: push: branches: - - main + - master pull_request: name: ci jobs: diff --git a/README.md b/README.md index b0b3bc0a4..20931e4a8 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Cloud Bigtable Client Library for Node.js A comprehensive list of changes in each version may be found in -[the CHANGELOG](https://github.com/googleapis/nodejs-bigtable/blob/main/CHANGELOG.md). +[the CHANGELOG](https://github.com/googleapis/nodejs-bigtable/blob/master/CHANGELOG.md). * [Cloud Bigtable Node.js Client API Reference][client-docs] * [Cloud Bigtable Documentation][product-docs] @@ -84,19 +84,19 @@ quickstart(); ## Samples -Samples are in the [`samples/`](https://github.com/googleapis/nodejs-bigtable/tree/main/samples) directory. Each sample's `README.md` has instructions for running its sample. +Samples are in the [`samples/`](https://github.com/googleapis/nodejs-bigtable/tree/master/samples) directory. Each sample's `README.md` has instructions for running its sample. | Sample | Source Code | Try it | | --------------------------- | --------------------------------- | ------ | -| Filter Snippets | [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/filterSnippets.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/filterSnippets.js,samples/README.md) | -| Instances | [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/instances.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/instances.js,samples/README.md) | -| Quickstart | [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) | -| Read Snippets | [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/readSnippets.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/readSnippets.js,samples/README.md) | -| Tableadmin | [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/tableadmin.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/tableadmin.js,samples/README.md) | -| Write Batch | [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/writeBatch.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeBatch.js,samples/README.md) | -| Write Conditionally | [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/writeConditionally.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeConditionally.js,samples/README.md) | -| Write Increment | [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/writeIncrement.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeIncrement.js,samples/README.md) | -| Simple Insert | [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/writeSimple.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeSimple.js,samples/README.md) | +| Filter Snippets | [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/filterSnippets.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/filterSnippets.js,samples/README.md) | +| Instances | [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/instances.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/instances.js,samples/README.md) | +| Quickstart | [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) | +| Read Snippets | [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/readSnippets.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/readSnippets.js,samples/README.md) | +| Tableadmin | [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/tableadmin.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/tableadmin.js,samples/README.md) | +| Write Batch | [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/writeBatch.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeBatch.js,samples/README.md) | +| Write Conditionally | [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/writeConditionally.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeConditionally.js,samples/README.md) | +| Write Increment | [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/writeIncrement.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeIncrement.js,samples/README.md) | +| Simple Insert | [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/writeSimple.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeSimple.js,samples/README.md) | @@ -146,7 +146,7 @@ More Information: [Google Cloud Platform Launch Stages][launch_stages] ## Contributing -Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/nodejs-bigtable/blob/main/CONTRIBUTING.md). +Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/nodejs-bigtable/blob/master/CONTRIBUTING.md). Please note that this `README.md`, the `samples/README.md`, and a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`) @@ -158,7 +158,7 @@ to its templates in Apache Version 2.0 -See [LICENSE](https://github.com/googleapis/nodejs-bigtable/blob/main/LICENSE) +See [LICENSE](https://github.com/googleapis/nodejs-bigtable/blob/master/LICENSE) [client-docs]: https://cloud.google.com/nodejs/docs/reference/bigtable/latest [product-docs]: https://cloud.google.com/bigtable diff --git a/samples/README.md b/samples/README.md index 1f65d7a59..79ca162b4 100644 --- a/samples/README.md +++ b/samples/README.md @@ -39,7 +39,7 @@ Before running the samples, make sure you've followed the steps outlined in ### Filter Snippets -View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/filterSnippets.js). +View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/filterSnippets.js). [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/filterSnippets.js,samples/README.md) @@ -56,7 +56,7 @@ __Usage:__ ### Instances -View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/instances.js). +View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/instances.js). [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/instances.js,samples/README.md) @@ -73,7 +73,7 @@ __Usage:__ ### Quickstart -View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/quickstart.js). +View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/quickstart.js). [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) @@ -90,7 +90,7 @@ __Usage:__ ### Read Snippets -View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/readSnippets.js). +View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/readSnippets.js). [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/readSnippets.js,samples/README.md) @@ -107,7 +107,7 @@ __Usage:__ ### Tableadmin -View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/tableadmin.js). +View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/tableadmin.js). [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/tableadmin.js,samples/README.md) @@ -124,7 +124,7 @@ __Usage:__ ### Write Batch -View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/writeBatch.js). +View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/writeBatch.js). [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeBatch.js,samples/README.md) @@ -141,7 +141,7 @@ __Usage:__ ### Write Conditionally -View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/writeConditionally.js). +View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/writeConditionally.js). [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeConditionally.js,samples/README.md) @@ -158,7 +158,7 @@ __Usage:__ ### Write Increment -View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/writeIncrement.js). +View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/writeIncrement.js). [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeIncrement.js,samples/README.md) @@ -177,7 +177,7 @@ __Usage:__ Insert a row into a table. -View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/writeSimple.js). +View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/writeSimple.js). [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeSimple.js,samples/README.md) diff --git a/samples/generated/v2/snippet_metadata.google.bigtable.v2.json b/samples/generated/v2/snippet_metadata.google.bigtable.v2.json new file mode 100644 index 000000000..dedcd3fb3 --- /dev/null +++ b/samples/generated/v2/snippet_metadata.google.bigtable.v2.json @@ -0,0 +1,327 @@ +{ + "clientLibrary": { + "name": "nodejs-bigtable", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.bigtable.v2", + "version": "v2" + } + ] + }, + "snippets": [ + { + "regionTag": "bigtable_v2_generated_Bigtable_ReadRows_async", + "title": "bigtable readRows Sample", + "origin": "API_DEFINITION", + "description": " Streams back the contents of all requested rows in key order, optionally applying the same Reader filter to each. Depending on their size, rows and cells may be broken up across multiple responses, but atomicity of each row will still be preserved. See the ReadRowsResponse documentation for details.", + "canonical": true, + "file": "bigtable.read_rows.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 20, + "end": 69, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ReadRows", + "fullName": "google.bigtable.v2.Bigtable.ReadRows", + "async": true, + "parameters": [ + { + "name": "table_name", + "type": "TYPE_STRING" + }, + { + "name": "app_profile_id", + "type": "TYPE_STRING" + }, + { + "name": "rows", + "type": ".google.bigtable.v2.RowSet" + }, + { + "name": "filter", + "type": ".google.bigtable.v2.RowFilter" + }, + { + "name": "rows_limit", + "type": "TYPE_INT64" + } + ], + "resultType": ".google.bigtable.v2.ReadRowsResponse", + "client": { + "shortName": "BigtableClient", + "fullName": "google.bigtable.v2.BigtableClient" + }, + "method": { + "shortName": "ReadRows", + "fullName": "google.bigtable.v2.Bigtable.ReadRows", + "service": { + "shortName": "Bigtable", + "fullName": "google.bigtable.v2.Bigtable" + } + } + } + }, + { + "regionTag": "bigtable_v2_generated_Bigtable_SampleRowKeys_async", + "title": "bigtable sampleRowKeys Sample", + "origin": "API_DEFINITION", + "description": " Returns a sample of row keys in the table. The returned row keys will delimit contiguous sections of the table of approximately equal size, which can be used to break up the data for distributed tasks like mapreduces.", + "canonical": true, + "file": "bigtable.sample_row_keys.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 20, + "end": 54, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SampleRowKeys", + "fullName": "google.bigtable.v2.Bigtable.SampleRowKeys", + "async": true, + "parameters": [ + { + "name": "table_name", + "type": "TYPE_STRING" + }, + { + "name": "app_profile_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.bigtable.v2.SampleRowKeysResponse", + "client": { + "shortName": "BigtableClient", + "fullName": "google.bigtable.v2.BigtableClient" + }, + "method": { + "shortName": "SampleRowKeys", + "fullName": "google.bigtable.v2.Bigtable.SampleRowKeys", + "service": { + "shortName": "Bigtable", + "fullName": "google.bigtable.v2.Bigtable" + } + } + } + }, + { + "regionTag": "bigtable_v2_generated_Bigtable_MutateRow_async", + "title": "bigtable mutateRow Sample", + "origin": "API_DEFINITION", + "description": " Mutates a row atomically. Cells already present in the row are left unchanged unless explicitly changed by `mutation`.", + "canonical": true, + "file": "bigtable.mutate_row.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 20, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "MutateRow", + "fullName": "google.bigtable.v2.Bigtable.MutateRow", + "async": true, + "parameters": [ + { + "name": "table_name", + "type": "TYPE_STRING" + }, + { + "name": "app_profile_id", + "type": "TYPE_STRING" + }, + { + "name": "row_key", + "type": "TYPE_BYTES" + }, + { + "name": "mutations", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.bigtable.v2.MutateRowResponse", + "client": { + "shortName": "BigtableClient", + "fullName": "google.bigtable.v2.BigtableClient" + }, + "method": { + "shortName": "MutateRow", + "fullName": "google.bigtable.v2.Bigtable.MutateRow", + "service": { + "shortName": "Bigtable", + "fullName": "google.bigtable.v2.Bigtable" + } + } + } + }, + { + "regionTag": "bigtable_v2_generated_Bigtable_MutateRows_async", + "title": "bigtable mutateRows Sample", + "origin": "API_DEFINITION", + "description": " Mutates multiple rows in a batch. Each individual row is mutated atomically as in MutateRow, but the entire batch is not executed atomically.", + "canonical": true, + "file": "bigtable.mutate_rows.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 20, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "MutateRows", + "fullName": "google.bigtable.v2.Bigtable.MutateRows", + "async": true, + "parameters": [ + { + "name": "table_name", + "type": "TYPE_STRING" + }, + { + "name": "app_profile_id", + "type": "TYPE_STRING" + }, + { + "name": "entries", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.bigtable.v2.MutateRowsResponse", + "client": { + "shortName": "BigtableClient", + "fullName": "google.bigtable.v2.BigtableClient" + }, + "method": { + "shortName": "MutateRows", + "fullName": "google.bigtable.v2.Bigtable.MutateRows", + "service": { + "shortName": "Bigtable", + "fullName": "google.bigtable.v2.Bigtable" + } + } + } + }, + { + "regionTag": "bigtable_v2_generated_Bigtable_CheckAndMutateRow_async", + "title": "bigtable checkAndMutateRow Sample", + "origin": "API_DEFINITION", + "description": " Mutates a row atomically based on the output of a predicate Reader filter.", + "canonical": true, + "file": "bigtable.check_and_mutate_row.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 20, + "end": 81, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CheckAndMutateRow", + "fullName": "google.bigtable.v2.Bigtable.CheckAndMutateRow", + "async": true, + "parameters": [ + { + "name": "table_name", + "type": "TYPE_STRING" + }, + { + "name": "app_profile_id", + "type": "TYPE_STRING" + }, + { + "name": "row_key", + "type": "TYPE_BYTES" + }, + { + "name": "predicate_filter", + "type": ".google.bigtable.v2.RowFilter" + }, + { + "name": "true_mutations", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "false_mutations", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.bigtable.v2.CheckAndMutateRowResponse", + "client": { + "shortName": "BigtableClient", + "fullName": "google.bigtable.v2.BigtableClient" + }, + "method": { + "shortName": "CheckAndMutateRow", + "fullName": "google.bigtable.v2.Bigtable.CheckAndMutateRow", + "service": { + "shortName": "Bigtable", + "fullName": "google.bigtable.v2.Bigtable" + } + } + } + }, + { + "regionTag": "bigtable_v2_generated_Bigtable_ReadModifyWriteRow_async", + "title": "bigtable readModifyWriteRow Sample", + "origin": "API_DEFINITION", + "description": " Modifies a row atomically on the server. The method reads the latest existing timestamp and value from the specified columns and writes a new entry based on pre-defined read/modify/write rules. The new value for the timestamp is the greater of the existing timestamp or the current server time. The method returns the new contents of all modified cells.", + "canonical": true, + "file": "bigtable.read_modify_write_row.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 20, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ReadModifyWriteRow", + "fullName": "google.bigtable.v2.Bigtable.ReadModifyWriteRow", + "async": true, + "parameters": [ + { + "name": "table_name", + "type": "TYPE_STRING" + }, + { + "name": "app_profile_id", + "type": "TYPE_STRING" + }, + { + "name": "row_key", + "type": "TYPE_BYTES" + }, + { + "name": "rules", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.bigtable.v2.ReadModifyWriteRowResponse", + "client": { + "shortName": "BigtableClient", + "fullName": "google.bigtable.v2.BigtableClient" + }, + "method": { + "shortName": "ReadModifyWriteRow", + "fullName": "google.bigtable.v2.Bigtable.ReadModifyWriteRow", + "service": { + "shortName": "Bigtable", + "fullName": "google.bigtable.v2.Bigtable" + } + } + } + } + ] +} diff --git a/src/v2/bigtable_client.ts b/src/v2/bigtable_client.ts index 560410767..be3b1ee5e 100644 --- a/src/v2/bigtable_client.ts +++ b/src/v2/bigtable_client.ts @@ -18,8 +18,15 @@ /* global window */ import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; - +import { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GoogleError, +} from 'google-gax'; + +import {PassThrough} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); /** @@ -236,6 +243,16 @@ export class BigtableClient { stub => (...args: Array<{}>) => { if (this._terminated) { + if (methodName in this.descriptors.stream) { + const stream = new PassThrough(); + setImmediate(() => { + stream.emit( + 'error', + new GoogleError('The client has already been closed.') + ); + }); + return stream; + } return Promise.reject('The client has already been closed.'); } const func = stub[methodName]; diff --git a/test/gapic_bigtable_v2.ts b/test/gapic_bigtable_v2.ts index ffa8554b8..03b0e1522 100644 --- a/test/gapic_bigtable_v2.ts +++ b/test/gapic_bigtable_v2.ts @@ -559,6 +559,32 @@ describe('v2.BigtableClient', () => { .calledWith(request, expectedOptions) ); }); + + it('invokes readRows with closed client', async () => { + const client = new bigtableModule.v2.BigtableClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.v2.ReadRowsRequest() + ); + const expectedError = new Error('The client has already been closed.'); + client.close(); + const stream = client.readRows(request); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + (response: protos.google.bigtable.v2.ReadRowsResponse) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + }); }); describe('sampleRowKeys', () => { @@ -646,6 +672,32 @@ describe('v2.BigtableClient', () => { .calledWith(request, expectedOptions) ); }); + + it('invokes sampleRowKeys with closed client', async () => { + const client = new bigtableModule.v2.BigtableClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.v2.SampleRowKeysRequest() + ); + const expectedError = new Error('The client has already been closed.'); + client.close(); + const stream = client.sampleRowKeys(request); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + (response: protos.google.bigtable.v2.SampleRowKeysResponse) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + }); }); describe('mutateRows', () => { @@ -733,6 +785,32 @@ describe('v2.BigtableClient', () => { .calledWith(request, expectedOptions) ); }); + + it('invokes mutateRows with closed client', async () => { + const client = new bigtableModule.v2.BigtableClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.v2.MutateRowsRequest() + ); + const expectedError = new Error('The client has already been closed.'); + client.close(); + const stream = client.mutateRows(request); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + (response: protos.google.bigtable.v2.MutateRowsResponse) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + }); }); describe('Path templates', () => { From ad426f958a295a4ddf9cd1e90a0cc3c0b9603599 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Thu, 3 Feb 2022 20:04:48 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- .github/generated-files-bot.yml | 4 ++-- .github/workflows/ci.yaml | 2 +- README.md | 26 +++++++++++++------------- samples/README.md | 18 +++++++++--------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.github/generated-files-bot.yml b/.github/generated-files-bot.yml index 7bb7ce54c..992ccef4a 100644 --- a/.github/generated-files-bot.yml +++ b/.github/generated-files-bot.yml @@ -8,9 +8,9 @@ generatedFiles: - path: '.github/generated-files-bot.+(yml|yaml)' message: '`.github/generated-files-bot.(yml|yaml)` should be updated in [`synthtool`](https://github.com/googleapis/synthtool)' - path: 'README.md' - message: '`README.md` is managed by [`synthtool`](https://github.com/googleapis/synthtool). However, a partials file can be used to update the README, e.g.: https://github.com/googleapis/nodejs-storage/blob/master/.readme-partials.yaml' + message: '`README.md` is managed by [`synthtool`](https://github.com/googleapis/synthtool). However, a partials file can be used to update the README, e.g.: https://github.com/googleapis/nodejs-storage/blob/main/.readme-partials.yaml' - path: 'samples/README.md' - message: '`samples/README.md` is managed by [`synthtool`](https://github.com/googleapis/synthtool). However, a partials file can be used to update the README, e.g.: https://github.com/googleapis/nodejs-storage/blob/master/.readme-partials.yaml' + message: '`samples/README.md` is managed by [`synthtool`](https://github.com/googleapis/synthtool). However, a partials file can be used to update the README, e.g.: https://github.com/googleapis/nodejs-storage/blob/main/.readme-partials.yaml' ignoreAuthors: - 'gcf-owl-bot[bot]' - 'yoshi-automation' diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 397792ed8..a9517884b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,7 +1,7 @@ on: push: branches: - - master + - main pull_request: name: ci jobs: diff --git a/README.md b/README.md index 20931e4a8..b0b3bc0a4 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Cloud Bigtable Client Library for Node.js A comprehensive list of changes in each version may be found in -[the CHANGELOG](https://github.com/googleapis/nodejs-bigtable/blob/master/CHANGELOG.md). +[the CHANGELOG](https://github.com/googleapis/nodejs-bigtable/blob/main/CHANGELOG.md). * [Cloud Bigtable Node.js Client API Reference][client-docs] * [Cloud Bigtable Documentation][product-docs] @@ -84,19 +84,19 @@ quickstart(); ## Samples -Samples are in the [`samples/`](https://github.com/googleapis/nodejs-bigtable/tree/master/samples) directory. Each sample's `README.md` has instructions for running its sample. +Samples are in the [`samples/`](https://github.com/googleapis/nodejs-bigtable/tree/main/samples) directory. Each sample's `README.md` has instructions for running its sample. | Sample | Source Code | Try it | | --------------------------- | --------------------------------- | ------ | -| Filter Snippets | [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/filterSnippets.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/filterSnippets.js,samples/README.md) | -| Instances | [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/instances.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/instances.js,samples/README.md) | -| Quickstart | [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) | -| Read Snippets | [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/readSnippets.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/readSnippets.js,samples/README.md) | -| Tableadmin | [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/tableadmin.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/tableadmin.js,samples/README.md) | -| Write Batch | [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/writeBatch.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeBatch.js,samples/README.md) | -| Write Conditionally | [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/writeConditionally.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeConditionally.js,samples/README.md) | -| Write Increment | [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/writeIncrement.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeIncrement.js,samples/README.md) | -| Simple Insert | [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/writeSimple.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeSimple.js,samples/README.md) | +| Filter Snippets | [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/filterSnippets.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/filterSnippets.js,samples/README.md) | +| Instances | [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/instances.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/instances.js,samples/README.md) | +| Quickstart | [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) | +| Read Snippets | [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/readSnippets.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/readSnippets.js,samples/README.md) | +| Tableadmin | [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/tableadmin.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/tableadmin.js,samples/README.md) | +| Write Batch | [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/writeBatch.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeBatch.js,samples/README.md) | +| Write Conditionally | [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/writeConditionally.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeConditionally.js,samples/README.md) | +| Write Increment | [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/writeIncrement.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeIncrement.js,samples/README.md) | +| Simple Insert | [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/writeSimple.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeSimple.js,samples/README.md) | @@ -146,7 +146,7 @@ More Information: [Google Cloud Platform Launch Stages][launch_stages] ## Contributing -Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/nodejs-bigtable/blob/master/CONTRIBUTING.md). +Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/nodejs-bigtable/blob/main/CONTRIBUTING.md). Please note that this `README.md`, the `samples/README.md`, and a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`) @@ -158,7 +158,7 @@ to its templates in Apache Version 2.0 -See [LICENSE](https://github.com/googleapis/nodejs-bigtable/blob/master/LICENSE) +See [LICENSE](https://github.com/googleapis/nodejs-bigtable/blob/main/LICENSE) [client-docs]: https://cloud.google.com/nodejs/docs/reference/bigtable/latest [product-docs]: https://cloud.google.com/bigtable diff --git a/samples/README.md b/samples/README.md index 79ca162b4..1f65d7a59 100644 --- a/samples/README.md +++ b/samples/README.md @@ -39,7 +39,7 @@ Before running the samples, make sure you've followed the steps outlined in ### Filter Snippets -View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/filterSnippets.js). +View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/filterSnippets.js). [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/filterSnippets.js,samples/README.md) @@ -56,7 +56,7 @@ __Usage:__ ### Instances -View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/instances.js). +View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/instances.js). [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/instances.js,samples/README.md) @@ -73,7 +73,7 @@ __Usage:__ ### Quickstart -View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/quickstart.js). +View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/quickstart.js). [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) @@ -90,7 +90,7 @@ __Usage:__ ### Read Snippets -View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/readSnippets.js). +View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/readSnippets.js). [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/readSnippets.js,samples/README.md) @@ -107,7 +107,7 @@ __Usage:__ ### Tableadmin -View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/tableadmin.js). +View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/tableadmin.js). [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/tableadmin.js,samples/README.md) @@ -124,7 +124,7 @@ __Usage:__ ### Write Batch -View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/writeBatch.js). +View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/writeBatch.js). [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeBatch.js,samples/README.md) @@ -141,7 +141,7 @@ __Usage:__ ### Write Conditionally -View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/writeConditionally.js). +View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/writeConditionally.js). [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeConditionally.js,samples/README.md) @@ -158,7 +158,7 @@ __Usage:__ ### Write Increment -View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/writeIncrement.js). +View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/writeIncrement.js). [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeIncrement.js,samples/README.md) @@ -177,7 +177,7 @@ __Usage:__ Insert a row into a table. -View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/master/samples/writeSimple.js). +View the [source code](https://github.com/googleapis/nodejs-bigtable/blob/main/samples/writeSimple.js). [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-bigtable&page=editor&open_in_editor=samples/writeSimple.js,samples/README.md)