Documentation ¶
Index ¶
- Constants
- Variables
- type Conn
- func (c *Conn) Begin() (driver.Tx, error)deprecated
- func (c *Conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error)
- func (c *Conn) Close() error
- func (c *Conn) Exec(query string, args []driver.Value) (driver.Result, error)
- func (c *Conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)
- func (c *Conn) Prepare(query string) (driver.Stmt, error)
- func (c *Conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error)
- func (c *Conn) Query(query string, args []driver.Value) (driver.Rows, error)
- func (c *Conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)
- type DialFunc
- type Driver
- type Error
- type NodeInfo
- type NodeStore
- type Option
- func WithConnectionBackoffCap(cap time.Duration) Option
- func WithConnectionBackoffFactor(factor time.Duration) Option
- func WithConnectionTimeout(timeout time.Duration) Option
- func WithContext(context context.Context) Option
- func WithContextTimeout(timeout time.Duration) Option
- func WithDialFunc(dial DialFunc) Option
- func WithLogFunc(log client.LogFunc) Option
- type Result
- type Rows
- type Stmt
- func (s *Stmt) Close() error
- func (s *Stmt) Exec(args []driver.Value) (driver.Result, error)
- func (s *Stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error)
- func (s *Stmt) NumInput() int
- func (s *Stmt) Query(args []driver.Value) (driver.Rows, error)
- func (s *Stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error)
- type Tx
Constants ¶
const (
ErrBusy = 5
)
Error codes. Values here mostly overlap with native SQLite codes.
Variables ¶
var DefaultNodeStore = client.DefaultNodeStore
DefaultNodeStore is a convenience alias of client.DefaultNodeStore.
var ErrNoAvailableLeader = protocol.ErrNoAvailableLeader
ErrNoAvailableLeader is returned as root cause of Open() if there's no leader available in the cluster.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn implements the sql.Conn interface.
func (*Conn) BeginTx ¶
BeginTx starts and returns a new transaction. If the context is canceled by the user the sql package will call Tx.Rollback before discarding and closing the connection.
This must check opts.Isolation to determine if there is a set isolation level. If the driver does not support a non-default level and one is set or if there is a non-default isolation level that is not supported, an error must be returned.
This must also check opts.ReadOnly to determine if the read-only value is true to either set the read-only transaction property if supported or return an error if it is not supported.
func (*Conn) Close ¶
Close invalidates and potentially stops any current prepared statements and transactions, marking this connection as no longer in use.
Because the sql package maintains a free pool of connections and only calls Close when there's a surplus of idle connections, it shouldn't be necessary for drivers to do their own connection caching.
func (*Conn) ExecContext ¶
func (c *Conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)
ExecContext is an optional interface that may be implemented by a Conn.
func (*Conn) PrepareContext ¶
PrepareContext returns a prepared statement, bound to this connection. context is for the preparation of the statement, it must not store the context within the statement itself.
type DialFunc ¶
DialFunc is a function that can be used to establish a network connection with a dqlite node.
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver perform queries against a dqlite server.
func New ¶
NewDriver creates a new dqlite driver, which also implements the driver.Driver interface.
func (*Driver) Open ¶
Open establishes a new connection to a SQLite database on the dqlite server.
The given name must be a pure file name without any directory segment, dqlite will connect to a database with that name in its data directory.
Query parameters are always valid except for "mode=memory".
If this node is not the leader, or the leader is unknown an ErrNotLeader error is returned.
func (*Driver) SetContextTimeout ¶
SetContextTimeout sets the default client timeout when no context deadline is provided.
type Option ¶
type Option func(*options)
Option can be used to tweak driver parameters.
func WithConnectionBackoffCap ¶
WithConnectionBackoffCap sets the maximum connection retry backoff value, (regardless of the backoff factor) for retrying failed connection attempts.
If not used, the default is 1 second.
func WithConnectionBackoffFactor ¶
WithConnectionBackoffFactor sets the exponential backoff factor for retrying failed connection attempts.
If not used, the default is 50 milliseconds.
func WithConnectionTimeout ¶
WithConnectionTimeout sets the connection timeout.
If not used, the default is 5 seconds.
func WithContext ¶
WithContext sets a global cancellation context.
func WithContextTimeout ¶
WithContextTimeout sets the default client context timeout when no context deadline is provided.
If not used, the default is 5 seconds.
func WithDialFunc ¶
WithDialFunc sets a custom dial function.
func WithLogFunc ¶
WithLogFunc sets a custom logging function.
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result is the result of a query execution.
func (*Result) LastInsertId ¶
LastInsertId returns the database's auto-generated ID after, for example, an INSERT into a table with primary key.
func (*Result) RowsAffected ¶
RowsAffected returns the number of rows affected by the query.
type Rows ¶
type Rows struct {
// contains filtered or unexported fields
}
Rows is an iterator over an executed query's results.
func (*Rows) ColumnTypeDatabaseTypeName ¶
ColumnTypeDatabaseTypeName implements RowsColumnTypeDatabaseTypeName. warning: not thread safe
func (*Rows) ColumnTypeScanType ¶
ColumnTypeScanType implements RowsColumnTypeScanType.
type Stmt ¶
type Stmt struct {
// contains filtered or unexported fields
}
Stmt is a prepared statement. It is bound to a Conn and not used by multiple goroutines concurrently.
func (*Stmt) ExecContext ¶
ExecContext executes a query that doesn't return rows, such as an INSERT or UPDATE.
ExecContext must honor the context timeout and return when it is canceled.
func (*Stmt) QueryContext ¶
QueryContext executes a query that may return rows, such as a SELECT.
QueryContext must honor the context timeout and return when it is canceled.