dsql

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CacheKeyPK = "pk"
)

Variables

This section is empty.

Functions

func GormClickhouseDB

func GormClickhouseDB(cfg ClickhouseCfg) *gorm.DB

func GormMySQLDB added in v0.9.2

func GormMySQLDB(cfg SQLCfg) *gorm.DB

func GormPGDB

func GormPGDB(cfg SQLCfg) *gorm.DB

Types

type CacheDB

type CacheDB struct {
	// contains filtered or unexported fields
}

func NewMySQLCacheDB added in v0.9.2

func NewMySQLCacheDB(cfg SQLCfg, cache dcomponent.Cache, prefix string, expire time.Duration) *CacheDB

func NewPGCacheDB added in v0.9.2

func NewPGCacheDB(cfg SQLCfg, cache dcomponent.Cache, prefix string, expire time.Duration) *CacheDB

func (*CacheDB) Create

func (gc *CacheDB) Create(ctx context.Context, v interface{}) error

func (*CacheDB) DB

func (gc *CacheDB) DB() *gorm.DB

func (*CacheDB) Delete

func (gc *CacheDB) Delete(ctx context.Context, v interface{}, kv map[string]interface{}) error

func (*CacheDB) QueryByIndex

func (gc *CacheDB) QueryByIndex(ctx context.Context, v interface{}, key string, indexVal interface{}, queryPk func(db *gorm.DB, v interface{}) (interface{}, error)) error

func (*CacheDB) QueryByPk

func (gc *CacheDB) QueryByPk(ctx context.Context, v interface{}, pkVal interface{}, query func(db *gorm.DB, v interface{}) error) error

func (*CacheDB) Update

func (gc *CacheDB) Update(ctx context.Context, v interface{}, kv map[string]interface{}) error

type ClickhouseCfg

type ClickhouseCfg struct {
	IP       string            `yaml:"ip" env:"CLICKHOUSE_IP"`
	Port     string            `yaml:"port" env:"CLICKHOUSE_PORT"`
	User     string            `yaml:"user" env:"CLICKHOUSE_USER"`
	Password dcrypto.RSAEncode `yaml:"password" env:"CLICKHOUSE_PASSWORD"`
	Secret   []byte            `secret:"/etc/secret/clickhouse-password-private-key"`
	DBName   string            `yaml:"db_name" env:"CLICKHOUSE_DB_NAME"`
}

type SQLCfg

type SQLCfg struct {
	IP       string            `yaml:"ip" env:"SQL_IP"`
	Port     string            `yaml:"port" env:"SQL_PORT"`
	User     string            `yaml:"user" env:"SQL_USER"`
	Password dcrypto.RSAEncode `yaml:"password" env:"SQL_PASSWORD"`
	Secret   []byte            `secret:"/etc/secret/sql-password-private-key"`
	DBName   string            `yaml:"db_name" env:"SQL_DB_NAME"`
}

Jump to

Keyboard shortcuts

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