database

package
v1.17.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectMongoDB added in v1.6.10

func ConnectMongoDB(ctx context.Context, dsn string, opts ...*options.ClientOptions) *mongo.Database

ConnectMongoDB connect to mongodb with dsn

func ConnectRedis added in v1.6.10

func ConnectRedis(dsn string, opts ...RedisPoolOption) *redis.Pool

ConnectRedis connect to redis with dsn

func ConnectSQLDatabase added in v1.6.10

func ConnectSQLDatabase(dsn string, opts ...SQLDatabaseOption) *sql.DB

ConnectSQLDatabase connect to sql database with dsn

func InitMongoDB

func InitMongoDB(ctx context.Context, opts ...*options.ClientOptions) interfaces.MongoDatabase

InitMongoDB return mongo db read & write instance from environment: MONGODB_HOST_WRITE, MONGODB_HOST_READ if want to create single connection, use MONGODB_HOST_WRITE and set empty for MONGODB_HOST_READ

func InitRedis

func InitRedis(opts ...RedisPoolOption) interfaces.RedisPool

InitRedis connection from environment: REDIS_READ_DSN, REDIS_WRITE_DSN if want to create single connection, use REDIS_WRITE_DSN and set empty for REDIS_READ_DSN

func InitSQLDatabase

func InitSQLDatabase(opts ...SQLDatabaseOption) interfaces.SQLDatabase

InitSQLDatabase return sql db read & write instance from environment: SQL_DB_READ_DSN, SQL_DB_WRITE_DSN if want to create single connection, use SQL_DB_WRITE_DSN and set empty for SQL_DB_READ_DSN

func ParseSQLDSN added in v1.16.1

func ParseSQLDSN(source string) (driverName string, dsn string)

ParseSQLDSN parse sql dsn

Types

type RedisPoolOption added in v1.17.0

type RedisPoolOption func(pool *redis.Pool)

func RedisPoolOptionSetIdleTimeout added in v1.17.0

func RedisPoolOptionSetIdleTimeout(dur time.Duration) RedisPoolOption

func RedisPoolOptionSetMaxActive added in v1.17.0

func RedisPoolOptionSetMaxActive(count int) RedisPoolOption

func RedisPoolOptionSetMaxConnLifetime added in v1.17.0

func RedisPoolOptionSetMaxConnLifetime(dur time.Duration) RedisPoolOption

func RedisPoolOptionSetMaxIdle added in v1.17.0

func RedisPoolOptionSetMaxIdle(count int) RedisPoolOption

type SQLDatabaseOption added in v1.17.2

type SQLDatabaseOption func(db *sql.DB)

Jump to

Keyboard shortcuts

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