-
Notifications
You must be signed in to change notification settings - Fork 2.3k
vtgateconn minor enhancements #18551
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
Changes from 4 commits
21980b5
63cf46a
34d328b
a143002
19c4d91
21f387f
9cc3c20
a3593e4
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 |
|---|---|---|
|
|
@@ -39,11 +39,12 @@ import ( | |
| ) | ||
|
|
||
| var ( | ||
| cert string | ||
| key string | ||
| ca string | ||
| crl string | ||
| name string | ||
| cert string | ||
| key string | ||
| ca string | ||
| crl string | ||
| name string | ||
| failFast bool | ||
| ) | ||
|
|
||
| func init() { | ||
|
|
@@ -56,16 +57,17 @@ func init() { | |
| "vtctl", | ||
| "vttestserver", | ||
| } { | ||
| servenv.OnParseFor(cmd, registerFlags) | ||
| servenv.OnParseFor(cmd, RegisterFlags) | ||
| } | ||
| } | ||
|
|
||
| func registerFlags(fs *pflag.FlagSet) { | ||
| func RegisterFlags(fs *pflag.FlagSet) { | ||
|
Member
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. Is there a reason for making this public? It doesn't seem necessary?
Member
Author
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. Yes it is -- As I mentioned in the related issue description, the main reason for these changes is our "vtgateproxy" binary which in essence is a mash-up of a mysql server module to accept connections from our app, and the vtgate grpc interface which we use to route those queries. To make that work, we want to be able to call this function to be able to register flags as part of the app initialization since we can't put "vtgateproxy" in the list of explicitly opted-in binaries above. |
||
| utils.SetFlagStringVar(fs, &cert, "vtgate-grpc-cert", "", "the cert to use to connect") | ||
| utils.SetFlagStringVar(fs, &key, "vtgate-grpc-key", "", "the key to use to connect") | ||
| utils.SetFlagStringVar(fs, &ca, "vtgate-grpc-ca", "", "the server ca to use to validate servers when connecting") | ||
| utils.SetFlagStringVar(fs, &crl, "vtgate-grpc-crl", "", "the server crl to use to validate server certificates when connecting") | ||
| utils.SetFlagStringVar(fs, &name, "vtgate-grpc-server-name", "", "the server name to use to validate server certificate") | ||
| utils.SetFlagBoolVar(fs, &failFast, "vtgate-grpc-fail-fast", false, "whether to enable grpc fail fast when communicating with vtgate") | ||
| } | ||
|
|
||
| type vtgateConn struct { | ||
|
|
@@ -87,7 +89,7 @@ func Dial(opts ...grpc.DialOption) vtgateconn.DialerFunc { | |
|
|
||
| opts = append(opts, opt) | ||
|
|
||
| cc, err := grpcclient.DialContext(ctx, address, grpcclient.FailFast(false), opts...) | ||
| cc, err := grpcclient.DialContext(ctx, address, grpcclient.FailFast(failFast), opts...) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /* | ||
| Copyright 2019 The Vitess Authors. | ||
| Copyright 2024 The Vitess Authors. | ||
demmer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
|
|
@@ -171,6 +171,11 @@ func (sn *VTGateSession) Prepare(ctx context.Context, query string) ([]*querypb. | |
| return fields, paramsCount, err | ||
| } | ||
|
|
||
| // CloseSession closes the session provided by rolling back any active transaction. | ||
| func (sn *VTGateSession) CloseSession(ctx context.Context) error { | ||
| return sn.impl.CloseSession(ctx, sn.session) | ||
| } | ||
|
|
||
|
Member
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. We should have tests for this to describe why this is needed. We do run stuff like https://go.dev/blog/deadcode on the codebase to clean up unused parts and it would identify this and we're remove it again. Making sure it's at least tested and described in the tests why it's needed would be required to at least try to avoid it being removed again in the future.
Member
Author
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. OK. I added a test for this to the framework. Took a bit of wrangling for the existing tests and the fake server to track "active txns" to make this work, but it is now tested. |
||
| // | ||
| // The rest of this file is for the protocol implementations. | ||
| // | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.