drivers

package
v0.0.0-...-72f0adf Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 16 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package drivers provides the driver interface and shared infrastructure for search backends.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, config DriverConfig)

Register registers a driver and its protocol capabilities.

Types

type CLILoader

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

CLILoader wraps a Driver for CLI bulk loading.

func NewBackendCLILoader

func NewBackendCLILoader(name, driverType, fileType, connString string, factory DriverFactory) *CLILoader

NewBackendCLILoader separates dataset directory/label from driver identity.

func NewCLILoader

func NewCLILoader(name, fileType, connString string, factory DriverFactory) *CLILoader

NewCLILoader creates a CLI loader that wraps a driver.

func (*CLILoader) Close

func (l *CLILoader) Close() error

func (*CLILoader) Drop

func (l *CLILoader) Drop(ctx context.Context, schema *Schema) error

func (*CLILoader) Load

func (l *CLILoader) Load(ctx context.Context, schema *Schema, dataPath string, batchSize int, workers int) (int, error)

func (*CLILoader) Name

func (l *CLILoader) Name() string

func (*CLILoader) RunPost

func (l *CLILoader) RunPost(ctx context.Context, dir string, schema *Schema) error

func (*CLILoader) RunPre

func (l *CLILoader) RunPre(ctx context.Context, dir string, schema *Schema) error

func (*CLILoader) ValidateSchema

func (l *CLILoader) ValidateSchema(schema *Schema) error

ValidateSchema checks whether this backend can load every schema column type, covering each table of a multi-table schema.

type Driver

type Driver interface {
	Close() error
	Exec(ctx context.Context, statements string) error
	Query(ctx context.Context, query string, args ...any) (hitCount int, err error)
	Insert(ctx context.Context, table string, cols []string, rows [][]any) (int, error)
	Update(ctx context.Context, table string, keyCols []string, cols []string, rows [][]any) (int, error)
	CaptureConfig(ctx context.Context, backendName string)
}

Driver is the minimal interface each backend must implement.

type DriverConfig

type DriverConfig struct {
	Factory  DriverFactory
	FileType string // "sql" or "json"
	// OptionalConnection allows drivers to obtain an endpoint from other settings.
	OptionalConnection bool
}

DriverConfig registers protocol capabilities. Backend defaults live in manifests.

func GetConfig

func GetConfig(name string) (DriverConfig, bool)

GetConfig returns the configuration for a driver.

type DriverFactory

type DriverFactory func(connString string) (Driver, error)

DriverFactory creates a driver from a connection string.

type K6Client

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

K6Client wraps a Driver with k6 metrics emission.

func NewK6Client

func NewK6Client(vu modules.VU, driver Driver, backend string) *K6Client

NewK6Client creates a k6 client that wraps a driver.

func (*K6Client) Close

func (c *K6Client) Close()

Close closes the underlying driver.

func (*K6Client) Insert

func (c *K6Client) Insert(table string, doc map[string]interface{}) map[string]interface{}

Insert inserts a single document and emits metrics.

func (*K6Client) InsertBatch

func (c *K6Client) InsertBatch(table string, docs []map[string]interface{}) map[string]interface{}

InsertBatch inserts documents and emits metrics.

func (*K6Client) Query

func (c *K6Client) Query(query string, args ...any) map[string]interface{}

Query executes a query and emits metrics.

func (*K6Client) SetTimeout

func (c *K6Client) SetTimeout(seconds int)

SetTimeout sets the query timeout duration. Use 0 to disable timeout (default).

func (*K6Client) Update

func (c *K6Client) Update(table string, doc map[string]interface{}) map[string]interface{}

Update updates a single document and emits metrics.

func (*K6Client) UpdateBatch

func (c *K6Client) UpdateBatch(table string, docs []map[string]interface{}) map[string]interface{}

UpdateBatch updates documents and emits metrics. The id or _id column is used as the key for matching existing rows.

type LoadWorkerFactory

type LoadWorkerFactory interface {
	NewLoadWorker() (Driver, error)
}

LoadWorkerFactory preserves driver-local setup when creating loader workers. Workers must not replay pre scripts, which can delete existing data.

type RowSource

type RowSource interface {
	// Columns returns the schema columns present in the file, in file order.
	Columns() []string
	// Next returns the values for the next row, aligned with Columns().
	// It returns io.EOF when the source is exhausted.
	Next() ([]any, error)
	Close() error
}

RowSource streams schema-converted rows from a dataset file.

func OpenRowSource

func OpenRowSource(path string, schema *Schema) (RowSource, error)

OpenRowSource opens a dataset data file or a directory of parquet shards, dispatching on file extension.

type Schema

type Schema struct {
	Table   string            `yaml:"table"`
	Columns map[string]string `yaml:"columns"`
	Tables  []Schema          `yaml:"tables"`
}

Schema defines the dataset schema from schema.yaml. A dataset is either single-table (top-level table and columns) or multi-table (a tables list with one entry per table); the two forms cannot be mixed.

func (*Schema) TableSchemas

func (s *Schema) TableSchemas() []*Schema

TableSchemas returns one single-table schema per table to load: the schema itself for single-table datasets, or each tables entry for multi-table ones.

func (*Schema) Validate

func (s *Schema) Validate() error

Validate checks the structural rules for a schema: the single- and multi-table forms cannot be mixed, and every tables entry needs a unique name and its own columns.

type TelemetryProvider

type TelemetryProvider interface {
	TelemetryEnabled() bool
	ReadTelemetry(ctx context.Context) ([]metrics.TelemetryPoint, error)
}

TelemetryProvider is an optional backend capability consumed by the dedicated metrics collector. Implementations own their database-specific queries and return generic counter/gauge series.

type TypeReloader

type TypeReloader interface {
	ReloadTypes(ctx context.Context) error
}

TypeReloader is implemented by drivers whose connections cache database type information that can be invalidated by pre scripts (e.g. CREATE EXTENSION).

Directories

Path Synopsis
Package clickhouse provides the ClickHouse driver implementation.
Package clickhouse provides the ClickHouse driver implementation.
Package elasticsearch registers the Elasticsearch driver.
Package elasticsearch registers the Elasticsearch driver.
Package mongodb provides the MongoDB driver implementation.
Package mongodb provides the MongoDB driver implementation.
Package opensearch registers the OpenSearch driver.
Package opensearch registers the OpenSearch driver.
Package postgres registers the PostgreSQL driver.
Package postgres registers the PostgreSQL driver.
shared
elasticsearch
Package elasticsearch provides the shared Elasticsearch/OpenSearch driver implementation.
Package elasticsearch provides the shared Elasticsearch/OpenSearch driver implementation.
postgres
Package postgres provides the shared PostgreSQL driver implementation.
Package postgres provides the shared PostgreSQL driver implementation.
Package turbopuffer implements the cloud-only Turbopuffer HTTP backend.
Package turbopuffer implements the cloud-only Turbopuffer HTTP backend.

Jump to

Keyboard shortcuts

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