db

package
v0.0.0-...-a95e806 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

ProviderSet is db providers.

Functions

func NewMySQL

func NewMySQL(opts *MySQLOptions) (*gorm.DB, error)

NewMySQL create a new gorm db instance with the given options.

func NewRedis

func NewRedis(opts *RedisOptions) (*redis.Client, error)

NewRedis create a new redis db instance with the given options.

Types

type MySQLOptions

type MySQLOptions struct {
	Host                  string
	Username              string
	Password              string
	Database              string
	MaxIdleConnections    int
	MaxOpenConnections    int
	MaxConnectionLifeTime time.Duration
	// +optional
	Logger logger.Interface
}

MySQLOptions defines options for mysql database.

func (*MySQLOptions) DSN

func (o *MySQLOptions) DSN() string

DSN return DSN from MySQLOptions.

type RedisOptions

type RedisOptions struct {
	Addr         string
	Username     string
	Password     string
	Database     int
	MaxRetries   int
	MinIdleConns int
	DialTimeout  time.Duration
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
	PoolTimeout  time.Duration
	PoolSize     int
}

RedisOptions defines options for redis database.

type TracePlugin

type TracePlugin struct{}

TracePlugin defines gorm plugin used to trace sql.

func (*TracePlugin) Initialize

func (op *TracePlugin) Initialize(db *gorm.DB) (err error)

Initialize initialize the trace plugin.

func (*TracePlugin) Name

func (op *TracePlugin) Name() string

Name returns the name of trace plugin.

Jump to

Keyboard shortcuts

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