Documentation
¶
Index ¶
- func Contains[S ~[]E, E comparable](s S, v E) bool
- func Index[S ~[]E, E comparable](s S, v E) int
- func NewConnector(dbPath string, opts ...Option) (driver.Connector, error)
- type Driver
- type Option
- func WithAuthToken(authToken string) Option
- func WithKeepAlive(interval time.Duration) Option
- func WithProxy(proxy string) Option
- func WithRemoteEncryptionKey(key string) Option
- func WithRequestHeaders(headers map[string]string) Option
- func WithSchemaDb(schemaDb bool) Option
- func WithTls(tls bool) Option
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
Types ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func WithAuthToken ¶
func WithKeepAlive ¶ added in v0.2.0
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 WithRemoteEncryptionKey ¶
func WithRequestHeaders ¶
WithRequestHeaders attaches arbitrary HTTP headers to every request the driver sends to the remote server. Passing the `Host` key (case-insensitive) has no effect.