db

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CtxMongoKey = util.CtxKey("ctxMongoKey")
	HeaderDBKey = "raccMongoDB"
)
View Source
const (
	CoreDB = "core"
	UserDB = "user"
)
View Source
const (
	CtxRedisKey = util.CtxKey("ctxRedisKey")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type EsDI

type EsDI interface {
	NewSearch(ctx context.Context) *elastic.Client
}

type EsV7Conf

type EsV7Conf struct {
	Hosts []string `yaml:"host"`
	Index string
}

func (*EsV7Conf) NewSearch

func (s *EsV7Conf) NewSearch(ctx context.Context) *elastic.Client

type MongoConf

type MongoConf struct {
	Uri       string `yaml:"uri"`
	User      string `yaml:"user"`
	Pass      string `yaml:"pass"`
	DefaultDB string `yaml:"defaul"`
	// contains filtered or unexported fields
}

func (MongoConf) NewMongoDBClient

func (mc MongoConf) NewMongoDBClient(ctx context.Context, userDB string) (MongoDBClient, error)

type MongoDBClient

type MongoDBClient interface {
	GetCoreDB() *mongo.Database
	GetUserDB() *mongo.Database
	WithSession(f func(sc mongo.SessionContext) error) error
	AbortTransaction(sc mongo.SessionContext) error
	CommitTransaction(sc mongo.SessionContext) error
	Close()
}

func GetCtxMgoDBClient

func GetCtxMgoDBClient(req *http.Request) MongoDBClient

type MongoDI

type MongoDI interface {
	NewMongoDBClient(ctx context.Context, userDB string) (MongoDBClient, error)
}

type RedisClient

type RedisClient interface {
	Close() error
	Ping() string
	Set(k string, v interface{}, exp time.Duration) (string, error)
	Del(k string) (int64, error)
	LPush(k string, v interface{}) (int64, error)
	RPop(k string) ([]byte, error)
	HMGet(key string, field ...string) []interface{}
	Exists(key string) bool
}

func GetRedisByReq

func GetRedisByReq(req *http.Request) RedisClient

type RedisConf

type RedisConf struct {
	Host string `yaml:"host"`
	Pwd  string `yaml:"pass"`
	DB   int    `yaml:"db"`
}

func (*RedisConf) NewRedisClient

func (rc *RedisConf) NewRedisClient(ctx context.Context) (RedisClient, error)

type RedisDI

type RedisDI interface {
	NewRedisClient(ctx context.Context) (RedisClient, error)
}

Jump to

Keyboard shortcuts

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