Documentation
¶
Index ¶
- type Connection
- type Option
- func WithConnection(dsn string, readOnly bool) Option
- func WithConnections(connections []Connection) Option
- func WithInsertBatchSize(insertBatchSize int) Option
- func WithMaxIdle(maxIdle int) Option
- func WithMaxLifetime(maxLifetime time.Duration) Option
- func WithMaxOpen(maxOpen int) Option
- func WithPreferSimpleProtocol(preferSimpleProtocol bool) Option
- func WithPreparedStatements(enabled bool) Option
- func WithSkipDefaultTransaction(skipDefaultTransaction bool) Option
- func WithTraceConfig(traceConfig config.ConfigurationDatabaseTracing) Option
- type Options
- type Pool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
Connection represents a single database connection configuration.
type Option ¶
type Option func(*Options)
Option configures database connection settings.
func WithConnection ¶
WithConnection returns an Option to configure the database connection dsn. Multiple calls with the same DSN but different readOnly flags are supported.
func WithConnections ¶
func WithConnections(connections []Connection) Option
WithConnections returns an Option to configure database connections from a slice. Supports adding multiple connections including the same DSN with different readOnly flags.
func WithInsertBatchSize ¶ added in v1.63.3
WithInsertBatchSize returns an Option to configure the database connection insert batch size.
func WithMaxIdle ¶
WithMaxIdle returns an Option to configure the database connection max idle connections.
func WithMaxLifetime ¶
WithMaxLifetime returns an Option to configure the database connection max lifetime.
func WithMaxOpen ¶
WithMaxOpen returns an Option to configure the database connection max open connections.
func WithPreferSimpleProtocol ¶
WithPreferSimpleProtocol returns an Option to configure the database connection prefer simple protocol.
func WithPreparedStatements ¶ added in v1.64.2
WithPreparedStatements returns an Option to enable or disable the prepared statement cache.
func WithSkipDefaultTransaction ¶
WithSkipDefaultTransaction returns an Option to configure the database connection skip default transaction.
func WithTraceConfig ¶
func WithTraceConfig(traceConfig config.ConfigurationDatabaseTracing) Option
WithTraceConfig returns an Option to configure the database connection trace config.
type Options ¶
type Options struct {
Connections []Connection
MaxOpen int
MaxIdle int
MaxLifetime time.Duration
PreferSimpleProtocol bool
SkipDefaultTransaction bool
TraceConfig config.ConfigurationDatabaseTracing
InsertBatchSize int
PreparedStatements bool
}
Options holds Datastore connection configuration.
type Pool ¶
type Pool interface {
DB(ctx context.Context, readOnly bool) *gorm.DB
AddConnection(ctx context.Context, opts ...Option) error
CanMigrate() bool
SaveMigration(ctx context.Context, migrationPatches ...*migration.Patch) error
// Migrate finds missing migrations and records them in the database.
Migrate(ctx context.Context, migrationsDirPath string, migrations ...any) error
Close(ctx context.Context)
}