Documentation
¶
Index ¶
- Variables
- func JoinErrors(errs ...error) error
- func RegisterDriver(driverType config.DriverType, constructor driverConstructor)
- func SupportsInsertMethod(driverType config.DriverType, method InsertMethod) bool
- func ValidateInsert(req *InsertRequest) error
- type Driver
- type ErrorFacts
- type ErrorKind
- type InsertCapability
- type InsertMethod
- type InsertRequest
- type Options
- type QueryResult
- type Rows
- type Tx
Constants ¶
This section is empty.
Variables ¶
var ErrInsertMethodNotSupported = errors.New("driver: insert method not supported")
ErrInsertMethodNotSupported is returned by a driver's Insert when the request's method is not one the driver serves (see InsertCapabilities).
var ErrInsertMethodUnsupported = errors.New("insert method not supported by driver")
ErrInsertMethodUnsupported is returned when a resolved insert method is not served by the selected driver.
var ErrNilInsertRequest = errors.New("driver: nil insert request")
ErrNilInsertRequest is returned when a driver's Insert receives a nil request pointer.
var ErrNilInsertSource = errors.New("driver: nil insert source")
ErrNilInsertSource is returned when an InsertRequest carries no source.
var ErrNoRegisteredDriver = errors.New("no registered driver")
var ErrUnknownInsertMethod = errors.New("unknown insert method")
ErrUnknownInsertMethod is returned by ParseInsertMethod for an unrecognized method string.
Functions ¶
func JoinErrors ¶
JoinErrors combines distinct error causes while preserving errors.Is behavior.
func RegisterDriver ¶
func RegisterDriver( driverType config.DriverType, constructor driverConstructor, )
func SupportsInsertMethod ¶
func SupportsInsertMethod(driverType config.DriverType, method InsertMethod) bool
SupportsInsertMethod reports whether driverType's implementation serves method.
func ValidateInsert ¶
func ValidateInsert(req *InsertRequest) error
ValidateInsert checks the request shape shared by every driver's Insert entry. A nil request, a nil source, or a zero-column schema are rejected before driver-specific dispatch; per-driver method capability is validated in each driver.
Types ¶
type Driver ¶
type Driver interface {
// Insert runs a typed [InsertRequest] through the driver, streaming
// rows from a workload-authored [gen.BatchSource] into the database.
// Generation after cursor preparation allocates nothing; driver-side
// encoding and materialization may.
Insert(ctx context.Context, req *InsertRequest) (*stats.Query, error)
RunQuery(ctx context.Context, sql string, args map[string]any) (*QueryResult, error)
Begin(ctx context.Context, isolation config.TxIsolationLevel) (Tx, error)
ClassifyError(err error) ErrorFacts
Teardown(ctx context.Context) error
}
type ErrorFacts ¶
ErrorFacts are backend-neutral properties used by workload error policy.
func DefaultErrorFacts ¶
func DefaultErrorFacts(err error) ErrorFacts
DefaultErrorFacts classifies errors shared by every driver. Unknown errors remain explicit so policy defaults fail closed instead of retrying them.
type ErrorKind ¶
type ErrorKind string
ErrorKind describes a database-independent property of a driver error.
const ( ErrorKindUnknown ErrorKind = "unknown" ErrorKindSerialization ErrorKind = "serialization" ErrorKindDeadlock ErrorKind = "deadlock" ErrorKindLockTimeout ErrorKind = "lock_timeout" ErrorKindTransient ErrorKind = "transient" ErrorKindUnsupported ErrorKind = "unsupported" ErrorKindCanceled ErrorKind = "canceled" ErrorKindTimeout ErrorKind = "timeout" )
type InsertCapability ¶
type InsertCapability struct {
Type config.DriverType
InsertMethods []InsertMethod
}
InsertCapability pairs a driver type with the insert methods its implementation serves.
func InsertCapabilities ¶
func InsertCapabilities() []InsertCapability
InsertCapabilities returns the driver→insert-method matrix ordered by driver enum value. Method lists follow enum value order too, so output is deterministic for machine consumers.
type InsertMethod ¶
type InsertMethod int
InsertMethod names a row-insertion strategy. The typed Driver.Insert path uses this Go-native enum; a driver advertises the methods it serves via InsertCapabilities.
The method describes how a driver lands rows, not how a generator stores them: NATIVE is a driver-specific bulk primitive (COPY, BulkUpsert, …), PLAIN_BULK is a multi-row INSERT, PLAIN_QUERY is one INSERT per row, and COLUMNAR is a single-array-per-column protocol (e.g. unnest).
const ( InsertPlainQuery InsertMethod = iota + 1 InsertPlainBulk InsertColumnar InsertNative )
func ParseInsertMethod ¶
func ParseInsertMethod(s string) (InsertMethod, error)
ParseInsertMethod resolves an authoring string to a driver InsertMethod. The empty string selects plain_query, matching the legacy default.
func ResolveInsertMethod ¶
func ResolveInsertMethod(driverType config.DriverType, s string) (InsertMethod, error)
ResolveInsertMethod parses an authoring string and rejects methods the selected driver does not serve, so an invalid or unsupported value fails before a run starts loading.
func (InsertMethod) String ¶
func (m InsertMethod) String() string
String returns the stable, lowercase method name used in CLI strings and probe output ("plain_query", "plain_bulk", "columnar", "native").
type InsertRequest ¶
type InsertRequest struct {
Table string
Method InsertMethod
Workers int
Source gen.BatchSource
}
InsertRequest carries a driver-owned InsertMethod, a worker count, and a gen.BatchSource whose prepared partitions fill reusable typed batches. Workloads hand their source straight to the driver, avoiding intermediate row representations.
Source, Method, and Workers are the driver's full input; the table name is carried separately because generation is table-agnostic.
type Options ¶
type Options struct {
// DialFunc lets the runner observe or customize driver network dials.
DialFunc func(ctx context.Context, network, addr string) (net.Conn, error)
Logger *zap.Logger
Config *config.DriverConfig
// QueryTimeout bounds each statement; <= 0 disables the deadline.
QueryTimeout time.Duration
}
type QueryResult ¶
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package common hosts driver-agnostic building blocks shared by every Stroppy database driver.
|
Package common hosts driver-agnostic building blocks shared by every Stroppy database driver. |
|
Package csv implements an ephemeral Stroppy driver that writes generator output to CSV files on the local filesystem instead of a database.
|
Package csv implements an ephemeral Stroppy driver that writes generator output to CSV files on the local filesystem instead of a database. |
|
Package insertprogress provides driver-agnostic insert operation progress tracking.
|
Package insertprogress provides driver-agnostic insert operation progress tracking. |
|
Package noop provides a no-op database driver that discards all operations without performing any I/O. It is intended for benchmarking stroppy's own framework overhead in isolation from actual database latency.
|
Package noop provides a no-op database driver that discards all operations without performing any I/O. It is intended for benchmarking stroppy's own framework overhead in isolation from actual database latency. |
|
Package recording implements a database-free driver that records operations.
|
Package recording implements a database-free driver that records operations. |