Documentation
¶
Overview ¶
Package database provides Runa database primitives.
Index ¶
- Constants
- func Provider(options ...ProviderOption) runaprovider.Provider
- type Config
- type Database
- type Driver
- type Info
- type ProviderOption
- type Registry
- func (registry *Registry) Close(ctx context.Context) error
- func (registry *Registry) Get(name string) Database
- func (registry *Registry) Info() []Info
- func (registry *Registry) MustGet(name string) Database
- func (registry *Registry) Open(ctx context.Context, app any) error
- func (registry *Registry) Ping(ctx context.Context, name string) error
- func (registry *Registry) RegisterDriver(name string, driver Driver)
- func (registry *Registry) Shutdown(ctx context.Context) error
- type SQLLog
- type SQLRecorder
Constants ¶
View Source
const DefaultName = "default"
Variables ¶
This section is empty.
Functions ¶
func Provider ¶
func Provider(options ...ProviderOption) runaprovider.Provider
Types ¶
type Database ¶
type Database interface {
Name() string
Kind() string
Raw() any
Ping(ctx context.Context) error
Close(ctx context.Context) error
Info() Info
}
Database is a named data source runtime.
type ProviderOption ¶
type ProviderOption func(*provider)
func RegisterDriver ¶
func RegisterDriver(name string, driver Driver) ProviderOption
RegisterDriver registers a database driver with the provider.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry stores named database drivers and runtimes.
func (*Registry) RegisterDriver ¶
Register registers or replaces a named driver.
type SQLLog ¶
type SQLLog struct {
Time time.Time
Database string
Dialect string
Operation string
Model string
Table string
SQL string
Rows int64
Latency time.Duration
Slow bool
Error string
}
SQLLog describes one SQL execution event emitted by database drivers.
type SQLRecorder ¶
type SQLRecorder interface {
RecordSQL(SQLLog)
}
SQLRecorder consumes SQL execution events.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.