Documentation
¶
Index ¶
- Constants
- Variables
- func NewResultSet(opts ...ResultSetOption) (sql.ResultSet, error)
- func NewResultSetColumnFrom(name string, ct *dbsql.ColumnType) (sql.Column, error)
- func NewResultSetDataTypeFrom(ct *dbsql.ColumnType) (sql.DataType, error)
- type Config
- type Conn
- type ConnID
- type Database
- func (db *Database) Begin() error
- func (db *Database) Commit() error
- func (db *Database) DB() *sql.DB
- func (db *Database) Exec(query string, args ...any) (sql.Result, error)
- func (db *Database) Name() string
- func (db *Database) Query(query string, args ...any) (*sql.Rows, error)
- func (db *Database) Rollback() error
- func (db *Database) SetOptions(opts ...DatabaseOption) error
- type DatabaseOption
- type Databases
- type PrometheusExporter
- type ResultSetOption
- type SQLExecutor
- type Server
- type TLSConf
- func (config *TLSConf) IsTLSEnabled() bool
- func (config *TLSConf) SetClientAuthType(authType tls.ClientAuthType)
- func (config *TLSConf) SetRootCertFiles(files ...string) error
- func (config *TLSConf) SetRootCerts(certs ...[]byte)
- func (config *TLSConf) SetServerCert(cert []byte)
- func (config *TLSConf) SetServerCertFile(file string) error
- func (config *TLSConf) SetServerKey(key []byte)
- func (config *TLSConf) SetServerKeyFile(file string) error
- func (config *TLSConf) SetTLSConfig(tlsConfig *tls.Config)
- func (config *TLSConf) SetTLSEnabled(enabled bool)
- func (config *TLSConf) TLSConfig() (*tls.Config, error)
Constants ¶
const ( ConfigLogger = "logger" ConfigTLS = "tls" ConfigAuth = "auth" ConfigQuery = "query" ConfigTracer = "tracer" ConfigMetrics = "metrics" ConfigMySQL = "mysql" ConfigPostgresql = "postgresql" ConfigPort = "port" ConfigEnabled = "enabled" ConfigLevel = "level" ConfigPrometheus = "prometheus" ConfigStore = "store" ConfigSQLite = "sqlite" ConfigMemory = "memory" )
const ( DatabaseDefaultFilename = ":memory:" DatabaseFilenameExt = "sqlite3" )
const ( DefaultPrometheusPort = 9181 DefaultPrometheusConnectionTimeout time.Duration = time.Second * 60 )
const (
// ProductName is the product name.
ProductName = "go-sqlserver"
)
const (
Version = "v0.0.1"
)
Variables ¶
Functions ¶
func NewResultSet ¶ added in v0.9.0
func NewResultSet(opts ...ResultSetOption) (sql.ResultSet, error)
NewResultSet creates a new result set.
func NewResultSetColumnFrom ¶ added in v0.9.0
NewResultSetColumn creates a new result set column from a column name and type.
func NewResultSetDataTypeFrom ¶ added in v0.9.0
func NewResultSetDataTypeFrom(ct *dbsql.ColumnType) (sql.DataType, error)
NewResultSetDataTypeFrom creates a new result set data type from a column type.
Types ¶
type Config ¶
type Config interface { // MySQLPort returns the MySQL port. MySQLPort() (int, error) // PostgresqlPort returns the Postgresql port. PostgresqlPort() (int, error) // IsLoggerEnabled returns true if the logger is enabled. IsLoggerEnabled() (bool, error) // LoggerLevel returns the logger level. LoggerLevel() (string, error) // IsTLSEnabled returns true if the TLS is enabled. IsTLSEnabled() (bool, error) // TLSCert returns the TLS certificate. TLSConfig() (*tls.Config, error) // IsPrometheusEnabled returns true if the Prometheus is enabled. IsPrometheusEnabled() (bool, error) // PrometheusPort returns the Prometheus port. PrometheusPort() (int, error) // IsMemoryStoreEnabled returns true if the store is memory. IsMemoryStoreEnabled() (bool, error) }
Config represents a configuration interface for PuzzleDB.
func NewConfigWithFile ¶ added in v0.9.0
NewConfigWithFile returns a new configuration with the specified file.
func NewConfigWithPath ¶ added in v0.9.0
NewConfigWithPath returns a new configuration with the specified path.
func NewConfigWithPaths ¶ added in v0.9.0
func NewConfigWithString ¶ added in v0.9.0
NewConfigWithString returns a new configuration with the specified string.
func NewDefaultConfig ¶
type Database ¶ added in v0.9.0
type Database struct {
// contains filtered or unexported fields
}
Database represents a destination or source database of query.
func NewDatabaseWith ¶ added in v0.9.0
func NewDatabaseWith(opt ...DatabaseOption) (*Database, error)
NewDatabaseWith returns a new database with the specified string.
func (*Database) SetOptions ¶ added in v0.9.0
func (db *Database) SetOptions(opts ...DatabaseOption) error
SetOptions sets the database options.
type DatabaseOption ¶ added in v0.9.0
DatabaseOption is a function that configures a database.
func WithDatabaseFilename ¶ added in v0.9.0
func WithDatabaseFilename(filename string) DatabaseOption
WithDatabaseFilename returns a database option that sets the filename.
func WithDatabaseName ¶ added in v0.9.0
func WithDatabaseName(name string) DatabaseOption
WithDatabaseName returns a database option that sets the name.
type Databases ¶ added in v0.9.0
type Databases struct {
// contains filtered or unexported fields
}
Databases represents a collection of databases.
func NewDatabases ¶ added in v0.9.0
func NewDatabases() *Databases
NewDatabases returns a databases instance.
func (*Databases) AddDatabase ¶ added in v0.9.0
AddDatabase adds a specified database.
func (*Databases) DropDatabase ¶ added in v0.9.0
DropDatabase remove the specified database.
type PrometheusExporter ¶ added in v0.9.0
PrometheusExporter is a prometheus exporter service.
func NewPrometheusExporter ¶ added in v0.9.0
func NewPrometheusExporter() *PrometheusExporter
NewPrometheusExporter returns a new prometheus exporter service.
func (*PrometheusExporter) SetAddress ¶ added in v0.9.0
func (expoter *PrometheusExporter) SetAddress(addr string)
SetAddress sets an address of the expoter.
func (*PrometheusExporter) SetPort ¶ added in v0.9.0
func (expoter *PrometheusExporter) SetPort(port int)
SetPort sets a port number of the expoter.
func (*PrometheusExporter) Start ¶ added in v0.9.0
func (expoter *PrometheusExporter) Start() error
Start starts the expoter.
func (*PrometheusExporter) Stop ¶ added in v0.9.0
func (expoter *PrometheusExporter) Stop() error
Stop stops the Grpc expoter.
type ResultSetOption ¶ added in v0.9.0
type ResultSetOption func(*resultset) error
ResultSetOption is a result set option.
func WithResultSetResult ¶ added in v0.9.0
func WithResultSetResult(result dbsql.Result) ResultSetOption
WithResultSetResult sets the result set result.
func WithResultSetRows ¶ added in v0.9.0
func WithResultSetRows(rows *dbsql.Rows) ResultSetOption
WithResultSetRows sets the result set rows.
type SQLExecutor ¶ added in v0.9.0
SQLExecutor represents a SQL executor.
type Server ¶
type Server interface { // SetConfig sets a configuration. SetConfig(Config) // SetTracer sets a tracing tracer. SetTracer(tracer.Tracer) // SetSQLExecutor sets a SQL executor. SetSQLExecutor(SQLExecutor) // MySQLServer returns a MySQL server. MySQLServer() mysql.Server // PostgreSQLServer returns a PostgreSQL server. PostgreSQLServer() postgresql.Server // Start starts the server. Start() error // Stop stops the server. Stop() error // Restart restarts the server. Restart() error }
Server represents a PostgreSQL protocol server.
type TLSConf ¶
type TLSConf struct { ClientAuthType tls.ClientAuthType ServerCert []byte ServerKey []byte RootCerts [][]byte // contains filtered or unexported fields }
TLSConf represents a TLS configuration.
func (*TLSConf) IsTLSEnabled ¶
IsEnabled returns true if the TLS is enabled.
func (*TLSConf) SetClientAuthType ¶
func (config *TLSConf) SetClientAuthType(authType tls.ClientAuthType)
SetClientAuthType sets a client authentication type.
func (*TLSConf) SetRootCertFiles ¶
SetRootCertFile sets a SSL root certificates.
func (*TLSConf) SetRootCerts ¶
SetRootCerts sets a SSL root certificates.
func (*TLSConf) SetServerCert ¶
SetServerCert sets a SSL server certificate.
func (*TLSConf) SetServerCertFile ¶
SetServerCertFile sets a SSL server certificate file.
func (*TLSConf) SetServerKey ¶
SetServerKey sets a SSL server key.
func (*TLSConf) SetServerKeyFile ¶
SetServerKeyFile sets a SSL server key file.
func (*TLSConf) SetTLSConfig ¶
SetTLSConfig sets a TLS configuration.
func (*TLSConf) SetTLSEnabled ¶
SetTLSEnabled sets a TLS enabled flag.