Documentation ¶
Overview ¶
Package driverbase provides a framework for implementing ADBC drivers in Go. It intends to reduce boilerplate for common functionality and managing state transitions.
Index ¶
- Constants
- type AutocommitSetter
- type Connection
- type ConnectionBuilder
- func (b *ConnectionBuilder) Connection() Connection
- func (b *ConnectionBuilder) WithAutocommitSetter(helper AutocommitSetter) *ConnectionBuilder
- func (b *ConnectionBuilder) WithCurrentNamespacer(helper CurrentNamespacer) *ConnectionBuilder
- func (b *ConnectionBuilder) WithDbObjectsEnumerator(helper DbObjectsEnumerator) *ConnectionBuilder
- func (b *ConnectionBuilder) WithDriverInfoPreparer(helper DriverInfoPreparer) *ConnectionBuilder
- func (b *ConnectionBuilder) WithTableTypeLister(helper TableTypeLister) *ConnectionBuilder
- type ConnectionImpl
- type ConnectionImplBase
- func (base *ConnectionImplBase) Base() *ConnectionImplBase
- func (base *ConnectionImplBase) Close() error
- func (base *ConnectionImplBase) Commit(ctx context.Context) error
- func (base *ConnectionImplBase) GetInfo(ctx context.Context, infoCodes []adbc.InfoCode) (array.RecordReader, error)
- func (base *ConnectionImplBase) GetObjects(ctx context.Context, depth adbc.ObjectDepth, catalog *string, dbSchema *string, ...) (array.RecordReader, error)
- func (base *ConnectionImplBase) GetOption(key string) (string, error)
- func (base *ConnectionImplBase) GetOptionBytes(key string) ([]byte, error)
- func (base *ConnectionImplBase) GetOptionDouble(key string) (float64, error)
- func (base *ConnectionImplBase) GetOptionInt(key string) (int64, error)
- func (base *ConnectionImplBase) GetTableSchema(ctx context.Context, catalog *string, dbSchema *string, tableName string) (*arrow.Schema, error)
- func (base *ConnectionImplBase) GetTableTypes(context.Context) (array.RecordReader, error)
- func (base *ConnectionImplBase) NewStatement() (adbc.Statement, error)
- func (base *ConnectionImplBase) ReadPartition(ctx context.Context, serializedPartition []byte) (array.RecordReader, error)
- func (base *ConnectionImplBase) Rollback(context.Context) error
- func (base *ConnectionImplBase) SetOption(key string, val string) error
- func (base *ConnectionImplBase) SetOptionBytes(key string, val []byte) error
- func (base *ConnectionImplBase) SetOptionDouble(key string, val float64) error
- func (base *ConnectionImplBase) SetOptionInt(key string, val int64) error
- type CurrentNamespacer
- type Database
- type DatabaseImpl
- type DatabaseImplBase
- func (base *DatabaseImplBase) Base() *DatabaseImplBase
- func (base *DatabaseImplBase) Close() error
- func (base *DatabaseImplBase) GetOption(key string) (string, error)
- func (base *DatabaseImplBase) GetOptionBytes(key string) ([]byte, error)
- func (base *DatabaseImplBase) GetOptionDouble(key string) (float64, error)
- func (base *DatabaseImplBase) GetOptionInt(key string) (int64, error)
- func (base *DatabaseImplBase) Open(ctx context.Context) (adbc.Connection, error)
- func (base *DatabaseImplBase) SetOption(key string, val string) error
- func (base *DatabaseImplBase) SetOptionBytes(key string, val []byte) error
- func (base *DatabaseImplBase) SetOptionDouble(key string, val float64) error
- func (base *DatabaseImplBase) SetOptionInt(key string, val int64) error
- func (base *DatabaseImplBase) SetOptions(options map[string]string) error
- type DbObjectsEnumerator
- type Driver
- type DriverImpl
- type DriverImplBase
- type DriverInfo
- func (di *DriverInfo) GetInfoDriverADBCVersion() (int64, bool)
- func (di *DriverInfo) GetInfoDriverArrowVersion() (string, bool)
- func (di *DriverInfo) GetInfoDriverName() (string, bool)
- func (di *DriverInfo) GetInfoDriverVersion() (string, bool)
- func (di *DriverInfo) GetInfoForInfoCode(code adbc.InfoCode) (any, bool)
- func (di *DriverInfo) GetInfoVendorArrowVersion() (string, bool)
- func (di *DriverInfo) GetInfoVendorName() (string, bool)
- func (di *DriverInfo) GetInfoVendorVersion() (string, bool)
- func (di *DriverInfo) GetName() string
- func (di *DriverInfo) InfoSupportedCodes() []adbc.InfoCode
- func (di *DriverInfo) RegisterInfoCode(code adbc.InfoCode, value any) error
- type DriverInfoPreparer
- type ErrorHelper
- type TableTypeLister
Constants ¶
const ( ConnectionMessageOptionUnknown = "Unknown connection option" ConnectionMessageOptionUnsupported = "Unsupported connection option" ConnectionMessageCannotCommit = "Cannot commit when autocommit is enabled" ConnectionMessageCannotRollback = "Cannot rollback when autocommit is enabled" )
const ( UnknownVersion = "(unknown or development build)" DefaultInfoDriverADBCVersion = adbc.AdbcVersion1_1_0 )
const (
DatabaseMessageOptionUnknown = "Unknown database option"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AutocommitSetter ¶
AutocommitSetter is an interface that drivers may implement to simplify the implementation of autocommit state management. There is no need to implement this for backends that do not support autocommit, as this is already the default behavior. SetAutocommit should only attempt to update the autocommit state in the backend. Local driver state is automatically updated if the result of this call does not produce an error. (Get/Set)Options implementations are provided automatically as well/
type Connection ¶
type Connection interface { adbc.Connection adbc.GetSetOptions }
Connection is the interface satisfied by the result of the NewConnection constructor, given that an input is provided satisfying the ConnectionImpl interface.
type ConnectionBuilder ¶
type ConnectionBuilder struct {
// contains filtered or unexported fields
}
func NewConnectionBuilder ¶
func NewConnectionBuilder(impl ConnectionImpl) *ConnectionBuilder
func (*ConnectionBuilder) Connection ¶
func (b *ConnectionBuilder) Connection() Connection
func (*ConnectionBuilder) WithAutocommitSetter ¶
func (b *ConnectionBuilder) WithAutocommitSetter(helper AutocommitSetter) *ConnectionBuilder
func (*ConnectionBuilder) WithCurrentNamespacer ¶
func (b *ConnectionBuilder) WithCurrentNamespacer(helper CurrentNamespacer) *ConnectionBuilder
func (*ConnectionBuilder) WithDbObjectsEnumerator ¶
func (b *ConnectionBuilder) WithDbObjectsEnumerator(helper DbObjectsEnumerator) *ConnectionBuilder
func (*ConnectionBuilder) WithDriverInfoPreparer ¶
func (b *ConnectionBuilder) WithDriverInfoPreparer(helper DriverInfoPreparer) *ConnectionBuilder
func (*ConnectionBuilder) WithTableTypeLister ¶
func (b *ConnectionBuilder) WithTableTypeLister(helper TableTypeLister) *ConnectionBuilder
type ConnectionImpl ¶
type ConnectionImpl interface { adbc.Connection adbc.GetSetOptions Base() *ConnectionImplBase }
ConnectionImpl is an interface that drivers implement to provide vendor-specific functionality.
type ConnectionImplBase ¶
type ConnectionImplBase struct { Alloc memory.Allocator ErrorHelper ErrorHelper DriverInfo *DriverInfo Logger *slog.Logger Autocommit bool Closed bool }
ConnectionImplBase is a struct that provides default implementations of the ConnectionImpl interface. It is meant to be used as a composite struct for a driver's ConnectionImpl implementation.
func NewConnectionImplBase ¶
func NewConnectionImplBase(database *DatabaseImplBase) ConnectionImplBase
NewConnectionImplBase instantiates ConnectionImplBase.
- database is a DatabaseImplBase containing the common resources from the parent database, allowing the Arrow allocator, error handler, and logger to be reused.
func (*ConnectionImplBase) Base ¶
func (base *ConnectionImplBase) Base() *ConnectionImplBase
func (*ConnectionImplBase) Close ¶
func (base *ConnectionImplBase) Close() error
func (*ConnectionImplBase) Commit ¶
func (base *ConnectionImplBase) Commit(ctx context.Context) error
func (*ConnectionImplBase) GetInfo ¶
func (base *ConnectionImplBase) GetInfo(ctx context.Context, infoCodes []adbc.InfoCode) (array.RecordReader, error)
func (*ConnectionImplBase) GetObjects ¶
func (base *ConnectionImplBase) GetObjects(ctx context.Context, depth adbc.ObjectDepth, catalog *string, dbSchema *string, tableName *string, columnName *string, tableType []string) (array.RecordReader, error)
func (*ConnectionImplBase) GetOption ¶
func (base *ConnectionImplBase) GetOption(key string) (string, error)
func (*ConnectionImplBase) GetOptionBytes ¶
func (base *ConnectionImplBase) GetOptionBytes(key string) ([]byte, error)
func (*ConnectionImplBase) GetOptionDouble ¶
func (base *ConnectionImplBase) GetOptionDouble(key string) (float64, error)
func (*ConnectionImplBase) GetOptionInt ¶
func (base *ConnectionImplBase) GetOptionInt(key string) (int64, error)
func (*ConnectionImplBase) GetTableSchema ¶
func (*ConnectionImplBase) GetTableTypes ¶
func (base *ConnectionImplBase) GetTableTypes(context.Context) (array.RecordReader, error)
func (*ConnectionImplBase) NewStatement ¶
func (base *ConnectionImplBase) NewStatement() (adbc.Statement, error)
func (*ConnectionImplBase) ReadPartition ¶
func (base *ConnectionImplBase) ReadPartition(ctx context.Context, serializedPartition []byte) (array.RecordReader, error)
func (*ConnectionImplBase) Rollback ¶
func (base *ConnectionImplBase) Rollback(context.Context) error
func (*ConnectionImplBase) SetOption ¶
func (base *ConnectionImplBase) SetOption(key string, val string) error
func (*ConnectionImplBase) SetOptionBytes ¶
func (base *ConnectionImplBase) SetOptionBytes(key string, val []byte) error
func (*ConnectionImplBase) SetOptionDouble ¶
func (base *ConnectionImplBase) SetOptionDouble(key string, val float64) error
func (*ConnectionImplBase) SetOptionInt ¶
func (base *ConnectionImplBase) SetOptionInt(key string, val int64) error
type CurrentNamespacer ¶
type CurrentNamespacer interface { GetCurrentCatalog() (string, error) GetCurrentDbSchema() (string, error) SetCurrentCatalog(string) error SetCurrentDbSchema(string) error }
CurrentNamespacer is an interface that drivers may implement to delegate stateful namespacing with DB catalogs and schemas. The appropriate (Get/Set)Options implementations will be provided using the results of these methods.
type Database ¶
type Database interface { adbc.Database adbc.GetSetOptions adbc.DatabaseLogging }
Database is the interface satisfied by the result of the NewDatabase constructor, given an input is provided satisfying the DatabaseImpl interface.
func NewDatabase ¶
func NewDatabase(impl DatabaseImpl) Database
NewDatabase wraps a DatabaseImpl to create an adbc.Database.
type DatabaseImpl ¶
type DatabaseImpl interface { adbc.Database adbc.GetSetOptions Base() *DatabaseImplBase }
DatabaseImpl is an interface that drivers implement to provide vendor-specific functionality.
type DatabaseImplBase ¶
type DatabaseImplBase struct { Alloc memory.Allocator ErrorHelper ErrorHelper DriverInfo *DriverInfo Logger *slog.Logger }
DatabaseImplBase is a struct that provides default implementations of the DatabaseImpl interface. It is meant to be used as a composite struct for a driver's DatabaseImpl implementation.
func NewDatabaseImplBase ¶
func NewDatabaseImplBase(driver *DriverImplBase) DatabaseImplBase
NewDatabaseImplBase instantiates DatabaseImplBase.
- driver is a DriverImplBase containing the common resources from the parent driver, allowing the Arrow allocator and error handler to be reused.
func (*DatabaseImplBase) Base ¶
func (base *DatabaseImplBase) Base() *DatabaseImplBase
func (*DatabaseImplBase) Close ¶
func (base *DatabaseImplBase) Close() error
func (*DatabaseImplBase) GetOption ¶
func (base *DatabaseImplBase) GetOption(key string) (string, error)
func (*DatabaseImplBase) GetOptionBytes ¶
func (base *DatabaseImplBase) GetOptionBytes(key string) ([]byte, error)
func (*DatabaseImplBase) GetOptionDouble ¶
func (base *DatabaseImplBase) GetOptionDouble(key string) (float64, error)
func (*DatabaseImplBase) GetOptionInt ¶
func (base *DatabaseImplBase) GetOptionInt(key string) (int64, error)
func (*DatabaseImplBase) Open ¶
func (base *DatabaseImplBase) Open(ctx context.Context) (adbc.Connection, error)
func (*DatabaseImplBase) SetOption ¶
func (base *DatabaseImplBase) SetOption(key string, val string) error
func (*DatabaseImplBase) SetOptionBytes ¶
func (base *DatabaseImplBase) SetOptionBytes(key string, val []byte) error
func (*DatabaseImplBase) SetOptionDouble ¶
func (base *DatabaseImplBase) SetOptionDouble(key string, val float64) error
func (*DatabaseImplBase) SetOptionInt ¶
func (base *DatabaseImplBase) SetOptionInt(key string, val int64) error
func (*DatabaseImplBase) SetOptions ¶
func (base *DatabaseImplBase) SetOptions(options map[string]string) error
type DbObjectsEnumerator ¶
type DbObjectsEnumerator interface { GetObjectsCatalogs(ctx context.Context, catalog *string) ([]string, error) GetObjectsDbSchemas(ctx context.Context, depth adbc.ObjectDepth, catalog *string, schema *string, metadataRecords []internal.Metadata) (map[string][]string, error) GetObjectsTables(ctx context.Context, depth adbc.ObjectDepth, catalog *string, schema *string, tableName *string, columnName *string, tableType []string, metadataRecords []internal.Metadata) (map[internal.CatalogAndSchema][]internal.TableInfo, error) }
DbObjectsEnumerator is an interface that drivers may implement to simplify the implementation of adbc.Connection.GetObjects(). By independently implementing lookup for catalogs, dbSchemas and tables, the driverbase is able to provide the full GetObjects functionality for arbitrary search patterns and lookup depth.
type Driver ¶
Driver is the interface satisfied by the result of the NewDriver constructor, given an input is provided satisfying the DriverImpl interface.
func NewDriver ¶
func NewDriver(impl DriverImpl) Driver
NewDriver wraps a DriverImpl to create a Driver.
type DriverImpl ¶
type DriverImpl interface { adbc.Driver Base() *DriverImplBase }
DriverImpl is an interface that drivers implement to provide vendor-specific functionality.
type DriverImplBase ¶
type DriverImplBase struct { Alloc memory.Allocator ErrorHelper ErrorHelper DriverInfo *DriverInfo }
DriverImplBase is a struct that provides default implementations of the DriverImpl interface. It is meant to be used as a composite struct for a driver's DriverImpl implementation.
func NewDriverImplBase ¶
func NewDriverImplBase(info *DriverInfo, alloc memory.Allocator) DriverImplBase
NewDriverImplBase instantiates DriverImplBase.
- info contains build and vendor info, as well as the name to construct error messages.
- alloc is an Arrow allocator to use.
func (*DriverImplBase) Base ¶
func (base *DriverImplBase) Base() *DriverImplBase
func (*DriverImplBase) NewDatabase ¶
type DriverInfo ¶
type DriverInfo struct {
// contains filtered or unexported fields
}
func DefaultDriverInfo ¶
func DefaultDriverInfo(name string) *DriverInfo
func (*DriverInfo) GetInfoDriverADBCVersion ¶
func (di *DriverInfo) GetInfoDriverADBCVersion() (int64, bool)
func (*DriverInfo) GetInfoDriverArrowVersion ¶
func (di *DriverInfo) GetInfoDriverArrowVersion() (string, bool)
func (*DriverInfo) GetInfoDriverName ¶
func (di *DriverInfo) GetInfoDriverName() (string, bool)
func (*DriverInfo) GetInfoDriverVersion ¶
func (di *DriverInfo) GetInfoDriverVersion() (string, bool)
func (*DriverInfo) GetInfoForInfoCode ¶
func (di *DriverInfo) GetInfoForInfoCode(code adbc.InfoCode) (any, bool)
func (*DriverInfo) GetInfoVendorArrowVersion ¶
func (di *DriverInfo) GetInfoVendorArrowVersion() (string, bool)
func (*DriverInfo) GetInfoVendorName ¶
func (di *DriverInfo) GetInfoVendorName() (string, bool)
func (*DriverInfo) GetInfoVendorVersion ¶
func (di *DriverInfo) GetInfoVendorVersion() (string, bool)
func (*DriverInfo) GetName ¶
func (di *DriverInfo) GetName() string
func (*DriverInfo) InfoSupportedCodes ¶
func (di *DriverInfo) InfoSupportedCodes() []adbc.InfoCode
func (*DriverInfo) RegisterInfoCode ¶
func (di *DriverInfo) RegisterInfoCode(code adbc.InfoCode, value any) error
type DriverInfoPreparer ¶
type DriverInfoPreparer interface {
PrepareDriverInfo(ctx context.Context, infoCodes []adbc.InfoCode) error
}
DriverInfoPreparer is an interface that drivers may implement to add/update DriverInfo values whenever adbc.Connection.GetInfo() is called.
type ErrorHelper ¶
type ErrorHelper struct {
DriverName string
}
ErrorHelper helps format errors for ADBC drivers.
type TableTypeLister ¶
TableTypeLister is an interface that drivers may implement to simplify the implementation of adbc.Connection.GetTableTypes() for backends that do not natively send these values as arrow records. The conversion of the result to a RecordReader is handled automatically.