client

package
v2.5.0-alpha.5 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateConnection

func CreateConnection(ctx api.StreamContext) modules.Connection

func ParseDBUrl

func ParseDBUrl(urlstr string) (string, string, error)

func ParseDriver

func ParseDriver(url string) (string, error)

Types

type SQLConnection

type SQLConnection struct {
	syncx.RWMutex
	// contains filtered or unexported fields
}

func (*SQLConnection) BeginTx

func (s *SQLConnection) BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)

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).

Jump to

Keyboard shortcuts

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