db

package
v0.0.0-...-ce1014b Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEntClient

func NewEntClient(cfg Config) *ent.Client

NewEntClient creates an Ent client. When read_replica.read_dsn is configured, SELECT/WITH queries are automatically routed to the replica; all writes go to master. Transactions always run on master. If read_dsn is empty, all queries go to master.

Types

type Config

type Config struct {
	Dialect              string        `conf:"dialect" yaml:"dialect" json:"dialect"`
	DSN                  string        `conf:"dsn" yaml:"dsn" json:"dsn"`
	Debug                bool          `conf:"debug" yaml:"debug" json:"debug"`
	MaxOpenConns         int           `conf:"max_open_conns" yaml:"max_open_conns" json:"max_open_conns"`
	MaxIdleConns         int           `conf:"max_idle_conns" yaml:"max_idle_conns" json:"max_idle_conns"`
	ConnMaxLifetime      time.Duration `conf:"conn_max_lifetime" yaml:"conn_max_lifetime" json:"conn_max_lifetime"`
	ConnMaxIdleTime      time.Duration `conf:"conn_max_idle_time" yaml:"conn_max_idle_time" json:"conn_max_idle_time"`
	DisableSQLiteAutoWAL bool          `conf:"disable_sqlite_auto_wal" yaml:"disable_sqlite_auto_wal" json:"disable_sqlite_auto_wal"`
	DisableAutoMigration bool          `conf:"disable_auto_migration" yaml:"disable_auto_migration" json:"disable_auto_migration"`

	ReadReplica ReadReplicaConfig `conf:"read_replica" yaml:"read_replica" json:"read_replica"`
}

type ReadReplicaConfig

type ReadReplicaConfig struct {
	DSN          string `conf:"read_dsn" yaml:"read_dsn" json:"read_dsn"`
	MaxOpenConns int    `conf:"read_max_open_conns" yaml:"read_max_open_conns" json:"read_max_open_conns"`
	MaxIdleConns int    `conf:"read_max_idle_conns" yaml:"read_max_idle_conns" json:"read_max_idle_conns"`
}

Jump to

Keyboard shortcuts

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