-
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?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,8 @@ static class SessionId { | |
private static final PathTemplate NAME_TEMPLATE = | ||
PathTemplate.create( | ||
"projects/{project}/instances/{instance}/databases/{database}/sessions/{session}"); | ||
private static final PathTemplate EXTERNAL_HOST_NAME_TEMPLATE = | ||
PathTemplate.create("instances/{instance}/databases/{database}/sessions/{session}"); | ||
private final DatabaseId db; | ||
private final String name; | ||
|
||
|
@@ -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 commentThe 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 commentThe 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 |
||
} | ||
Preconditions.checkArgument( | ||
parts != null, "Name should conform to pattern %s: %s", NAME_TEMPLATE, name); | ||
return of( | ||
parts.get("project"), parts.get("instance"), parts.get("database"), parts.get("session")); | ||
parts.containsKey("project") ? parts.get("project") : "default", | ||
parts.get("instance"), | ||
parts.get("database"), | ||
parts.get("session")); | ||
} | ||
|
||
/** Creates a {@code SessionId} given project, instance, database and session 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.
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?