db

package
v0.0.0-...-32e545c Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(ctx context.Context, conf *Config) error

Init initializes default db

func Ping

func Ping(ctx context.Context) error

Ping pings default db

Types

type Config

type Config struct {
	// DriverName is the name of the database driver and it's mandatory
	DriverName string `json:"driver_name" yaml:"driver_name" env:"DB_DRIVER" env-default:"postgres" validate:"required"`

	// You can supply either an sql.DB object or config of the database connection, but not both (mutually exclusive)
	DB         *sql.DB `validate:"required_without=DbHost"`
	DbHost     string  `` /* 226-byte string literal not displayed */
	DbPort     int     `` /* 217-byte string literal not displayed */
	DbName     string  `` /* 213-byte string literal not displayed */
	DbUsername string  `` /* 221-byte string literal not displayed */
	DbPassword string  `` /* 221-byte string literal not displayed */
	DbSslMode  string  `` /* 221-byte string literal not displayed */

	// ReplicaDB is the database connection for replication, it's optional
	ReplicaDB         *sql.DB `validate:"required_without=ReplicaDbHost"`
	ReplicaDbHost     string  `` /* 296-byte string literal not displayed */
	ReplicaDbPort     int     `` /* 287-byte string literal not displayed */
	ReplicaDbName     string  `` /* 283-byte string literal not displayed */
	ReplicaDbUsername string  `` /* 291-byte string literal not displayed */
	ReplicaDbPassword string  `` /* 291-byte string literal not displayed */
	ReplicaDbSslMode  string  `` /* 291-byte string literal not displayed */

	AwsAccessKeyID     string
	AwsSecretAccessKey string
	AwsSessionToken    string
	AwsSource          string
	AwsRegion          string
	AwsEndpointURL     string
}

type DB

type DB interface {
	Ping(context.Context) error
}

func New

func New(ctx context.Context, conf *Config) (DB, error)

Jump to

Keyboard shortcuts

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