db

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProvidersName = "database"
)

Variables

View Source
var (
	ErrEmptyDatabases          = errors.New("empty databases")
	ErrEmptyConnectionName     = errors.New("empty connection name is not allowed")
	ErrConnectionPointerIsNil  = errors.New("nil passed as connection pointer")
	ErrConnectionDoesNotExists = errors.New("connection does not exist")
	ErrMutexPointerIsNil       = errors.New("nil passed as mutex pointer")
	ErrNotLockIDPointer        = errors.New("passed lockID is not int64")
	ErrDBConnNotEstablished    = errors.New("database connection not established")
)

Functions

func ErrNotBulker added in v0.3.0

func ErrNotBulker(iface interface{}) error

func ErrNotConfigPointer added in v0.3.0

func ErrNotConfigPointer(iface interface{}) error

func ErrNotEnityPointer

func ErrNotEnityPointer(iface interface{}) error

func ErrNotMigrationPointer

func ErrNotMigrationPointer(iface interface{}) error

func ErrNotMigrator added in v0.3.0

func ErrNotMigrator(iface interface{}) error

func ErrNotMutexPointer

func ErrNotMutexPointer(iface interface{}) error

func ErrNotQueueItemPointer

func ErrNotQueueItemPointer(iface interface{}) error

func GetEnity

func GetEnity(ctx context.Context, provider, enityName string) (interface{}, error)

func Registrate

func Registrate(ctx context.Context) context.Context

func RegistrateEnity

func RegistrateEnity(ctx context.Context, provider, enityName string, options interface{}) (context.Context, error)

func RegistrateProvider

func RegistrateProvider(ctx context.Context, name string, p Provider) (context.Context, error)

Types

type Bulker added in v0.3.0

type Bulker interface {
	// AppendToQueue should add passed item into processing queue, if provider
	// able to be asynchronous (e.g. for batching database inserts or updates,
	// aka transactions). It's up to provider to cast passed item into
	// required data type. Provider should return error if something goes
	// wrong, e.g. if AddToQueue() used on provider that doesn't support
	// transactions or queues.
	AppendToQueue(connectionName string, item interface{}) error
	// WaitForFlush blocks execution until queue will be empty.
	WaitForFlush(connectionName string) error
}

type Databases

type Databases struct {
	*providerswithmetrics.BaseProvidersWithMetrics
}

Databases is a controlling structure for all databases and providers.

func Get

func Get(ctx context.Context) *Databases

func NewDatabases

func NewDatabases(ctx context.Context) *Databases

func (*Databases) AppendToQueue

func (d *Databases) AppendToQueue(providerName, connectionName string, queueItem interface{}) error

AppendToQueue appends passed queueItem to queue for designated provider and connection. Passed queue item should be valid for designated provider, otherwise error will be returned.

func (*Databases) GetAllAliveHandlers

func (d *Databases) GetAllAliveHandlers(out stats.MapCheckFunc) (stats.MapCheckFunc, error)

GetAllAliveHandlers collect all aliveHandlers for Databases

func (*Databases) GetAllMetrics

func (d *Databases) GetAllMetrics(out stats.MapMetricsOptions) (stats.MapMetricsOptions, error)

GetAllMetrics collect all metrics for Databases

func (*Databases) GetAllReadyHandlers

func (d *Databases) GetAllReadyHandlers(out stats.MapCheckFunc) (stats.MapCheckFunc, error)

GetAllReadyHandlers collect all readyHandlers for Databases

func (*Databases) GetProvider

func (d *Databases) GetProvider(providerName string) (Provider, error)

GetProvider returns requested database provider. Return error if providers wasn't registered.

func (*Databases) RegisterMigration

func (d *Databases) RegisterMigration(providerName, connectionName string, migration interface{}) error

RegisterMigration registers migration for designated provider and connection.

func (*Databases) WaitForFlush

func (d *Databases) WaitForFlush(providerName, connectionName string) error

WaitForFlush block execution until underlying provider will flush queue. If something will go wrong here - error will be returned by provider.

type Migrator added in v0.3.0

type Migrator interface {
	// RegisterMigration registers migration for specified connection.
	// It is up to provider to provide instructions about working with
	// migrations and how to put them into migration interface. It is
	// recommended to use separate structure.
	RegisterMigration(connectionName string, migration interface{}) error
}

type Provider

Provider is an interface every database provider should conform. Every provider can hold more than one connection.

func GetProvider

func GetProvider(ctx context.Context, name string) (Provider, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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