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

fix: handle fallback option properly #73

Merged
merged 2 commits into from
Jun 12, 2020
Merged
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
12 changes: 12 additions & 0 deletions .kokoro/populate-secrets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,19 @@

set -eo pipefail

function now { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n' ;}
function msg { println "$*" >&2 ;}
function println { printf '%s\n' "$(now) $*" ;}


# Populates requested secrets set in SECRET_MANAGER_KEYS from service account:
# kokoro-trampoline@cloud-devrel-kokoro-resources.iam.gserviceaccount.com
SECRET_LOCATION="${KOKORO_GFILE_DIR}/secret_manager"
msg "Creating folder on disk for secrets: ${SECRET_LOCATION}"
mkdir -p ${SECRET_LOCATION}
for key in $(echo ${SECRET_MANAGER_KEYS} | sed "s/,/ /g")
do
msg "Retrieving secret ${key}"
docker run --entrypoint=gcloud \
--volume=${KOKORO_GFILE_DIR}:${KOKORO_GFILE_DIR} \
gcr.io/google.com/cloudsdktool/cloud-sdk \
Expand All @@ -29,4 +36,9 @@ do
--project cloud-devrel-kokoro-resources \
--secret $key > \
"$SECRET_LOCATION/$key"
if [[ $? == 0 ]]; then
msg "Secret written to ${SECRET_LOCATION}/${key}"
else
msg "Error retrieving secret ${key}"
fi
done
13 changes: 5 additions & 8 deletions src/v1/big_query_read_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,11 @@ export class BigQueryReadClient {
// const showcaseClient = new showcaseClient({ projectId, customConfig });
opts.clientConfig = opts.clientConfig || {};

const isBrowser = typeof window !== 'undefined';
if (isBrowser) {
opts.fallback = true;
}
// If we are in browser, we are already using fallback because of the
// "browser" field in package.json.
// But if we were explicitly requested to use fallback, let's do it now.
this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
// If we're running in browser, it's OK to omit `fallback` since
// google-gax has `browser` field in its `package.json`.
// For Electron (which does not respect `browser` field),
// pass `{fallback: true}` to the BigQueryReadClient constructor.
this._gaxModule = opts.fallback ? gax.fallback : gax;

// Create a `gaxGrpc` object, with any grpc-specific options
// sent to the client.
Expand Down
13 changes: 5 additions & 8 deletions src/v1beta1/big_query_storage_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,11 @@ export class BigQueryStorageClient {
// const showcaseClient = new showcaseClient({ projectId, customConfig });
opts.clientConfig = opts.clientConfig || {};

const isBrowser = typeof window !== 'undefined';
if (isBrowser) {
opts.fallback = true;
}
// If we are in browser, we are already using fallback because of the
// "browser" field in package.json.
// But if we were explicitly requested to use fallback, let's do it now.
this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
// If we're running in browser, it's OK to omit `fallback` since
// google-gax has `browser` field in its `package.json`.
// For Electron (which does not respect `browser` field),
// pass `{fallback: true}` to the BigQueryStorageClient constructor.
this._gaxModule = opts.fallback ? gax.fallback : gax;

// Create a `gaxGrpc` object, with any grpc-specific options
// sent to the client.
Expand Down
4 changes: 2 additions & 2 deletions synth.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"git": {
"name": ".",
"remote": "https://github.com/googleapis/nodejs-bigquery-storage.git",
"sha": "20d9978cf09493d982bde1914f4ba1ef6fc21711"
"sha": "6513e8cf6195740b570b39fb645d8a1adafc0580"
}
},
{
Expand All @@ -19,7 +19,7 @@
"git": {
"name": "synthtool",
"remote": "https://github.com/googleapis/synthtool.git",
"sha": "1c92077459db3dc50741e878f98b08c6261181e0"
"sha": "e7034945fbdc0e79d3c57f6e299e5c90b0f11469"
}
}
],
Expand Down