xdb

package
v0.1.32 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SecretKey = "glue.xdb12345678"

默认数据库环境变量加密key

View Source
var SecretMode = "cbc/pkcs7"

Functions

func DecryptConn added in v0.1.5

func DecryptConn(conn string) (newConn string, err error)

func NewDB

func NewDB(proto string, cfg *Config) (obj xdb.IDB, err error)

NewDB 创建DB实例

Types

type Config

type Config struct {
	Proto         string `json:"proto" valid:"required"`
	Conn          string `json:"conn" valid:"required" label:"连接字符串"`
	MaxOpen       int    `json:"max_open" valid:"required" label:"最大打开连接数"`
	MaxIdle       int    `json:"max_idle" valid:"required" label:"最大空闲连接数"`
	LifeTime      int    `json:"life_time" valid:"required" label:"单个连接时长(秒)"`
	ShowQueryLog  bool   `json:"show_query_log"  label:"开启慢查询日志"`
	LongQueryTime int    `json:"long_query_time"  label:"慢查询阈值(毫秒)"`
	LoggerName    string `json:"logger_name" label:"日志提供程序"`
	Debug         bool   `json:"debug" label:"调试模式"`
	// contains filtered or unexported fields
}

DB 数据库配置

func New

func New(proto string, conn string, opts ...Option) *Config

New 构建DB连接信息

type Option

type Option func(*Config)

Option 配置选项

func WithLifeTime

func WithLifeTime(lifeTime int) Option

func WithLoggerName added in v0.1.31

func WithLoggerName(name string) Option

func WithLongQueryTime

func WithLongQueryTime(longQueryTime int) Option

func WithMaxIdle

func WithMaxIdle(maxIdle int) Option

func WithMaxOpen

func WithMaxOpen(maxOpen int) Option

func WithShowQueryLog

func WithShowQueryLog(showQueryLog bool) Option

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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