libsql

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains[S ~[]E, E comparable](s S, v E) bool

func Index

func Index[S ~[]E, E comparable](s S, v E) int

func NewConnector

func NewConnector(dbPath string, opts ...Option) (driver.Connector, error)

Types

type Driver

type Driver struct{}

func (Driver) Open

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

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithAuthToken

func WithAuthToken(authToken string) Option

func WithKeepAlive added in v0.2.0

func WithKeepAlive(interval time.Duration) Option

WithKeepAlive holds a suspending remote instance awake by issuing a trivial statement whenever the connector has been idle for `interval`.

Pick an interval under the server's suspend threshold, which measured between 30 and 60 seconds; 25s leaves margin for a late tick. Passing a non-positive interval disables the keepalive, so a caller can wire it to a config value without branching.

This applies to REMOTE connectors only. A file: database does not suspend, so asking for a keepalive on one is quietly ignored rather than burning a goroutine to query local disk on a timer.

The keepalive's own goroutine stops when the connector is closed. database/sql calls Close on a connector that implements io.Closer, so sql.OpenDB(c) followed by db.Close() shuts it down with no extra bookkeeping:

c, err := libsql.NewConnector(dsn, libsql.WithKeepAlive(25*time.Second))
if err != nil { ... }
db := sql.OpenDB(c)
defer db.Close() // stops the keepalive

func WithProxy

func WithProxy(proxy string) Option

func WithRemoteEncryptionKey

func WithRemoteEncryptionKey(key string) Option

func WithRequestHeaders

func WithRequestHeaders(headers map[string]string) Option

WithRequestHeaders attaches arbitrary HTTP headers to every request the driver sends to the remote server. Passing the `Host` key (case-insensitive) has no effect.

func WithSchemaDb

func WithSchemaDb(schemaDb bool) Option

func WithTls

func WithTls(tls bool) Option

Directories

Path Synopsis
internal
ws

Jump to

Keyboard shortcuts

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