sqldriver

package
v1.2.6-prerelease5 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 License: MIT Imports: 7 Imported by: 2 modules, 1 package

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDBConnections

func CreateDBConnections(cfg *config.SQL, createConnFunc CreateSingleDBConn) ([]*sqlx.DB, error)

CreateDBConnections returns references to logical connections to the underlying SQL databases. By default when UseMultipleDatabases == false, the returned object is to tied to a single SQL database and the object can be used to perform CRUD operations on the tables in the database. If UseMultipleDatabases == true then return connections to all the databases

Types

type CreateSingleDBConn

type CreateSingleDBConn func(cfg *config.SQL) (*sqlx.DB, error)

type Driver

type Driver interface {

	// BeginTxx starts a new transaction in the shard of dbShardID
	BeginTxx(ctx context.Context, dbShardID int, opts *sql.TxOptions) (*sqlx.Tx, error)
	// Commit commits the current transaction(started by BeginTxx)
	Commit() error
	// Rollback rollbacks the current transaction(started by BeginTxx)
	Rollback() error
	// Close closes this driver(and underlying connections)
	Close() error

	// ExecDDL executes a DDL query
	ExecDDL(ctx context.Context, dbShardID int, query string, args ...interface{}) (sql.Result, error)
	// SelectForSchemaQuery executes a select query for schema(returning multiple rows).
	SelectForSchemaQuery(dbShardID int, dest interface{}, query string, args ...interface{}) error
	// GetForSchemaQuery executes a get query for schema(returning single row).
	GetForSchemaQuery(dbShardID int, dest interface{}, query string, args ...interface{}) error
	// contains filtered or unexported methods
}

Driver interface is an abstraction to query SQL. The layer is added so that we can have a adapter to support multiple SQL databases behind a single Cadence cluster

func NewDriver

func NewDriver(xdbs []*sqlx.DB, tx *sqlx.Tx, dbShardID int) (Driver, error)

NewDriver returns a driver to SQL, either using singleton Driver or sharded Driver

Jump to

Keyboard shortcuts

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