Skip to content

sample: add turbo replication samples #1618

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

Merged
merged 15 commits into from
Jan 10, 2022

Conversation

ddelgrosso1
Copy link
Contributor

@ddelgrosso1 ddelgrosso1 commented Sep 25, 2021

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #1649 🦕

@generated-files-bot
Copy link

Warning: This pull request is touching the following templated files:

@product-auto-label product-auto-label bot added the api: storage Issues related to the googleapis/nodejs-storage API. label Sep 25, 2021
@snippet-bot
Copy link

snippet-bot bot commented Sep 25, 2021

Here is the summary of changes.

You are about to add 4 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Sep 25, 2021
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Sep 25, 2021
@ddelgrosso1 ddelgrosso1 added the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 25, 2021
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 25, 2021
@ddelgrosso1 ddelgrosso1 added the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 25, 2021
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 25, 2021
@ddelgrosso1 ddelgrosso1 force-pushed the turbo-replication-samples branch from 4d53fb4 to a4ebfdc Compare September 25, 2021 20:41
@ddelgrosso1 ddelgrosso1 added the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 25, 2021
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 25, 2021
@ddelgrosso1 ddelgrosso1 added the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 25, 2021
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Sep 25, 2021
@shaffeeullah
Copy link
Contributor

Does it make sense to also add this value to the getMetadata sample?

);
}

createBucketWithTurboReplication().catch(console.error);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of catching like this, please remove the .catch, and add this at the end:

process.on('unhandledRejection', err => {
  console.error(err.message);
  process.exitCode = 1;
});
main(...process.argv.slice(2));

This follows the sample standards we've laid out elsewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @JustinBeckwith I'll make a ticket to update the other tests to this format as most in this repo are doing .catch(console.error)

@ddelgrosso1 ddelgrosso1 added the owlbot:run Add this label to trigger the Owlbot post processor. label Oct 13, 2021
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Oct 13, 2021
// https://cloud.google.com/storage/docs/storage-classes
const [bucket] = await storage.createBucket(bucketName, {
location,
rpo,
Copy link
Contributor

@JesseLovelace JesseLovelace Oct 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sample is called "create bucket with turbo replication", however it takes in rpo as a parameter, meaning theoretically you could set the rpo to whatever you want, for example DEFAULT, and then the sample wouldn't do what it's saying.

To make this clearer, wouldn't it be better to create a local variable named rpo and set it to ASYNC_TURBO, as part of the sample rather than as an argument? I know that you do that as a commented out line, but it might be clearer what this sample is communicating if it's hard-coded in

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I will change this.


// Enable turbo replication for the bucket by setting rpo to ASYNC_TURBO.
// The bucket must be a dual-region bucket.
async function setRPOAsyncTurbo() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would "enableTurboReplication()" be a better name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally had a name somewhat similar to that but TW thought this was a better name (see comments in the canonical sample document).


// Disable turbo replication for the bucket by setting RPO to default.
// The bucket must be a dual-region bucket.
async function setRPODefault() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would "disableTurboReplication()" be a better name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

@ddelgrosso1 ddelgrosso1 force-pushed the turbo-replication-samples branch from 30d57af to 70caa80 Compare October 14, 2021 14:44
@ddelgrosso1 ddelgrosso1 added owlbot:run Add this label to trigger the Owlbot post processor. and removed do not merge Indicates a pull request not ready for merge, due to either quality or timing. labels Jan 10, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jan 10, 2022
@ddelgrosso1 ddelgrosso1 force-pushed the turbo-replication-samples branch from a17f006 to 52ce8f6 Compare January 10, 2022 14:54
@ddelgrosso1 ddelgrosso1 added the owlbot:run Add this label to trigger the Owlbot post processor. label Jan 10, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jan 10, 2022
@ddelgrosso1 ddelgrosso1 force-pushed the turbo-replication-samples branch from e50a1ed to 5120d52 Compare January 10, 2022 18:38
@ddelgrosso1 ddelgrosso1 added the owlbot:run Add this label to trigger the Owlbot post processor. label Jan 10, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jan 10, 2022
@ddelgrosso1 ddelgrosso1 merged commit 97edb9a into googleapis:main Jan 10, 2022
@ddelgrosso1 ddelgrosso1 deleted the turbo-replication-samples branch January 10, 2022 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/nodejs-storage API. cla: yes This human has signed the Contributor License Agreement. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add samples for turbo replication
4 participants