Skip to content

Commit

Permalink
Merge conn: Advertise driver's name & version in STARTUP (apache#1702)
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-sucha committed Jun 12, 2023
2 parents 66d2761 + 73398bd commit a2566b8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
4 changes: 3 additions & 1 deletion conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,9 @@ func (s *startupCoordinator) options(ctx context.Context) error {

func (s *startupCoordinator) startup(ctx context.Context, supported map[string][]string) error {
m := map[string]string{
"CQL_VERSION": s.conn.cfg.CQLVersion,
"CQL_VERSION": s.conn.cfg.CQLVersion,
"DRIVER_NAME": driverName,
"DRIVER_VERSION": driverVersion,
}

if s.conn.compressor != nil {
Expand Down
28 changes: 28 additions & 0 deletions version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package gocql

import "runtime/debug"

const (
mainModule = "github.com/gocql/gocql"
)

var driverName string

var driverVersion string

func init() {
buildInfo, ok := debug.ReadBuildInfo()
if ok {
for _, d := range buildInfo.Deps {
if d.Path == mainModule {
driverName = mainModule
driverVersion = d.Version
if d.Replace != nil {
driverName = d.Replace.Path
driverVersion = d.Replace.Version
}
break
}
}
}
}

0 comments on commit a2566b8

Please sign in to comment.