-
Notifications
You must be signed in to change notification settings - Fork 1.9k
chore(spanner): Add support for experimental endpoint #5527
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
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 |
|---|---|---|
|
|
@@ -30,6 +30,9 @@ import ( | |
|
|
||
| "cloud.google.com/go/spanner" | ||
| "google.golang.org/api/iterator" | ||
| "google.golang.org/api/option" | ||
| "google.golang.org/grpc" | ||
| "google.golang.org/grpc/credentials/insecure" | ||
|
|
||
| "cloud.google.com/go/iam/apiv1/iampb" | ||
| database "cloud.google.com/go/spanner/admin/database/apiv1" | ||
|
|
@@ -824,14 +827,25 @@ func run(ctx context.Context, w io.Writer, cmd string, db string, arg string) er | |
| cfg := spanner.ClientConfig{ | ||
| DatabaseRole: databaseRole, | ||
| } | ||
| opts := []option.ClientOption{} | ||
|
|
||
| adminClient, err := database.NewDatabaseAdminClient(ctx) | ||
| endpoint := os.Getenv("EXPERIMENTAL_HOST") | ||
|
Contributor
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. |
||
| if endpoint != "" { | ||
| opts = append(opts, | ||
| option.WithEndpoint(endpoint), | ||
| option.WithGRPCDialOption(grpc.WithTransportCredentials(insecure.NewCredentials())), | ||
| option.WithoutAuthentication(), | ||
| ) | ||
| cfg.IsExperimentalHost = true | ||
| } | ||
|
|
||
| adminClient, err := database.NewDatabaseAdminClient(ctx, opts...) | ||
|
Contributor
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. The |
||
| if err != nil { | ||
| log.Fatal(err) | ||
| } | ||
| defer adminClient.Close() | ||
|
|
||
| dataClient, err := spanner.NewClientWithConfig(ctx, db, cfg) | ||
| dataClient, err := spanner.NewClientWithConfig(ctx, db, cfg, opts...) | ||
|
Contributor
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. |
||
| if err != nil { | ||
| log.Fatal(err) | ||
| } | ||
|
|
||
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.
In Go, it is more idiomatic to use
varfor an empty slice that will be appended to, rather than an empty slice literal. This avoids an unnecessary allocation and is generally preferred when the slice's initial capacity is not known.References