utils

package
v0.0.0-...-d9cd954 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckVersion

func CheckVersion(coll *mongo.Collection, key string, currentVersion int) error

func IsMySQLTableNotExist

func IsMySQLTableNotExist(err error) bool

func NewMongo

func NewMongo(conf MongoConfig) (*mongo.Database, error)

func NewMySQL

func NewMySQL(conf MySQLConfig) (*gorm.DB, error)

func NewTask

func NewTask[A interface{ TableName() string }, B any, C any](gormDB *gorm.DB, mongoDB *mongo.Database, mongoDBInit func(db *mongo.Database) (B, error), convert func(v A) C) error

NewTask A mysql table B mongodb model C mongodb table

func ParseConfig

func ParseConfig[T any](path string) (*T, error)

func SetVersion

func SetVersion(coll *mongo.Collection, key string, version int) error

Types

type MongoConfig

type MongoConfig struct {
	Uri         string   `yaml:"uri"`
	Address     []string `yaml:"address"`
	Database    string   `yaml:"database"`
	Username    string   `yaml:"username"`
	Password    string   `yaml:"password"`
	MaxPoolSize int      `yaml:"maxPoolSize"`
}

type MySQLConfig

type MySQLConfig struct {
	Address     []string `yaml:"address"`
	Username    string   `yaml:"username"`
	Password    string   `yaml:"password"`
	Database    string   `yaml:"database"`
	MaxOpenConn int      `yaml:"maxOpenConn"`
	MaxIdleConn int      `yaml:"maxIdleConn"`
	MaxLifeTime int      `yaml:"maxLifeTime"`
}

Jump to

Keyboard shortcuts

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