Documentation
¶
Index ¶
- Constants
- Variables
- func ConvertDefaults() func(field types.Field) (value interface{}, err error)
- func ConvertNamedValue(arg driver.NamedValue) (value types.SqlParameter, err error)
- func ConvertNamedValues(args []driver.NamedValue) ([]types.SqlParameter, error)
- func NewConnection(ctx context.Context, rds AWSClientInterface, resourceARN string, ...) driver.Conn
- func NewResult(out *rdsdata.ExecuteStatementOutput) driver.Result
- func NewRows(dialect Dialect, out *rdsdata.ExecuteStatementOutput) driver.Rows
- func NewTx(transactionID *string, conn *Connection) driver.Tx
- func ZippyRDSClient() *sql.DB
- type AWSClientInterface
- type Config
- type Connection
- func (r *Connection) Begin() (driver.Tx, error)
- func (r *Connection) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error)
- func (r *Connection) Close() error
- func (r *Connection) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)
- func (r *Connection) IsValid() bool
- func (r *Connection) Ping(ctx context.Context) (err error)
- func (r *Connection) Prepare(query string) (driver.Stmt, error)
- func (r *Connection) PrepareContext(ctx context.Context, query string) (driver.Stmt, error)
- func (r *Connection) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)
- func (r *Connection) ResetSession(_ context.Context) error
- type Connector
- type Dialect
- type DialectMySQL
- type DialectPostgres
- type Driver
- type FieldConverter
- type Result
- type Rows
- type Statement
- func (s *Statement) Close() error
- func (s *Statement) ConvertOrdinal(values []driver.Value) []driver.NamedValue
- func (s *Statement) Exec(values []driver.Value) (driver.Result, error)
- func (s *Statement) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error)
- func (s *Statement) NumInput() int
- func (s *Statement) Query(values []driver.Value) (driver.Rows, error)
- func (s *Statement) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error)
- type Tx
Constants ¶
const DRIVERNAME = "rds"
DRIVERNAME is used when configuring your dialector
Variables ¶
var ErrClosed = fmt.Errorf("this connection is closed")
ErrClosed indicates that the connection is closed
var ErrInvalidDSNScheme = fmt.Errorf("this driver requires a DSN scheme of rds://")
ErrInvalidDSNScheme for when the dsn doesn't match rds://
var ErrNoMixedParams = fmt.Errorf("please do not mix ordinal and named parameters")
ErrNoMixedParams is thrown if parameters are mixed
Functions ¶
func ConvertDefaults ¶
ConvertDefaults handles all types that can be returned directly without additional conversion.
func ConvertNamedValue ¶
func ConvertNamedValue(arg driver.NamedValue) (value types.SqlParameter, err error)
ConvertNamedValue from a NamedValue to an SqlParameter
func ConvertNamedValues ¶
func ConvertNamedValues(args []driver.NamedValue) ([]types.SqlParameter, error)
ConvertNamedValues converts passed driver.NamedValue instances into RDS SQLParameters
func NewConnection ¶
func NewConnection(ctx context.Context, rds AWSClientInterface, resourceARN string, secretARN string, database string, dialect Dialect) driver.Conn
NewConnection that can make transaction and statement requests against RDS
func NewResult ¶
func NewResult(out *rdsdata.ExecuteStatementOutput) driver.Result
NewResult for the executed statement
func NewRows ¶
func NewRows(dialect Dialect, out *rdsdata.ExecuteStatementOutput) driver.Rows
NewRows instance for the provided statement output
func NewTx ¶
func NewTx(transactionID *string, conn *Connection) driver.Tx
NewTx creates a new transaction
func ZippyRDSClient ¶
Types ¶
type AWSClientInterface ¶
type AWSClientInterface interface {
ExecuteStatement(ctx context.Context, e *rdsdata.ExecuteStatementInput, optFns ...func(*rdsdata.Options)) (*rdsdata.ExecuteStatementOutput, error)
BeginTransaction(ctx context.Context, b *rdsdata.BeginTransactionInput, optFns ...func(*rdsdata.Options)) (*rdsdata.BeginTransactionOutput, error)
CommitTransaction(ctx context.Context, c *rdsdata.CommitTransactionInput, optFns ...func(*rdsdata.Options)) (*rdsdata.CommitTransactionOutput, error)
RollbackTransaction(ctx context.Context, r *rdsdata.RollbackTransactionInput, optFns ...func(*rdsdata.Options)) (*rdsdata.RollbackTransactionOutput, error)
}
AWSClientInterface interface that captures methods required by the driver. In this case, replicating the RDS API
type Config ¶
type Config struct {
ResourceArn string
SecretArn string
Database string
AWSRegion string
ParseTime bool
}
Config struct used to provide AWS Configuration Credentials
func NewConfig ¶
func NewConfig(resourceARN string, secretARN string, database string, awsRegion string) (conf *Config)
NewConfig with specific
func NewConfigFromDSN ¶
NewConfigFromDSN assumes that the DSN is a JSON-encoded string
func ZippyRDSConfig ¶
lookup env vars for gzippy config
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection to RDS's Aurora Serverless Data API
func (*Connection) Begin ¶
func (r *Connection) Begin() (driver.Tx, error)
Begin starts and returns a new transaction.
func (*Connection) ExecContext ¶
func (r *Connection) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)
ExecContext executes a query that would normally not return a result.
func (*Connection) IsValid ¶
func (r *Connection) IsValid() bool
IsValid is called prior to placing the connection into the connection pool. The connection will be discarded if false is returned.
func (*Connection) Ping ¶
func (r *Connection) Ping(ctx context.Context) (err error)
Ping the database
func (*Connection) Prepare ¶
func (r *Connection) Prepare(query string) (driver.Stmt, error)
Prepare returns a prepared statement, bound to this connection.
func (*Connection) PrepareContext ¶
PrepareContext returns a prepared statement, bound to this connection.
func (*Connection) QueryContext ¶
func (r *Connection) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)
QueryContext executes a statement that would return some kind of result.
func (*Connection) ResetSession ¶
func (r *Connection) ResetSession(_ context.Context) error
ResetSession is called prior to executing a query on the connection if the connection has been used before. If the driver returns ErrBadConn the connection is discarded.
type Connector ¶
type Connector struct {
// contains filtered or unexported fields
}
Connector spits out connections to our database.
func NewConnector ¶
func NewConnector(d driver.Driver, client AWSClientInterface, conf *Config) *Connector
NewConnector from the provided configuration fields
type Dialect ¶
type Dialect interface {
// MigrateQuery from the dialect to RDS
MigrateQuery(string, []driver.NamedValue) (*rdsdata.ExecuteStatementInput, error)
// GetFieldConverter for a given ColumnMetadata.TypeName field.
GetFieldConverter(columnType string) FieldConverter
// IsIsolationLevelSupported for this dialect?
IsIsolationLevelSupported(level driver.IsolationLevel) bool
}
Dialect is an interface that encapsulates a particular languages' eccentricities
func NewPostgres ¶
NewPostgres dialect from our configuration
type DialectMySQL ¶
type DialectMySQL struct {
// contains filtered or unexported fields
}
DialectMySQL for version 5.7
func (*DialectMySQL) GetFieldConverter ¶
func (d *DialectMySQL) GetFieldConverter(columnType string) FieldConverter
GetFieldConverter knows how to parse column results.
func (*DialectMySQL) IsIsolationLevelSupported ¶
func (d *DialectMySQL) IsIsolationLevelSupported(level driver.IsolationLevel) bool
IsIsolationLevelSupported for mysql?
func (*DialectMySQL) MigrateQuery ¶
func (d *DialectMySQL) MigrateQuery(query string, args []driver.NamedValue) (*rdsdata.ExecuteStatementInput, error)
MigrateQuery converts a mysql query into an RDS stateement.
type DialectPostgres ¶
type DialectPostgres struct {
// contains filtered or unexported fields
}
DialectPostgres is for postgres 10.14 as supported by aurora serverless
func (*DialectPostgres) GetFieldConverter ¶
func (d *DialectPostgres) GetFieldConverter(columnType string) FieldConverter
GetFieldConverter knows how to parse response data.
func (*DialectPostgres) IsIsolationLevelSupported ¶
func (d *DialectPostgres) IsIsolationLevelSupported(level driver.IsolationLevel) bool
IsIsolationLevelSupported for postgres?
func (*DialectPostgres) MigrateQuery ¶
func (d *DialectPostgres) MigrateQuery(query string, args []driver.NamedValue) (*rdsdata.ExecuteStatementInput, error)
MigrateQuery from Postgres to RDS.
type Driver ¶
type Driver struct{}
Driver implements the driver.Driver interface for RDS
type FieldConverter ¶
FieldConverter is a function that converts the passed result row field into the expected type.
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result from a query
func (*Result) LastInsertId ¶
LastInsertId from the executed statement.
type Rows ¶
type Rows struct {
// contains filtered or unexported fields
}
Rows implementation for the RDS Driver
type Statement ¶
type Statement struct {
// contains filtered or unexported fields
}
Statement encapsulates a single RDS query statement
func NewStatement ¶
func NewStatement(_ context.Context, connection *Connection, sql string) *Statement
NewStatement for the provided connection
func (*Statement) ConvertOrdinal ¶
func (s *Statement) ConvertOrdinal(values []driver.Value) []driver.NamedValue
ConvertOrdinal converts a list of Values to Ordinal NamedValues
func (*Statement) Exec ¶
Exec executes a query that doesn't return rows, such as an INSERT or UPDATE.
func (*Statement) ExecContext ¶
func (s *Statement) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error)
ExecContext executes a query that doesn't return rows, such as an INSERT or UPDATE.
func (*Statement) QueryContext ¶
func (s *Statement) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error)
QueryContext executes a query that may return rows, such as a SELECT.