stdlib

package
v0.0.0-...-f06801b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2021 License: MIT Imports: 8 Imported by: 3

Documentation

Overview

Package stdlib is a compatibility layer/driver intended to be used with the standard library's database/sql package

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTransactionsNotSupported is a placeholder returned by sql driver transaction related methods, given that no such functionality exists currently in ksqlDB
	ErrTransactionsNotSupported = errors.New("Transactions are not supported by the kafka-go driver, please use Query or Exec instead")

	// ErrInvalidQueryStrategy is returned when the provided query strategy is not supported or doesn't exist
	ErrInvalidQueryStrategy = errors.New("unrecognised query strategy")
)
View Source
var (
	// ErrMissingSemicolon is returned when the sql statement is missing a trailing semi-colon
	ErrMissingSemicolon = errors.New("statement is missing a trailing semi-colon")
)

Functions

This section is empty.

Types

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

Conn provides the driver.Conn interface for interacting with the ksqlDB client

func (*Conn) Begin

func (c *Conn) Begin() (driver.Tx, error)

Begin is not supported but implemented here for compatibility

func (*Conn) BeginTx

func (c *Conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error)

BeginTx is a placeholder, transactions are not supported

func (*Conn) CheckNamedValue

func (c *Conn) CheckNamedValue(val *driver.NamedValue) error

CheckNamedValue is used here to filter out config options from the final args

func (*Conn) Client

func (c *Conn) Client() ksql.Client

Client exposes the underlying ksql client instance

func (*Conn) Close

func (c *Conn) Close() error

Close the underlying client connection

func (*Conn) Connect

func (c *Conn) Connect(context.Context) (driver.Conn, error)

Connect simply returns the connection

func (*Conn) Driver

func (c *Conn) Driver() driver.Driver

Driver returns a Driver singleton

func (*Conn) ExecContext

func (c *Conn) ExecContext(ctx context.Context, stmt string, args []driver.NamedValue) (driver.Result, error)

ExecContext executes any arbitrary ksql statements, except queries

func (*Conn) IsValid

func (c *Conn) IsValid() bool

IsValid is a placeholder for compatibility

func (*Conn) Ping

func (c *Conn) Ping(ctx context.Context) error

Ping checks the status of the ksqlDB cluster using the /info endpoint

func (*Conn) Prepare

func (c *Conn) Prepare(query string) (driver.Stmt, error)

Prepare a SQL query. Note that there are no optimizations here and this method is only provided for compatibility reasons.

func (*Conn) PrepareContext

func (c *Conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error)

PrepareContext is a placeholder, prepared statements are not supported in ksqlDB

func (*Conn) QueryContext

func (c *Conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)

QueryContext runs a SELECT query via the ksqlDB client

func (*Conn) ResetSession

func (c *Conn) ResetSession(ctx context.Context) error

ResetSession is a placeholder for compatibility

type Connector

type Connector struct {
	// contains filtered or unexported fields
}

Connector implements the database/sql/driver package's Connector interface

func NewConnector

func NewConnector(client ksql.Client) *Connector

NewConnector allows a specific client to be passed to database/sql compatible connectors

func (*Connector) Client

func (c *Connector) Client() ksql.Client

Client returns the connector's ksql client

func (*Connector) Connect

func (c *Connector) Connect(ctx context.Context) (driver.Conn, error)

Connect returns a new connection with access to the client

func (*Connector) Driver

func (c *Connector) Driver() driver.Driver

Driver returns a new driver instance

type Driver

type Driver struct{}

Driver is a database/sql compatible driver

func (*Driver) Open

func (d *Driver) Open(url string) (driver.Conn, error)

Open returns a new connection with a new client

func (*Driver) OpenConnector

func (d *Driver) OpenConnector(url string) (driver.Connector, error)

OpenConnector returns a new connection with a new client

type PreparedStatement

type PreparedStatement struct {
	Name string
	SQL  string
	// contains filtered or unexported fields
}

PreparedStatement imitates a pre loaded sql statement

func (PreparedStatement) Close

func (p PreparedStatement) Close() error

Close closes the ksqlDB connection

func (PreparedStatement) Exec

func (p PreparedStatement) Exec(args []driver.Value) (driver.Result, error)

Exec is equivalent to running the given sql statement via the Execer interface

func (PreparedStatement) ExecContext

func (p PreparedStatement) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error)

ExecContext is equivalent to running the given sql statement via the ExecerContext interface

func (PreparedStatement) NumInput

func (p PreparedStatement) NumInput() int

NumInput always returns -1 to allow any number of arguments

func (PreparedStatement) Query

func (p PreparedStatement) Query(args []driver.Value) (driver.Rows, error)

Query is equivalent to running the given sql statement via the Queryer interface

func (PreparedStatement) QueryContext

func (p PreparedStatement) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error)

QueryContext is equivalent to running the given sql statement via the QueryerContext interface

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL