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, conf *Config, dialect Dialect) driver.Conn
- func NewResult(results []*rdsdata.ExecuteStatementOutput) driver.Result
- func NewRows(dialect Dialect, results []*rdsdata.ExecuteStatementOutput) driver.Rows
- func NewTx(transactionID *string, conn *Connection) driver.Tx
- 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 ¶ added in v0.5.1
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, conf *Config, dialect Dialect) driver.Conn
NewConnection that can make transaction and statement requests against RDS
func NewResult ¶
func NewResult(results []*rdsdata.ExecuteStatementOutput) driver.Result
NewResult for the executed statement
Types ¶
type AWSClientInterface ¶ added in v0.5.0
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 SplitMulti bool Custom map[string][]string }
Config struct used to provide AWS Configuration Credentials
func NewConfig ¶
func NewConfig(resourceARN string, secretARN string, database string, awsRegion string) (conf *Config)
NewConfig with basic values.
func NewConfigFromDSN ¶
NewConfigFromDSN assumes that the DSN is a JSON-encoded string
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 queries 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 queries 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 ¶ added in v0.3.0
NewPostgres dialect from our configuration
type DialectMySQL ¶
type DialectMySQL struct {
// contains filtered or unexported fields
}
DialectMySQL for version 5.7
func (*DialectMySQL) GetFieldConverter ¶ added in v0.2.0
func (d *DialectMySQL) GetFieldConverter(columnType string) FieldConverter
GetFieldConverter knows how to parse column results.
func (*DialectMySQL) IsIsolationLevelSupported ¶ added in v0.2.0
func (d *DialectMySQL) IsIsolationLevelSupported(level driver.IsolationLevel) bool
IsIsolationLevelSupported for mysql?
func (*DialectMySQL) MigrateQuery ¶ added in v0.2.0
func (d *DialectMySQL) MigrateQuery(query string, args []driver.NamedValue) (*rdsdata.ExecuteStatementInput, error)
MigrateQuery converts a mysql queries 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 ¶ added in v0.2.0
func (d *DialectPostgres) GetFieldConverter(columnType string) FieldConverter
GetFieldConverter knows how to parse response data.
func (*DialectPostgres) IsIsolationLevelSupported ¶ added in v0.2.0
func (d *DialectPostgres) IsIsolationLevelSupported(level driver.IsolationLevel) bool
IsIsolationLevelSupported for postgres?
func (*DialectPostgres) MigrateQuery ¶ added in v0.2.0
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 ¶ added in v0.2.0
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 queries
func (*Result) LastInsertId ¶
LastInsertId from the executed statements.
type Rows ¶
type Rows struct {
// contains filtered or unexported fields
}
Rows implementation for the RDS Driver
func (*Rows) HasNextResultSet ¶ added in v0.8.0
HasNextResultSet returns true if there's another result set.
func (*Rows) NextResultSet ¶ added in v0.8.0
NextResultSet moves the result to the next result set.
type Statement ¶
type Statement struct {
// contains filtered or unexported fields
}
Statement encapsulates a single RDS queries statement
func NewStatement ¶
func NewStatement(_ context.Context, connection *Connection, sql []string) *Statement
NewStatement for the provided connection
func (*Statement) ConvertOrdinal ¶ added in v0.2.0
func (s *Statement) ConvertOrdinal(values []driver.Value) []driver.NamedValue
ConvertOrdinal converts a list of Values to Ordinal NamedValues
func (*Statement) Exec ¶
Exec executes a queries 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 queries 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 queries that may return rows, such as a SELECT.