grdb

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2022 License: MIT Imports: 7 Imported by: 1

README

grdb

Documentation

Index

Constants

View Source
const (
	// DialectMySQL defines the value to be used to identify a
	// MySQL dialect.
	DialectMySQL = "mysql"

	// DialectSqlite defines the value to be used to identify a
	// Sqlite dialect.
	DialectSqlite = "sqlite"
)

Variables

View Source
var (
	// ErrNilPointer defines a nil pointer argument error
	ErrNilPointer = fmt.Errorf("invalid nil pointer")

	// ErrConversion defines a type conversion error
	ErrConversion = fmt.Errorf("invalid type conversion")

	// ErrConfigNotFound @todo doc
	ErrConfigNotFound = fmt.Errorf("rdb config not found")

	// ErrUnknownDialect @todo doc
	ErrUnknownDialect = fmt.Errorf("unknown rdb dialect")
)
View Source
var (
	// ConnectionsConfigPath contains the configuration path that holds the
	// relational database connection configurations.
	ConnectionsConfigPath = genv.String("GRDB_CONNECTIONS_CONFIG_PATH", "rdb.connections")

	// ObserveConfig defines the connection factory config observing flag
	// used to register in the config object an observer of the connection
	// config entries list, so it can reset the connections pool.
	ObserveConfig = genv.Bool("GRDB_OBSERVE_CONFIG", true)
)

Functions

This section is empty.

Types

type ConnectionFactory

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

ConnectionFactory @todo doc

func NewConnectionFactory

func NewConnectionFactory(config gconfig.Manager, dialectFactory *DialectFactory) (*ConnectionFactory, error)

NewConnectionFactory instantiates a new connection factory instance.

func (*ConnectionFactory) Get

func (f *ConnectionFactory) Get(name string, gcfg *gorm.Config) (*gorm.DB, error)

Get execute the process of the connection creation based on the base configuration defined by the given name of the connection, and apply the extra connection config also given as arguments.

type DialectFactory

type DialectFactory []DialectStrategy

DialectFactory @todo doc

func (DialectFactory) Get

func (f DialectFactory) Get(config gconfig.Config) (gorm.Dialector, error)

Get generates a new connection dialect interface defined by the configuration parameters stored in the configuration partial marked by the given name.

func (*DialectFactory) Register

func (f *DialectFactory) Register(strategy DialectStrategy) error

Register will register a new dialect factory strategy to be used on requesting to create a dialect.

type DialectStrategy

type DialectStrategy interface {
	Accept(dialect string) bool
	Get(config gconfig.Config) (gorm.Dialector, error)
}

DialectStrategy defines the interface to a gorm rdb dialect instantiation strategy, based on a configuration.

type DialectStrategyMySQL

type DialectStrategyMySQL struct{}

DialectStrategyMySQL @todo doc

func (DialectStrategyMySQL) Accept

func (DialectStrategyMySQL) Accept(dialect string) bool

Accept check if the provided configuration should the handled as a mysql connection definition,

func (DialectStrategyMySQL) Get

Get instantiates the requested mysql connection dialect.

type DialectStrategySqlite

type DialectStrategySqlite struct{}

DialectStrategySqlite @todo doc

func (DialectStrategySqlite) Accept

func (DialectStrategySqlite) Accept(name string) bool

Accept check if the provided configuration should the handled as a mysql connection definition,

func (DialectStrategySqlite) Get

Get instantiates the requested mysql connection dialect.

Jump to

Keyboard shortcuts

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