storage

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: MIT Imports: 7 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithStorage

func ContextWithStorage(ctx context.Context) context.Context

func IsEmpty

func IsEmpty(err error) bool

func RegisterCommonDialectImplementor

func RegisterCommonDialectImplementor(schema configure.Schema, dialect CommonDialect)

RegisterCommonDialectImplementor registers common storage Dialector.

func RegisterImplementor

func RegisterImplementor(mgr Manager)

RegisterImplementor registers the storage manage service implementor.

func RegisterSQLDialectImplementor

func RegisterSQLDialectImplementor(sql SQLDialect)

RegisterSQLDialectImplementor registers gorm sql Dialector.

func StreamServerInterceptor

func StreamServerInterceptor() grpc.StreamServerInterceptor

StreamServerInterceptor returns a new streaming server interceptor for storage manager.

func UnaryServerInterceptor

func UnaryServerInterceptor() grpc.UnaryServerInterceptor

UnaryServerInterceptor returns a new unary server interceptor for storage manager.

Types

type CommonDialect

type CommonDialect interface {
	Open(configure.Address) (interface{}, error)
}

func CommonDialectImplementor

func CommonDialectImplementor(schema configure.Schema) CommonDialect

CommonDialectImplementor returns the common storage Dialector implementor.

type Manager

type Manager interface {
	New(component string)
	Get(component string) Storage
}

func Implementor

func Implementor() Manager

Implementor returns the storage manage service implementor.

type RedisOption

type RedisOption func(*redis.Options)

func WithRedisIdleCheckFreq

func WithRedisIdleCheckFreq(dur time.Duration) RedisOption

func WithRedisMaxConnAge

func WithRedisMaxConnAge(dur time.Duration) RedisOption

func WithRedisMaxRetry

func WithRedisMaxRetry(retries int) RedisOption

type SQLDialect

type SQLDialect interface {
	Open(configure.Address) gorm.Dialector
}

func SQLDialectImplementor

func SQLDialectImplementor() SQLDialect

SQLDialectImplementor returns the gorm sql Dialector implementor.

type SQLOption

type SQLOption func(*gorm.Config, *gorm.DB)

func WithDBConnMaxLifetime

func WithDBConnMaxLifetime(dur time.Duration) SQLOption

WithDBConnMaxLifetime sets the maximum amount of time a connection may be reused.

func WithDBDebug

func WithDBDebug() SQLOption

WithDBDebug starts debug mode.

func WithDBDryRun

func WithDBDryRun() SQLOption

WithDBDryRun generates sql without executing.

func WithDBMaxIdleConn

func WithDBMaxIdleConn(maxIdleConn int) SQLOption

WithDBMaxIdleConn sets the maximum number of connections in the idle connection pool.

func WithDBMaxOpenConn

func WithDBMaxOpenConn(maxOpenConn int) SQLOption

WithDBMaxOpenConn sets the maximum number of open connections to the database.

func WithoutDBAutomaticPing

func WithoutDBAutomaticPing() SQLOption

WithoutDBAutomaticPing disables automatic ping.

func WithoutDBDefaultTransaction

func WithoutDBDefaultTransaction() SQLOption

WithoutDBDefaultTransaction disables single create, update, delete operations in transaction.

type Storage

type Storage interface {
	InitDB(master configure.Address, slaves []configure.Address, opts ...SQLOption) error
	InitRedis(configs []configure.Address, opts ...RedisOption) error
	GetDB(readOnly ...bool) *gorm.DB
	GetRedisz() []redis.Cmdable
	GetRedis(key interface{}) redis.Cmdable

	InitCommon(config configure.Address) error
	GetCommon(schema configure.Schema) interface{}
}

Storage interface.

func ContextStorage

func ContextStorage(ctx context.Context, component string) Storage

Jump to

Keyboard shortcuts

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