Documentation
¶
Index ¶
- func GormCheck(cfg Config, db *gorm.DB, log *zap.Logger) error
- func Module(opts ...di.Node) di.Node
- func NewGormDB(dialecter gorm.Dialector) (*gorm.DB, error)
- func NewPostgresDialector(config Config) gorm.Dialector
- func RunCheck() di.Node
- func RunMigrations() di.Node
- func UseMigrations(migrationsDirFS *embed.FS, paths ...string) di.Node
- func UseOtel() di.Node
- type Config
- type ContextFn
- type GormOtel
- type LogConfig
- type Logger
- func (l Logger) Error(ctx context.Context, str string, args ...any)
- func (l Logger) Info(ctx context.Context, str string, args ...any)
- func (l Logger) LogMode(level gormlogger.LogLevel) gormlogger.Interface
- func (l Logger) ParamsFilter(ctx context.Context, sql string, params ...any) (string, []any)
- func (l Logger) SetAsDefault()
- func (l Logger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)
- func (l Logger) Warn(ctx context.Context, str string, args ...any)
- type Option
- type TraceConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewPostgresDialector ¶
func RunMigrations ¶ added in v1.5.0
RunMigrations runs goose migrations using the source registered by UseMigrations.
func UseMigrations ¶
UseMigrations registers migration files in the DI container.
Types ¶
type Config ¶
type Config struct {
Dialect string `mapstructure:"dialect"`
Migrate bool `mapstructure:"migrate"`
Datasource string `mapstructure:"datasource"`
Log LogConfig `mapstructure:"log"`
Trace TraceConfig `mapstructure:"trace"`
}
type LogConfig ¶ added in v1.4.0
type LogConfig struct {
Enabled *bool `mapstructure:"enabled"`
LogLevel string `mapstructure:"level" default:"warn"`
SlowThreshold time.Duration `mapstructure:"slow_threshold" default:"100ms"`
SkipCallerLookup bool `mapstructure:"skip_caller_lookup" default:"false"`
IgnoreRecordNotFoundError bool `mapstructure:"ignore_record_not_found_error" default:"false"`
ParameterizedQueries bool `mapstructure:"parameterized_queries" default:"true"`
}
type Logger ¶
type Logger struct {
ZapLogger *zap.Logger
LogLevel gormlogger.LogLevel
SlowThreshold time.Duration
SkipCallerLookup bool
IgnoreRecordNotFoundError bool
Context ContextFn
ParameterizedQueries bool
}
func (Logger) LogMode ¶
func (l Logger) LogMode(level gormlogger.LogLevel) gormlogger.Interface
func (Logger) ParamsFilter ¶
func (Logger) SetAsDefault ¶
func (l Logger) SetAsDefault()
type TraceConfig ¶ added in v1.4.0
type TraceConfig struct {
Enabled *bool `mapstructure:"enabled"`
DBName string `mapstructure:"db_name"`
Attributes map[string]string `mapstructure:"attributes"`
WithoutQueryVariables bool `mapstructure:"without_query_variables" default:"true"`
WithoutMetrics bool `mapstructure:"without_metrics" default:"false"`
IncludeDryRunSpans bool `mapstructure:"include_dry_run_spans" default:"false"`
}
Click to show internal directories.
Click to hide internal directories.