Documentation
¶
Overview ¶
Package providerregistry maps database driver names to provider factories.
Index ¶
- Constants
- Variables
- func Drivers() []string
- func HasLimits(driver string) bool
- func IsRegistered(driver string) bool
- func Limits(driver, dsn string, opts Options) (dialect.Profile, error)
- func New(driver, dsn string, opts Options) (provider.Provider, error)
- func Register(name string, factory Factory)
- func RegisterLimits(name string, fn LimitsFunc)
- type Factory
- type LimitsFunc
- type Options
Constants ¶
const PoolerTransaction = "transaction"
PoolerTransaction is the transaction-mode pooler setting.
Variables ¶
var ErrNoLimits = errors.New("providerregistry: the driver declares no limits")
ErrNoLimits is returned for a driver that registered no LimitsFunc.
var ErrUnsupportedDriver = errors.New("providerregistry: unsupported driver")
ErrUnsupportedDriver is returned when no factory is registered for a driver.
Functions ¶
func Drivers ¶ added in v0.1.15
func Drivers() []string
Drivers lists the registered driver names, sorted.
func IsRegistered ¶
IsRegistered reports whether driver has a registered factory.
func Limits ¶ added in v0.1.15
Limits judges a connection of driver to dsn opened with opts, without connecting (see LimitsFunc).
func Register ¶
Register adds a named provider factory. It panics for invalid or duplicate registrations so built-in driver mistakes fail during process startup.
func RegisterLimits ¶ added in v0.1.15
func RegisterLimits(name string, fn LimitsFunc)
RegisterLimits adds the LimitsFunc of a driver. Like Register, it panics for invalid or duplicate registrations.
Types ¶
type LimitsFunc ¶ added in v0.1.15
LimitsFunc judges, without connecting, what a connection to dsn opened with opts guarantees on the server (its statement timeouts and native write refusals).
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) NativeTimeout ¶ added in v0.1.15
NativeTimeout is the statement timeout a provider sets on the database: Timeout less a margin (a tenth, at most a second), so the database stops a slow statement, and reports it stopped, before the request's own deadline cuts the connection and leaves a write's outcome unknown. The request's deadline starts before planning, so this makes the database usually, not always, the first to stop. Configuration keeps Timeout at config.MinQueryTimeout or more, which leaves the margin whole milliseconds; a shorter Timeout given in code still gets at least a millisecond, as 0 is no timeout at all on PostgreSQL.
func (Options) OpenContext ¶ added in v0.1.12
OpenContext is the context opening the provider runs under.