dbconnector

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Addr

type Addr string

Addr is connection address, usually in "host:port" format

type DBConnector

type DBConnector interface {
	// Connect creates new database connection.
	//
	// NOTE:
	//
	// Connect implementation should return instance of app.ErrUnavailable if target DB is unavailable.
	//
	// If caller canceled the context, impl can return context.Canceled/context.DeadlineExceeded errors
	Connect(ctx context.Context, addr Addr, credentials models.Credentials) (conn ExecutorCloser, err error)
}

DBConnector is object that can open new connections

type ExecutorCloser

type ExecutorCloser interface {
	// Exec performs DB query and return results.
	//
	// NOTE:
	//
	// Implementation of Exec should return instance of app.ErrUnavailable if DB connection is loosed.
	// So, caller can decide: try to reconnect and repeat or not.
	//
	// If caller canceled the context, impl can return context.Canceled/context.DeadlineExceeded errors
	Exec(ctx context.Context, query models.Query) (rows models.RowSet, affectedRows int, err error)
	io.Closer
}

ExecutorCloser is object that can make database queries

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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