connectors

package
v0.0.0-...-94ea2d4 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBConn

type DBConn interface {
	Connect(context.Context) error
	Configure(...DBOption) error
	RunDDL(context.Context, string) error
	HasSchemas(context.Context) (bool, error)
	Disconnect(context.Context) error
	LogChanges(context.Context, string, ...any) (pgconn.CommandTag, error)
}

type DBOption

type DBOption func(*DBOptions) error

func Host

func Host(host string) DBOption

func ID

func ID(id string) DBOption

func Name

func Name(name string) DBOption

func Password

func Password(password string) DBOption

func Port

func Port(port string) DBOption

func Schemas

func Schemas(schemas ...string) DBOption

func TLSConfig

func TLSConfig(caCert, clientCert, clientKey []byte) DBOption

func User

func User(user string) DBOption

type DBOptions

type DBOptions struct {
	Name      string      // the name of the database used in a DSN
	ID        string      // the identifier used for logs, recording migration activity, etc.
	Port      string      // the port used to connect to
	User      string      // the user to authenticate as
	Password  string      // the password to authenticate with
	Host      string      // the database hostname/URL
	TLSConfig *tls.Config // the certificates used to authenticate with
	Schemas   []string    // a list of schema names
}

DBOptions repesent a series of details about a given database instance

func (*DBOptions) Configure

func (o *DBOptions) Configure(opts ...DBOption) (err error)

func (*DBOptions) GetMigrationKey

func (o *DBOptions) GetMigrationKey() string

GetMigrationKey returns a key name used for writing back successful migration state to some other database

type MongoDB

type MongoDB struct {
	*DBOptions
	Client *mongo.Client
}

func NewMongoDB

func NewMongoDB(opts ...DBOption) (m *MongoDB, err error)

func (*MongoDB) Connect

func (m *MongoDB) Connect(ctx context.Context) (err error)

func (*MongoDB) Disconnect

func (m *MongoDB) Disconnect(ctx context.Context) error

func (*MongoDB) HasSchemas

func (m *MongoDB) HasSchemas(ctx context.Context) (bool, error)

func (*MongoDB) LogChanges

func (m *MongoDB) LogChanges(ctx context.Context, query string, args ...any) (tag pgconn.CommandTag, err error)

LogChanges is a stub so that MongoDB can satisfy DBConn

func (*MongoDB) RunDDL

func (m *MongoDB) RunDDL(ctx context.Context, ddl string) error

type PostgresDB

type PostgresDB struct {
	*DBOptions
	Conn *pgx.Conn
}

func NewPostgresDB

func NewPostgresDB(opts ...DBOption) (*PostgresDB, error)

func (*PostgresDB) Connect

func (p *PostgresDB) Connect(ctx context.Context) (err error)

func (*PostgresDB) Disconnect

func (p *PostgresDB) Disconnect(ctx context.Context) error

func (*PostgresDB) GetInstalledSchemaVersion

func (p *PostgresDB) GetInstalledSchemaVersion(ctx context.Context) (version string, err error)

func (*PostgresDB) HasMetadataSchema

func (p *PostgresDB) HasMetadataSchema(ctx context.Context) (has bool, err error)

func (*PostgresDB) HasSchemas

func (p *PostgresDB) HasSchemas(ctx context.Context) (bool, error)

func (*PostgresDB) LogChanges

func (p *PostgresDB) LogChanges(ctx context.Context, query string, args ...any) (tag pgconn.CommandTag, err error)

LogChanges

func (*PostgresDB) RunDDL

func (p *PostgresDB) RunDDL(ctx context.Context, ddl string) (err error)

Jump to

Keyboard shortcuts

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