bunny

package
v0.0.0-...-98c8ee3 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2019 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMultipleRows = errors.New("sqlbunny: multiple rows in result set")
View Source
var NullBytes = []byte("null")

Functions

func Atomic

func Atomic(ctx context.Context, fn func(ctx context.Context) error) error

Atomic invokes the passed function in the context of a managed SQL transaction. Any errors returned from the user-supplied function are returned from this function.

Retries are automatically performed in case of serialization failures or deadlocks.

func AtomicReadOnly

func AtomicReadOnly(ctx context.Context, fn func(ctx context.Context) error) error

AtomicReadOnly invokes the passed function in the context of a managed SQL read only transaction. Any errors returned from the user-supplied function are returned from this function.

Retries are automatically performed in case of serialization failures or deadlocks.

func ContextWithDB

func ContextWithDB(ctx context.Context, db DB) context.Context

func Exec

func Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

func IsErrMultipleRows

func IsErrMultipleRows(err error) bool

func IsErrNoRows

func IsErrNoRows(err error) bool

func Query

func Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)

func QueryRow

func QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row

func SetLogger

func SetLogger(l Logger)

Types

type BeginLogInfo

type BeginLogInfo struct {
	ReadOnly bool
}

type CommitLogInfo

type CommitLogInfo struct {
	Duration time.Duration
}

type DB

type DB interface {
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
}

DB can perform SQL queries.

func DBFromContext

func DBFromContext(ctx context.Context) DB

type HookPoint

type HookPoint int

HookPoint is the point in time at which we hook

const (
	BeforeInsertHook HookPoint = iota + 1
	BeforeUpdateHook
	BeforeDeleteHook
	AfterInsertHook
	AfterSelectHook
	AfterUpdateHook
	AfterDeleteHook
)

the hook point constants

type InvalidEnumError

type InvalidEnumError struct {
	Value []byte
	Type  string
}

func (*InvalidEnumError) Error

func (e *InvalidEnumError) Error() string

type Logger

type Logger interface {
	LogQuery(ctx context.Context, info QueryLogInfo)
	LogBegin(ctx context.Context, info BeginLogInfo) context.Context
	LogCommit(ctx context.Context, info CommitLogInfo)
	LogRollback(ctx context.Context, info RollbackLogInfo)
}

type QueryLogInfo

type QueryLogInfo struct {
	Query    string
	Args     []interface{}
	Duration time.Duration
	Err      error
}

type RollbackLogInfo

type RollbackLogInfo struct {
	Duration time.Duration
	Err      error
}

Jump to

Keyboard shortcuts

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