Documentation ¶
Index ¶
- Constants
- Variables
- func HasBackend(str string) bool
- func IsDuckDBConnectionString(connString string) bool
- func IsMySqlConnectionString(connString string) bool
- func IsPostgresConnectionString(connString string) bool
- func IsSqliteConnectionString(connString string) bool
- type Backend
- type BasicRowReader
- type ConnectConfig
- type ConnectOption
- type DuckDBBackend
- type MySQLBackend
- type PgxConnector
- type PoolConfig
- type PostgresBackend
- func (b *PostgresBackend) Connect(ctx context.Context, opts ...ConnectOption) (*sql.DB, error)
- func (b *PostgresBackend) ConnectionString() string
- func (b *PostgresBackend) Name() string
- func (b *PostgresBackend) OriginalSearchPath() []string
- func (b *PostgresBackend) RequiredSearchPath() []string
- func (b *PostgresBackend) ResolvedSearchPath() []string
- func (b *PostgresBackend) RowReader() RowReader
- type RowReader
- type SearchPathConfig
- type SearchPathProvider
- type SqliteBackend
- type SteampipeBackend
Constants ¶
const ( DefaultMaxConnLifeTime = 10 * time.Minute DefaultMaxConnIdleTime = 1 * time.Minute DefaultMaxOpenConns = 10 )
Variables ¶
var ErrInvalidConfig = errors.New("invalid config")
var ErrUnknownBackend = errors.New("unknown backend")
Functions ¶
func HasBackend ¶
func IsDuckDBConnectionString ¶
IsDuckDBConnectionString returns true if the connection string is for duckdb looks for the duckdb:// prefix
func IsMySqlConnectionString ¶
IsMySqlConnectionString returns true if the connection string is for mysql looks for the mysql:// prefix
func IsPostgresConnectionString ¶
IsPostgresConnectionString returns true if the connection string is for postgres looks for the postgresql:// or postgres:// prefix
func IsSqliteConnectionString ¶
IsSqliteConnectionString returns true if the connection string is for sqlite looks for the sqlite:// prefix
Types ¶
type Backend ¶
type BasicRowReader ¶
type BasicRowReader struct {
CellReader func(columnValue any, col *queryresult.ColumnDef) (any, error)
}
BasicRowReader is a RowReader implementation for generic database/sql driver
func NewBasicRowReader ¶
func NewBasicRowReader() *BasicRowReader
func (*BasicRowReader) Read ¶
func (r *BasicRowReader) Read(columnValues []any, cols []*queryresult.ColumnDef) ([]any, error)
type ConnectConfig ¶
type ConnectConfig struct { MaxConnLifeTime time.Duration MaxConnIdleTime time.Duration MaxOpenConns int SearchPathConfig SearchPathConfig }
func NewConnectConfig ¶
func NewConnectConfig(opts []ConnectOption) *ConnectConfig
type ConnectOption ¶
type ConnectOption func(*ConnectConfig)
func WithConfig ¶
func WithConfig(other *ConnectConfig) ConnectOption
func WithSearchPathConfig ¶
func WithSearchPathConfig(config SearchPathConfig) ConnectOption
WithSearchPathConfig sets the search path to use when connecting to the database. If a prefix is also set, the search path will be resolved to the first matching schema in the search path. Only applies if the backend is postgres
type DuckDBBackend ¶
type DuckDBBackend struct {
// contains filtered or unexported fields
}
func NewDuckDBBackend ¶
func NewDuckDBBackend(connString string) *DuckDBBackend
func (*DuckDBBackend) Connect ¶
func (b *DuckDBBackend) Connect(_ context.Context, options ...ConnectOption) (*sql.DB, error)
Connect implements Backend.
func (*DuckDBBackend) ConnectionString ¶
func (b *DuckDBBackend) ConnectionString() string
func (*DuckDBBackend) Name ¶
func (b *DuckDBBackend) Name() string
func (*DuckDBBackend) RowReader ¶
func (b *DuckDBBackend) RowReader() RowReader
RowReader implements Backend.
type MySQLBackend ¶
type MySQLBackend struct {
// contains filtered or unexported fields
}
func NewMySQLBackend ¶
func NewMySQLBackend(connString string) *MySQLBackend
func (*MySQLBackend) Connect ¶
func (b *MySQLBackend) Connect(_ context.Context, options ...ConnectOption) (*sql.DB, error)
Connect implements Backend.
func (*MySQLBackend) ConnectionString ¶
func (b *MySQLBackend) ConnectionString() string
func (*MySQLBackend) Name ¶
func (b *MySQLBackend) Name() string
func (*MySQLBackend) RowReader ¶
func (b *MySQLBackend) RowReader() RowReader
RowReader implements Backend.
type PgxConnector ¶
type PgxConnector struct { driver.Connector AfterConnectFunc func(context.Context, driver.Conn) error }
PgxConnector is a wrapper around driver.Connector that allows for a callback to be executed after the connection is established.
func NewPgxConnector ¶
type PoolConfig ¶
type PostgresBackend ¶
type PostgresBackend struct {
// contains filtered or unexported fields
}
func NewPostgresBackend ¶
func NewPostgresBackend(ctx context.Context, connString string) (*PostgresBackend, error)
func (*PostgresBackend) Connect ¶
func (b *PostgresBackend) Connect(ctx context.Context, opts ...ConnectOption) (*sql.DB, error)
Connect implements Backend.
func (*PostgresBackend) ConnectionString ¶
func (b *PostgresBackend) ConnectionString() string
func (*PostgresBackend) Name ¶
func (b *PostgresBackend) Name() string
func (*PostgresBackend) OriginalSearchPath ¶
func (b *PostgresBackend) OriginalSearchPath() []string
OriginalSearchPath implements SearchPathProvider.
func (*PostgresBackend) RequiredSearchPath ¶
func (b *PostgresBackend) RequiredSearchPath() []string
RequiredSearchPath implements SearchPathProvider
func (*PostgresBackend) ResolvedSearchPath ¶
func (b *PostgresBackend) ResolvedSearchPath() []string
ResolvedSearchPath implements SearchPathProvider
func (*PostgresBackend) RowReader ¶
func (b *PostgresBackend) RowReader() RowReader
RowReader implements Backend.
type RowReader ¶
type RowReader interface {
Read(columnValues []any, cols []*queryresult.ColumnDef) ([]any, error)
}
type SearchPathConfig ¶
func (SearchPathConfig) Empty ¶
func (c SearchPathConfig) Empty() bool
func (SearchPathConfig) String ¶
func (c SearchPathConfig) String() string
type SearchPathProvider ¶
type SqliteBackend ¶
type SqliteBackend struct {
// contains filtered or unexported fields
}
func NewSqliteBackend ¶
func NewSqliteBackend(connString string) *SqliteBackend
func (*SqliteBackend) Connect ¶
func (b *SqliteBackend) Connect(_ context.Context, options ...ConnectOption) (*sql.DB, error)
Connect implements Backend.
func (*SqliteBackend) ConnectionString ¶
func (b *SqliteBackend) ConnectionString() string
func (*SqliteBackend) Name ¶
func (b *SqliteBackend) Name() string
func (*SqliteBackend) RowReader ¶
func (b *SqliteBackend) RowReader() RowReader
RowReader implements Backend.
type SteampipeBackend ¶
type SteampipeBackend struct { PostgresBackend // map of plugin versions, keyed by image ref PluginVersions map[string]*modconfig.PluginVersionString }
func NewSteampipeBackend ¶
func NewSteampipeBackend(ctx context.Context, postgresBackend PostgresBackend) (*SteampipeBackend, error)
func (*SteampipeBackend) Name ¶
func (b *SteampipeBackend) Name() string