yugabytedb

package
v4.18.4 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: MIT Imports: 16 Imported by: 0

README

yugabytedb

yugabytedb://user:password@host:port/dbname?query (yugabyte://, and ysql:// work, too)

URL Query WithInstance Config Description
x-migrations-table MigrationsTable Name of the migrations table
x-lock-table LockTable Name of the table which maintains the migration lock
x-force-lock ForceLock Force lock acquisition to fix faulty migrations which may not have released the schema lock (Boolean, default is false)
x-max-retries MaxRetries How many times retry queries on retryable errors (40001, 40P01, 08006, XX000). Default is 10
x-max-retry-interval MaxRetryInterval Interval between retries increases exponentially. This option specifies maximum duration between retries. Default is 15s
x-max-retry-elapsed-time MaxRetryElapsedTime Total retries timeout. Default is 30s
dbname DatabaseName The name of the database to connect to
user The user to sign in as
password The user's password
host The host to connect to. Values that start with / are for unix domain sockets. (default is localhost)
port The port to bind to. (default is 5432)
connect_timeout Maximum wait for connection, in seconds. Zero or not specified means wait indefinitely.
sslcert Cert file location. The file must contain PEM encoded data.
sslkey Key file location. The file must contain PEM encoded data.
sslrootcert The location of the root certificate file. The file must contain PEM encoded data.
sslmode Whether or not to use SSL (disable|require|verify-ca|verify-full)

Documentation

Index

Constants

View Source
const (
	DefaultMaxRetryInterval    = time.Second * 15
	DefaultMaxRetryElapsedTime = time.Second * 30
	DefaultMaxRetries          = 10
	DefaultMigrationsTable     = "migrations"
	DefaultLockTable           = "migrations_locks"
)

Variables

View Source
var (
	ErrNilConfig          = errors.New("no config")
	ErrNoDatabaseName     = errors.New("no database name")
	ErrMaxRetriesExceeded = errors.New("max retries exceeded")
)

Functions

func WithInstance

func WithInstance(instance *sql.DB, config *Config) (database.Driver, error)

Types

type Config

type Config struct {
	MigrationsTable     string
	LockTable           string
	ForceLock           bool
	DatabaseName        string
	MaxRetryInterval    time.Duration
	MaxRetryElapsedTime time.Duration
	MaxRetries          int
}

type YugabyteDB

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

func (*YugabyteDB) Close

func (c *YugabyteDB) Close() error

func (*YugabyteDB) Drop

func (c *YugabyteDB) Drop() (err error)

func (*YugabyteDB) Lock

func (c *YugabyteDB) Lock() error

Locking is done manually with a separate lock table. Implementing advisory locks in YugabyteDB is being discussed See: https://github.com/yugabyte/yugabyte-db/issues/3642

func (*YugabyteDB) Open

func (c *YugabyteDB) Open(dbURL string) (database.Driver, error)

func (*YugabyteDB) Run

func (c *YugabyteDB) Run(migration io.Reader) error

func (*YugabyteDB) SetVersion

func (c *YugabyteDB) SetVersion(version int, dirty bool) error

func (*YugabyteDB) Unlock

func (c *YugabyteDB) Unlock() error

Locking is done manually with a separate lock table. Implementing advisory locks in YugabyteDB is being discussed See: https://github.com/yugabyte/yugabyte-db/issues/3642

func (*YugabyteDB) Version

func (c *YugabyteDB) Version() (version int, dirty bool, err error)

Jump to

Keyboard shortcuts

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