-
Notifications
You must be signed in to change notification settings - Fork 116
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 external hosts #3474
base: main
Are you sure you want to change the base?
Conversation
🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use -- conventional-commit-lint bot |
a09b78b
to
f1b5719
Compare
@@ -49,10 +51,16 @@ private SessionId(DatabaseId db, String name) { | |||
static SessionId of(String name) { | |||
Preconditions.checkNotNull(name); | |||
Map<String, String> parts = NAME_TEMPLATE.match(name); | |||
if (parts == null) { | |||
parts = EXTERNAL_HOST_NAME_TEMPLATE.match(name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add unit tests to cover this pattern and ensure the functionality works as intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added unit test to cover existing pattern (for regression) as well as new pattern
@@ -94,6 +94,11 @@ public static DatabaseId of(String project, String instance, String database) { | |||
return new DatabaseId(new InstanceId(project, instance), database); | |||
} | |||
|
|||
/** Creates a {@code DatabaseId} given instance and database IDs. */ | |||
public static DatabaseId of(String instance, String database) { | |||
return new DatabaseId(new InstanceId("default", instance), database); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should document to users that this method assumes instance Id to be "default".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe not instance Id, but rather project Id?
@@ -94,6 +94,11 @@ public static DatabaseId of(String project, String instance, String database) { | |||
return new DatabaseId(new InstanceId(project, instance), database); | |||
} | |||
|
|||
/** Creates a {@code DatabaseId} with "default" project, given instance and database IDs. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit nit pick: "default" as project id.
try { | ||
SessionId.of(host); | ||
SessionId.of(externalHost); | ||
// If no exceptions are thrown, the test will pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to add assertEquas here to validate all the attributes instanceid, projectid and databaseid as set in both the scenarios?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added assert for session name.
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:
Fixes #<issue_number_goes_here> ☕️
If you write sample code, please follow the samples format.