Skip to content

Commit

Permalink
release 0.109.1
Browse files Browse the repository at this point in the history
  • Loading branch information
stfnmllr committed Oct 21, 2022
1 parent 7cd5634 commit 7a12c2a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 17 deletions.
4 changes: 4 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ Release Notes

## Release 0.109

Release 0.109.1 (upgrade urgency: no need for upgrade)

- Some minor source code cleanups

#### Release Notes

- Moved prometheus collector from ./driver/prometheus to ./prometheus (incompatible change)
Expand Down
44 changes: 28 additions & 16 deletions driver/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ type Connector struct {
*connAttrs
*authAttrs

newConn func(ctx context.Context, connAttrs *connAttrs, authAttrs *authAttrs) (driver.Conn, error)
connHook func(driver.Conn) driver.Conn
newConn func(ctx context.Context, connAttrs *connAttrs, authAttrs *authAttrs) (driver.Conn, error)
}

// NewConnector returns a new Connector instance with default values.
Expand All @@ -35,18 +36,18 @@ func NewConnector() *Connector {
// NewBasicAuthConnector creates a connector for basic authentication.
func NewBasicAuthConnector(host, username, password string) *Connector {
c := NewConnector()
c.connAttrs._host = host
c.authAttrs._username = username
c.authAttrs._password = password
c._host = host
c._username = username
c._password = password
return c
}

// NewX509AuthConnector creates a connector for X509 (client certificate) authentication.
func NewX509AuthConnector(host string, clientCert, clientKey []byte) *Connector {
c := NewConnector()
c.connAttrs._host = host
c.authAttrs._clientCert = clientCert
c.authAttrs._clientKey = clientKey
c._host = host
c._clientCert = clientCert
c._clientKey = clientKey
return c
}

Expand All @@ -67,24 +68,24 @@ func NewX509AuthConnectorByFiles(host, clientCertFile, clientKeyFile string) (*C
// NewJWTAuthConnector creates a connector for token (JWT) based authentication.
func NewJWTAuthConnector(host, token string) *Connector {
c := NewConnector()
c.connAttrs._host = host
c.authAttrs._token = token
c._host = host
c._token = token
return c
}

func newDSNConnector(dsn *DSN) (*Connector, error) {
c := NewConnector()
c.connAttrs._host = dsn.host
c.connAttrs._pingInterval = dsn.pingInterval
c.connAttrs._defaultSchema = dsn.defaultSchema
c.connAttrs.setTimeout(dsn.timeout)
c._host = dsn.host
c._pingInterval = dsn.pingInterval
c._defaultSchema = dsn.defaultSchema
c.setTimeout(dsn.timeout)
if dsn.tls != nil {
if err := c.connAttrs.setTLS(dsn.tls.ServerName, dsn.tls.InsecureSkipVerify, dsn.tls.RootCAFiles); err != nil {
return nil, err
}
}
c.authAttrs._username = dsn.username
c.authAttrs._password = dsn.password
c._username = dsn.username
c._password = dsn.password
return c, nil
}

Expand All @@ -102,8 +103,19 @@ func (c *Connector) NativeDriver() Driver { return stdHdbDriver }

// Connect implements the database/sql/driver/Connector interface.
func (c *Connector) Connect(ctx context.Context) (driver.Conn, error) {
return c.newConn(ctx, c.connAttrs.clone(), c.authAttrs)
conn, err := c.newConn(ctx, c.connAttrs.clone(), c.authAttrs)
if err != nil {
return nil, err
}
if c.connHook != nil {
conn = c.connHook(conn)
}
return conn, err
}

// Driver implements the database/sql/driver/Connector interface.
func (c *Connector) Driver() driver.Driver { return stdHdbDriver }

// SetConnHook sets a function for intercepting connection creation.
// This is for internal use only and might be changed or disabled in future.
func (c *Connector) SetConnHook(fn func(driver.Conn) driver.Conn) { c.connHook = fn }
2 changes: 1 addition & 1 deletion driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

// DriverVersion is the version number of the hdb driver.
const DriverVersion = "0.109.0"
const DriverVersion = "0.109.1"

// DriverName is the driver name to use with sql.Open for hdb databases.
const DriverName = "hdb"
Expand Down

0 comments on commit 7a12c2a

Please sign in to comment.