drivers

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MutexTableName is the name being used for the mutex table
	MutexTableName = "db_lock"

	// TTL is the interval after which a locked mutex will expire unless refreshed
	TTL = time.Second * 15

	// RefreshInterval is the interval on which the mutex will be refreshed when locked
	RefreshInterval = TTL / 2
)

Variables

This section is empty.

Functions

func ExtractCustomParams

func ExtractCustomParams(conn string, params []string) (map[string]string, error)

func GenerateAdvisoryLockID

func GenerateAdvisoryLockID(databaseName, schemaName string) (string, error)

func GetContext

func GetContext(timeoutInSeconds int) (context.Context, context.CancelFunc)

func IsLockable

func IsLockable(x interface{}) bool

IsLockable returns whether the given instance satisfies drivers.Lockable or not.

func MakeLockKey

func MakeLockKey(key string) (string, error)

MakeLockKey returns the prefixed key used to namespace mutex keys.

func NextWaitInterval

func NextWaitInterval(lastWaitInterval time.Duration, err error) time.Duration

NextWaitInterval determines how long to wait until the next lock retry.

func RemoveParamsFromURL

func RemoveParamsFromURL(conn string, params []string) (string, error)

Types

type AppError

type AppError struct {
	OrigErr error
	Driver  string
	Message string
}

func (*AppError) Error

func (ae *AppError) Error() string

type Config

type Config struct {
	MigrationsTable string
	// StatementTimeoutInSecs is used to set a timeout for each migration file.
	// Set below zero to disable timeout. Zero value will result in default value, which is 60 seconds.
	StatementTimeoutInSecs int
	MigrationMaxSize       int
}

type DatabaseError

type DatabaseError struct {
	OrigErr error
	Driver  string
	Message string
	Command string
	Query   []byte
}

func (*DatabaseError) Error

func (de *DatabaseError) Error() string

type DefaultLogger

type DefaultLogger struct {
}

func (DefaultLogger) Printf

func (DefaultLogger) Printf(format string, v ...interface{})

func (DefaultLogger) Println

func (DefaultLogger) Println(v ...interface{})

type Driver

type Driver interface {
	Ping() error
	// Close closes the underlying db connection. If the driver is created via Open() function
	// this method will also going to call Close() on the sql.db instance.
	Close() error
	Apply(migration *models.Migration, saveVersion bool) error
	AppliedMigrations() ([]*models.Migration, error)
	SetConfig(key string, value interface{}) error
}

type Lockable

type Lockable interface {
	DriverName() string
}

type Locker

type Locker interface {
	// Lock locks m unless the context is canceled. If the mutex is already locked by any other
	// instance, including the current one, the calling goroutine blocks until the mutex can be locked,
	// or the context is canceled.
	//
	// The mutex is locked only if a nil error is returned.
	Lock(ctx context.Context) error
	Unlock() error
}

type Logger

type Logger interface {
	Printf(format string, v ...interface{})
	Println(v ...interface{})
}

Directories

Path Synopsis
Initial code generated by generator.
Initial code generated by generator.

Jump to

Keyboard shortcuts

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