sql

package
v1.4.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAuthenticationError

func IsAuthenticationError(err error) bool

IsAuthenticationError checks if given error is know auth error.

func NewAuthRefreshDriver

func NewAuthRefreshDriver(d driver.Driver, a AuthProvider) driver.Driver

NewAuthRefreshDriver wraps given sql.Driver and uses AuthLoader to fetch new DNS in case of auth error.

Types

type AuthProvider

type AuthProvider interface {
	DSN() (string, error)
	IsAuthErr(error) bool
}

AuthProvider is used for refreshing DB credentials.

type AuthRefreshDriver

type AuthRefreshDriver struct {
	// contains filtered or unexported fields
}

AuthRefreshDriver wraps a sql.Driver with automatic credentials reloading.

func (*AuthRefreshDriver) Connect

func (d *AuthRefreshDriver) Connect(ctx context.Context) (driver.Conn, error)

Connect call's driver.Open which automatically refreshes credentials on Auth error.

func (*AuthRefreshDriver) Driver

func (d *AuthRefreshDriver) Driver() driver.Driver

Driver return pointer to itself.

func (*AuthRefreshDriver) Open

func (d *AuthRefreshDriver) Open(_ string) (conn driver.Conn, err error)

Open tries opening new connection and automatically refreshes credentials on Auth error.

func (*AuthRefreshDriver) OpenConnector

func (d *AuthRefreshDriver) OpenConnector(_ string) (driver.Connector, error)

OpenConnector return pointer to driver itself which implements also driver.Connector.

type BuildAuthTokenFn

type BuildAuthTokenFn func(ctx context.Context,
	endpoint, region, dbUser string,
	creds aws.CredentialsProvider,
	optFns ...func(options *auth.BuildAuthTokenOptions)) (string, error)

type IAMAuth

type IAMAuth struct {
	Host, DBUser, DBPassword, DBRegion, SSLMode, DBName string
	Port                                                int
	BuildAuthToken                                      BuildAuthTokenFn
}

IAMAuth implements AuthProvider and generates IAM DB credentials.

func (*IAMAuth) DSN

func (i *IAMAuth) DSN() (string, error)

DSN will trigger reparsing of configuration and return DSN or an error.

func (*IAMAuth) IsAuthErr

func (*IAMAuth) IsAuthErr(err error) bool

IsAuthErr checks if given error is know auth error.

func (*IAMAuth) RefreshPassword

func (i *IAMAuth) RefreshPassword() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL