Documentation
¶
Overview ¶
Package database provides database client initialization.
Package database provides database client initialization.
Index ¶
- Variables
- func CloseDB() error
- func CloseRedis() error
- func GenerateOrderNo(prefix string, snowId snowflake.ID) string
- func GetDB() *sgorm.DB
- func GetRedisCli() *goredis.Client
- func GetSequenceFromSnowId(id snowflake.ID) int64
- func GetSnowId() snowflake.ID
- func GetSnowNode() *snowflake.Node
- func GetTimeFromSnowId(id snowflake.ID) time.Time
- func InitCache(cType string)
- func InitDB()
- func InitMysql() *sgorm.DB
- func InitPostgresql() *sgorm.DB
- func InitRedis()
- func InitSnowNode()
- func InitSqlite() *sgorm.DB
- func ParseSnowId(id snowflake.ID) map[string]int64
- type CacheType
- type MqCfg
- type RabbitMQClient
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrCacheNotFound No hit cache ErrCacheNotFound = goredis.ErrRedisNotFound )
View Source
var (
ErrRecordNotFound = sgorm.ErrRecordNotFound
)
Functions ¶
func GenerateOrderNo ¶ added in v1.3.6
GenerateOrderNo 生成带有业务含义的订单号
func GetSequenceFromSnowId ¶ added in v1.3.6
GetSequenceFromSnowId 从雪花ID中提取序列号
Types ¶
type CacheType ¶
type CacheType struct {
CType string // cache type memory or redis
Rdb *goredis.Client // if CType=redis, Rdb cannot be empty
}
CacheType cache type
type MqCfg ¶ added in v1.3.6
type MqCfg struct {
ExchangeName string // 交换机名称
NormalQueueName string // 普通队列名称
Url string // RabbitMQ连接URL
DialTimeout time.Duration // 连接超时时间
IsDeadLetter bool // 是否启用死信队列
}
MqCfg 包含 RabbitMQ 配置信息
type RabbitMQClient ¶ added in v1.3.6
type RabbitMQClient struct {
// contains filtered or unexported fields
}
RabbitMQClient 封装RabbitMQ操作
func GetClient ¶ added in v1.3.6
func GetClient(ctx context.Context, cfg *MqCfg) (*RabbitMQClient, error)
GetClient 从连接池获取客户端
func (*RabbitMQClient) CloseConnection ¶ added in v1.3.6
func (c *RabbitMQClient) CloseConnection()
CloseConnection 关闭连接
Click to show internal directories.
Click to hide internal directories.