This is an automated email from the ASF dual-hosted git repository.
zeroshade pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git
The following commit(s) were added to refs/heads/main by this push:
new f120c5e feat(go/adbc/driver/flightsql): add user-agent for driver
(#497)
f120c5e is described below
commit f120c5e952897cc133ff944ee06571664eceda74
Author: David Li <[email protected]>
AuthorDate: Wed Mar 8 14:00:34 2023 -0500
feat(go/adbc/driver/flightsql): add user-agent for driver (#497)
Fixes #491.
---
go/adbc/driver/flightsql/flightsql_adbc.go | 9 +++++++++
go/adbc/driver/flightsql/flightsql_adbc_test.go | 23 +++++++++++++++++++++--
2 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/go/adbc/driver/flightsql/flightsql_adbc.go
b/go/adbc/driver/flightsql/flightsql_adbc.go
index 2d00216..d77369d 100644
--- a/go/adbc/driver/flightsql/flightsql_adbc.go
+++ b/go/adbc/driver/flightsql/flightsql_adbc.go
@@ -104,6 +104,14 @@ func init() {
}
}
}
+ // XXX: Deps not populated in tests
+ // https://github.com/golang/go/issues/33976
+ if infoDriverVersion == "" {
+ infoDriverVersion = "(unknown or development build)"
+ }
+ if infoDriverArrowVersion == "" {
+ infoDriverArrowVersion = "(unknown or development build)"
+ }
infoSupportedCodes = []adbc.InfoCode{
adbc.InfoDriverName,
@@ -167,6 +175,7 @@ func (d *dbDialOpts) rebuild() {
d.opts = []grpc.DialOption{
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(d.maxMsgSize),
grpc.MaxCallSendMsgSize(d.maxMsgSize)),
+ grpc.WithUserAgent("ADBC Flight SQL Driver " +
infoDriverVersion),
}
if d.block {
d.opts = append(d.opts, grpc.WithBlock())
diff --git a/go/adbc/driver/flightsql/flightsql_adbc_test.go
b/go/adbc/driver/flightsql/flightsql_adbc_test.go
index 045b542..c73a8fb 100644
--- a/go/adbc/driver/flightsql/flightsql_adbc_test.go
+++ b/go/adbc/driver/flightsql/flightsql_adbc_test.go
@@ -225,9 +225,9 @@ func (s *FlightSQLQuirks) GetMetadata(code adbc.InfoCode)
interface{} {
// runtime/debug.ReadBuildInfo doesn't currently work for tests
// github.com/golang/go/issues/33976
case adbc.InfoDriverVersion:
- return ""
+ return "(unknown or development build)"
case adbc.InfoDriverArrowVersion:
- return ""
+ return "(unknown or development build)"
case adbc.InfoVendorName:
return "db_name"
case adbc.InfoVendorVersion:
@@ -587,6 +587,25 @@ func (suite *HeaderTests) TestDatabaseOptAuthorization() {
suite.Contains(suite.Quirks.middle.recordedHeaders.Get("authorization"),
"auth-header-token")
}
+func (suite *HeaderTests) TestUserAgent() {
+ stmt, err := suite.Cnxn.NewStatement()
+ suite.Require().NoError(err)
+ defer func() {
+ suite.Require().NoError(stmt.Close())
+ }()
+
+ suite.Require().NoError(stmt.SetSqlQuery("timeout"))
+ _, _, err = stmt.ExecuteQuery(suite.ctx)
+ suite.Error(err)
+
+ userAgents := suite.Quirks.middle.recordedHeaders.Get("user-agent")
+ suite.NotEmpty(userAgents)
+ for _, agent := range userAgents {
+ suite.Contains(agent, "ADBC Flight SQL Driver")
+ suite.Contains(agent, "grpc-go")
+ }
+}
+
func (suite *HeaderTests) TestConnection() {
// can't change authorization header on connection, you have to set it
// as an option on the database object when creating the connection.