Documentation
¶
Index ¶
- func ContextWithStorage(ctx context.Context) context.Context
- func IsEmpty(err error) bool
- func RegisterImplementor(mgr Manager)
- func StreamServerInterceptor() grpc.StreamServerInterceptor
- func UnaryServerInterceptor() grpc.UnaryServerInterceptor
- type Config
- type ConfigParams
- type Dialect
- type DialectType
- type ElasticOption
- type ElasticSearch
- type MSSQL
- type Manager
- type MySQL
- type PostgreSQL
- type Redis
- type RedisOption
- type SQLOption
- type SQLite
- type Storage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 Config struct {
Schema DialectType `json:"type"`
Username string `json:"username"`
Password string `json:"password"`
Host string `json:"host"`
Port string `json:"port"`
Database string `json:"database"`
Params ConfigParams `json:"params"`
}
func (*Config) Type ¶
func (c *Config) Type() DialectType
type ConfigParams ¶
func (ConfigParams) Encode ¶
func (cp ConfigParams) Encode(dialect DialectType) string
type Dialect ¶
type Dialect interface {
Type() DialectType
Meta() *Config
URL() string
}
func NewDialect ¶
func ParseDialect ¶
type DialectType ¶
type DialectType string
const ( DialectSQLite DialectType = "sqlite3" DialectMySQL DialectType = "mysql" DialectPostgreSQL DialectType = "postgres" DialectMSSQL DialectType = "mssql" DialectRedis DialectType = "redis" DialectRedisCluster DialectType = "rediscluster" DialectElasticSearch6 DialectType = "elasticsearch6" DialectElasticSearch7 DialectType = "elasticsearch7" )
type ElasticOption ¶
func WithElasticSearchMaxRetry ¶
func WithElasticSearchMaxRetry(retries int) ElasticOption
type ElasticSearch ¶
type ElasticSearch struct {
*Config
}
func (*ElasticSearch) URL ¶
func (d *ElasticSearch) URL() string
type PostgreSQL ¶
type PostgreSQL struct {
*Config
}
func (*PostgreSQL) URL ¶
func (d *PostgreSQL) URL() string
type RedisOption ¶
func WithRedisIdleCheckFreq ¶
func WithRedisIdleCheckFreq(dur time.Duration) RedisOption
func WithRedisMaxConnAge ¶
func WithRedisMaxConnAge(dur time.Duration) RedisOption
func WithRedisMaxRetry ¶
func WithRedisMaxRetry(retries int) RedisOption
type SQLOption ¶
func WithDBConnMaxLifetime ¶
func WithDBDump ¶
func WithDBDump() SQLOption
func WithDBMaxIdleConn ¶
func WithDBMaxOpenConn ¶
type Storage ¶
type Storage interface {
InitDB(configs []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.
Click to show internal directories.
Click to hide internal directories.