Documentation
¶
Overview ¶
Package client implements the SQL connection provider. Like all packages under extensions/impl, it does not promise a stable Go API: the supported contract surface is contract/v2, and in-tree plugins are compiled against it. The database is reached only through the QueryContext / ExecContext / BeginTx facade below, which always routes to the current handle: a previously returned *sql.DB would outlive recovery swaps and bypass pool ownership. In particular, control-plane operations that would fork connection recovery ownership stay deleted with no compatibility shim: a shim would hand external callers an officially sanctioned way to bypass the Pool-only recovery invariant.
Index ¶
- func CreateConnection(ctx api.StreamContext) modules.Connection
- func ParseDBUrl(urlstr string) (string, string, error)
- func ParseDriver(url string) (string, error)
- type SQLConnection
- func (s *SQLConnection) BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
- func (s *SQLConnection) Close(ctx api.StreamContext) error
- func (s *SQLConnection) DetachSub(ctx api.StreamContext, props map[string]any)
- func (s *SQLConnection) Dial(ctx api.StreamContext) error
- func (s *SQLConnection) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
- func (s *SQLConnection) GetId(ctx api.StreamContext) string
- func (s *SQLConnection) HealthCheck(ctx api.StreamContext) error
- func (s *SQLConnection) Ping(ctx api.StreamContext) error
- func (s *SQLConnection) Provision(ctx api.StreamContext, conId string, props map[string]any) error
- func (s *SQLConnection) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
- func (s *SQLConnection) Recover(ctx api.StreamContext) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateConnection ¶
func CreateConnection(ctx api.StreamContext) modules.Connection
func ParseDriver ¶
Types ¶
type SQLConnection ¶
func (*SQLConnection) BeginTx ¶
BeginTx routes one transaction to the current handle, same routing-only contract as QueryContext.
func (*SQLConnection) Close ¶
func (s *SQLConnection) Close(ctx api.StreamContext) error
func (*SQLConnection) DetachSub ¶
func (s *SQLConnection) DetachSub(ctx api.StreamContext, props map[string]any)
func (*SQLConnection) Dial ¶
func (s *SQLConnection) Dial(ctx api.StreamContext) error
func (*SQLConnection) ExecContext ¶
func (s *SQLConnection) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
ExecContext routes one statement to the current handle, same routing-only contract as QueryContext.
func (*SQLConnection) GetId ¶
func (s *SQLConnection) GetId(ctx api.StreamContext) string
func (*SQLConnection) HealthCheck ¶
func (s *SQLConnection) HealthCheck(ctx api.StreamContext) error
func (*SQLConnection) Ping ¶
func (s *SQLConnection) Ping(ctx api.StreamContext) error
func (*SQLConnection) Provision ¶
func (s *SQLConnection) Provision(ctx api.StreamContext, conId string, props map[string]any) error
func (*SQLConnection) QueryContext ¶
func (s *SQLConnection) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
QueryContext routes one query to the current handle. It is pure routing: no retry, no recovery, no readiness wait — those belong to the consumer (WaitReady/suspect) and the Pool worker. The handle is snapshotted under a read lock; a recovery swap racing the call lands on either generation, and a failure on a stale one surfaces as a normal error for the caller to report.
func (*SQLConnection) Recover ¶
func (s *SQLConnection) Recover(ctx api.StreamContext) error
Recover implements modules.PoolRecoverableConnection: one bounded attempt that builds a candidate, verifies it, and installs it. No internal retry or backoff (the Pool worker owns the rhythm); ctx carries the Pool's per-attempt deadline plus lifecycle cancellation. The replaced handle retires asynchronously — closed detached from this call so a slow old pool never stalls the hot path, drained by Close so nothing leaks past the logical lifetime. A failure leaves the previous handle untouched; the Pool worker keeps owning the episode (Ping verification, then retries with backoff until success).