Documentation ¶
Index ¶
- Constants
- Variables
- func ErrNotBulker(iface interface{}) error
- func ErrNotConfigPointer(iface interface{}) error
- func ErrNotEnityPointer(iface interface{}) error
- func ErrNotMigrationPointer(iface interface{}) error
- func ErrNotMigrator(iface interface{}) error
- func ErrNotMutexPointer(iface interface{}) error
- func ErrNotQueueItemPointer(iface interface{}) error
- func GetEnity(ctx context.Context, provider, enityName string) (interface{}, error)
- func Registrate(ctx context.Context) context.Context
- func RegistrateEnity(ctx context.Context, provider, enityName string, options interface{}) (context.Context, error)
- func RegistrateProvider(ctx context.Context, name string, p Provider) (context.Context, error)
- type Bulker
- type Databases
- func (d *Databases) AppendToQueue(providerName, connectionName string, queueItem interface{}) error
- func (d *Databases) GetAllAliveHandlers(out stats.MapCheckFunc) (stats.MapCheckFunc, error)
- func (d *Databases) GetAllMetrics(out stats.MapMetricsOptions) (stats.MapMetricsOptions, error)
- func (d *Databases) GetAllReadyHandlers(out stats.MapCheckFunc) (stats.MapCheckFunc, error)
- func (d *Databases) GetProvider(providerName string) (Provider, error)
- func (d *Databases) RegisterMigration(providerName, connectionName string, migration interface{}) error
- func (d *Databases) WaitForFlush(providerName, connectionName string) error
- type Migrator
- type Provider
Constants ¶
const (
ProvidersName = "database"
)
Variables ¶
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 RegistrateEnity ¶
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 NewDatabases ¶
func (*Databases) AppendToQueue ¶
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 ¶
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 ¶
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 ¶
type Provider interface { provider.IProvider provider.IEnityManager stats.IProviderMetrics }
Provider is an interface every database provider should conform. Every provider can hold more than one connection.