providerregistry

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package providerregistry maps database driver names to provider factories.

Index

Constants

View Source
const PoolerTransaction = "transaction"

PoolerTransaction is the transaction-mode pooler setting.

Variables

View Source
var ErrUnsupportedDriver = errors.New("providerregistry: unsupported driver")

ErrUnsupportedDriver is returned when no factory is registered for a driver.

Functions

func IsRegistered

func IsRegistered(driver string) bool

IsRegistered reports whether driver has a registered factory.

func New

func New(driver, dsn string, opts Options) (provider.Provider, error)

New opens the provider registered under driver.

func Register

func Register(name string, factory Factory)

Register adds a named provider factory. It panics for invalid or duplicate registrations so built-in driver mistakes fail during process startup.

Types

type Factory

type Factory func(dsn string, opts Options) (provider.Provider, error)

Factory opens a database provider.

type Options added in v0.1.11

type Options struct {
	// Timeout is the statement timeout the provider sets natively.
	Timeout time.Duration
	// Pooler is "transaction" when the connection goes through a
	// transaction-mode pooler, which keeps no session state: the provider
	// must not rely on named prepared statements or startup settings.
	Pooler string
	// Context bounds opening the provider (its first connection); nil means
	// no bound.
	Context context.Context
}

Options configures an opened provider.

func (Options) OpenContext added in v0.1.12

func (o Options) OpenContext() context.Context

OpenContext is the context opening the provider runs under.

Jump to

Keyboard shortcuts

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