adapter

package
v0.0.0-...-210dfcc Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DEFAULT_MYSQL_MAX_ATTEMPTS     = 5               // Default number of attempts to connect to mysql
	DEFAULT_MYSQL_ATTEMPT_INTERVAL = 5 * time.Second // Time between attempts
)
View Source
const (
	DefaultPort = "3306"
	DefaultHost = "localhost"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	IsConnected bool
	Logger      *log.Logger
	Config      *Config
	// contains filtered or unexported fields
}

func DefaultAdapter

func DefaultAdapter() *Adapter

func NewAdapter

func NewAdapter(c *Config, l *log.Logger) *Adapter

func (*Adapter) Connect

func (a *Adapter) Connect() error

func (*Adapter) GetDb

func (a *Adapter) GetDb() *gorm.DB

func (*Adapter) IsDbConnectionAvailable

func (a *Adapter) IsDbConnectionAvailable() (*gorm.DB, error)

type Config

type Config struct {
	Dsn *Dsn

	Logger *log.Logger
	// contains filtered or unexported fields
}

func DefaultConfig

func DefaultConfig() *Config

func NewConfig

func NewConfig(dsn *Dsn, maxAttempts int, interval time.Duration) *Config

func (*Config) GetDsn

func (c *Config) GetDsn() *Dsn

func (*Config) GetInterval

func (c *Config) GetInterval() time.Duration

func (*Config) GetMaxAttempts

func (c *Config) GetMaxAttempts() int

func (*Config) SetInterval

func (c *Config) SetInterval(interval time.Duration) *Config

func (*Config) SetLogger

func (c *Config) SetLogger(logger *log.Logger) *Config

func (*Config) SetMaxAttempts

func (c *Config) SetMaxAttempts(maxAttempts int) *Config

type Dsn

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

func NewDsn

func NewDsn(user string, password string, database string) *Dsn

func (*Dsn) Dsn

func (d *Dsn) Dsn() string

func (*Dsn) SetDatabase

func (d *Dsn) SetDatabase(database string) *Dsn

func (*Dsn) SetHost

func (d *Dsn) SetHost(host string) *Dsn

func (*Dsn) SetPassword

func (d *Dsn) SetPassword(password string) *Dsn

func (*Dsn) SetPort

func (d *Dsn) SetPort(port string) *Dsn

func (*Dsn) SetUser

func (d *Dsn) SetUser(user string) *Dsn

Jump to

Keyboard shortcuts

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