driver

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package driver holds the driver interface.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLocked                  = fmt.Errorf("can't acquire lock")
	ErrFailedToSendCloseNotify = fmt.Errorf("failed to send closeNotify alert, please see https://github.com/jackc/pgx/issues/984 for more details")
)

Functions

func CanIgnoreError added in v1.9.1

func CanIgnoreError(err error) bool

func Drivers added in v1.3.1

func Drivers() []string

Drivers returns a sorted list of the names of the registered drivers.

func GenerateAdvisoryLockId added in v1.6.0

func GenerateAdvisoryLockId(databaseName string, additionalNames ...string) (string, error)

GenerateAdvisoryLockId inspired by rails migrations, see https://goo.gl/8o9bCT

func RegisterDriver added in v1.3.1

func RegisterDriver(name string, driver *DriverGenerator)

Registers a driver so it can be created from its name. Drivers should call this from an init() function so that they registers themselvse on import

Types

type Driver

type Driver interface {

	// Initialize is the first function to be called.
	// Check the url string and open and verify any connection
	// that has to be made.
	Initialize(url string, initOptions ...func(Driver)) error

	// Close is the last function to be called.
	// Close any open connection here.
	Close() error

	// FilenameExtension returns the extension of the migration files.
	// The returned string must not begin with a dot.
	FilenameExtension() string

	// Migrate is the heart of the driver.
	// It will receive a file which the driver should apply
	// to its backend or whatever. The migration function should use
	// the pipe channel to return any errors or other useful information.
	Migrate(file file.File, pipe chan interface{})

	// Version returns the current migration version.
	Version() (uint64, error)
}

Driver is the interface type that needs to implemented by all drivers.

func New

func New(url string, initOptions ...func(Driver)) (Driver, error)

New returns Driver and calls Initialize on it

type DriverGenerator added in v1.6.0

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

func GetDriverGenerator added in v1.6.0

func GetDriverGenerator(name string) (*DriverGenerator, bool)

Retrieves a registered driver by name

func NewDriverGenerator added in v1.6.0

func NewDriverGenerator(fn func() Driver) *DriverGenerator

func (*DriverGenerator) Generate added in v1.6.0

func (dg *DriverGenerator) Generate() Driver

func (*DriverGenerator) RegisterInitFunction added in v1.6.0

func (dg *DriverGenerator) RegisterInitFunction(fnInit func(Driver))

Directories

Path Synopsis
Package bash implements the Driver interface.
Package bash implements the Driver interface.
Package cassandra implements the Driver interface.
Package cassandra implements the Driver interface.
Package mysql implements the Driver interface.
Package mysql implements the Driver interface.
Package postgres implements the Driver interface.
Package postgres implements the Driver interface.
Package sqlite3 implements the Driver interface.
Package sqlite3 implements the Driver interface.

Jump to

Keyboard shortcuts

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