Documentation ¶
Index ¶
- func ContextWithStorage(ctx context.Context) context.Context
- func IsEmpty(err error) bool
- func RegisterImplementor(mgr Manager)
- func RegisterSQLDialectImplementor(sql SQLDialect)
- func StreamServerInterceptor() grpc.StreamServerInterceptor
- func UnaryServerInterceptor() grpc.UnaryServerInterceptor
- type Config
- type ConfigParams
- type Dialect
- type ElasticOption
- type Manager
- type RedisOption
- type SQLDialect
- type SQLOption
- type Schema
- type Storage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterImplementor ¶
func RegisterImplementor(mgr Manager)
RegisterImplementor registers the storage manage service implementor.
func RegisterSQLDialectImplementor ¶ added in v1.0.0
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 Config ¶
type ConfigParams ¶
func (ConfigParams) Encode ¶
func (cp ConfigParams) Encode(schema Schema) string
type ElasticOption ¶
func WithElasticSearchMaxRetry ¶
func WithElasticSearchMaxRetry(retries int) ElasticOption
WithElasticSearchMaxRetry sets retry times.
func WithRetryOnTimeout ¶ added in v1.0.0
func WithRetryOnTimeout() ElasticOption
WithRetryOnTimeout enables retry on timeout.
func WithRetryStatus ¶ added in v1.0.0
func WithRetryStatus(status ...int) ElasticOption
WithRetryStatus sets status codes for retry. Default: 502, 503, 504.
func WithoutRetry ¶ added in v1.0.0
func WithoutRetry() ElasticOption
WithoutRetry disables retrying.
type Manager ¶
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 ¶ added in v1.0.0
func SQLDialectImplementor ¶ added in v1.0.0
func SQLDialectImplementor() SQLDialect
SQLDialectImplementor returns the gorm sql Dialector implementor.
type SQLOption ¶
func WithDBConnMaxLifetime ¶
WithDBConnMaxLifetime sets the maximum amount of time a connection may be reused.
func WithDBDryRun ¶ added in v1.0.0
func WithDBDryRun() SQLOption
WithDBDryRun generates sql without executing.
func WithDBMaxIdleConn ¶
WithDBMaxIdleConn sets the maximum number of connections in the idle connection pool.
func WithDBMaxOpenConn ¶
WithDBMaxOpenConn sets the maximum number of open connections to the database.
func WithoutDBAutomaticPing ¶ added in v1.0.0
func WithoutDBAutomaticPing() SQLOption
WithoutDBAutomaticPing disables automatic ping.
func WithoutDBDefaultTransaction ¶ added in v1.0.0
func WithoutDBDefaultTransaction() SQLOption
WithoutDBDefaultTransaction disables single create, update, delete operations in transaction.
type Storage ¶
type Storage interface { InitDB(master Config, slaves []Config, opts ...SQLOption) error InitElasticSearch(config Config, opts ...ElasticOption) error InitRedis(configs []Config, opts ...RedisOption) error GetDB(readOnly ...bool) *gorm.DB GetESv6() *es6.Client GetESv7() *es7.Client GetRedisz() []redis.Cmdable GetRedis(key interface{}) redis.Cmdable }
Storage interface.