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

feat(spanner) : add support for client resource base routing #4548

Closed

Conversation

jiren
Copy link
Member

@jiren jiren commented Dec 30, 2019

Towards #4547 issue

Implementation of Client resource based routing.

  • Route requests based on available instance endpoint uri. Enable/Disable resource based routing using ENV variable(GOOGLE_CLOUD_SPANNER_ENABLE_RESOURCE_BASED_ROUTING=TRUE) or manual flag enable_resource_based_routing while creating a database client instance . Default client resource based routing is disabled.

Implementation overview

  • Get instance API with field mask
  • If resource based routing enabled create client connection using instance endpoint uris.
    • Get instance endpoint uris
      • If endpoint uris present, then create a connection using the first uri and cached connection into client instance.
      • If endpoint uris does not present then use default connection with global spanner endpoint uri

@jiren jiren requested a review from skuruppu December 30, 2019 14:35
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Dec 30, 2019
@skuruppu skuruppu requested a review from mbril January 1, 2020 22:43
@jiren jiren self-assigned this Jan 8, 2020
@hengfengli
Copy link
Contributor

hengfengli commented Jan 14, 2020

@jiren Could you please fix the CI check error? After that, we can review this PR. Thanks.

@jiren jiren added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 18, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 18, 2020
@jiren
Copy link
Member Author

jiren commented Jan 18, 2020

@jiren Could you please fix the CI check error? After that, we can review this PR. Thanks.

@hengfengli CI error fixed for OS X.

@jiren jiren added the api: spanner Issues related to the Spanner API. label Jan 21, 2020
Copy link
Contributor

@hengfengli hengfengli left a comment

Choose a reason for hiding this comment

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

My major concern is whether we need to add ClientServiceProxy and update service.rb.

I think in client.rb::initialize, we can have the following logic:

  • if resource-based routing is enabled,
    • the returned endpoint is empty: use the project.service.
    • the returned endpoint is same as the given one in the project.service: use the project.service.
    • the returned endpoint is different: we can create a service with the instance-specific endpoint and store it in the client instance.
  • If resource-based routing is not enabled, then we just use the project.service.

In this case, we don't need to update service.rb.

google-cloud-spanner/acceptance/spanner/client_test.rb Outdated Show resolved Hide resolved
google-cloud-spanner/acceptance/spanner/client_test.rb Outdated Show resolved Hide resolved
google-cloud-spanner/acceptance/spanner_helper.rb Outdated Show resolved Hide resolved
google-cloud-spanner/lib/google/cloud/spanner/client.rb Outdated Show resolved Hide resolved
google-cloud-spanner/lib/google/cloud/spanner/service.rb Outdated Show resolved Hide resolved
google-cloud-spanner/lib/google/cloud/spanner/client.rb Outdated Show resolved Hide resolved
google-cloud-spanner/lib/google/cloud/spanner/session.rb Outdated Show resolved Hide resolved
@jiren
Copy link
Member Author

jiren commented Jan 22, 2020

@hengfengli I will fix the conflict once we finalize service object creation in the client, due to channel-related changes in service.rb, current resource-based routing code will not work

@jiren jiren force-pushed the spanner-resource-base-routing-client branch from 5c42c3f to 521ec84 Compare January 22, 2020 12:17
@hengfengli
Copy link
Contributor

@jiren Thanks for fixing the issues.

@skuruppu It looks good to me. Please take a look or request someone to take another look.

@hengfengli
Copy link
Contributor

@jiren Why does the CI check not run for this PR again? Maybe because of the force-push. Can you try to re-trigger it?

@hengfengli hengfengli added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 22, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 22, 2020
Copy link
Contributor

@skuruppu skuruppu left a comment

Choose a reason for hiding this comment

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

Looks good. Just want all the comments to be addressed before I approve.

@jiren jiren force-pushed the spanner-resource-base-routing-client branch from 521ec84 to 13eb5cd Compare January 23, 2020 01:39
Copy link
Contributor

@skuruppu skuruppu left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @jiren. LGTM

Copy link
Contributor

@hengfengli hengfengli left a comment

Choose a reason for hiding this comment

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

LGTM.

@skuruppu
Copy link
Contributor

One more request @jiren. Please be more descriptive in the PR description. Follow googleapis/google-cloud-python#10183 as an example.

@jiren
Copy link
Member Author

jiren commented Jan 28, 2020

One more request @jiren. Please be more descriptive in the PR description. Follow googleapis/google-cloud-python#10183 as an example.

Got it

@rhiro rhiro removed the request for review from mbril February 4, 2020 23:25
@skuruppu skuruppu added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Feb 13, 2020
@skuruppu
Copy link
Contributor

We have decided to implement this functionality on the server side so we no longer need to add this support on the client side.

@skuruppu skuruppu closed this Apr 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the Spanner API. cla: yes This human has signed the Contributor License Agreement. do not merge Indicates a pull request not ready for merge, due to either quality or timing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants