update
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Description : mysql客户端
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 2021-03-01 9:20 下午
|
||||
package mysql
|
||||
@ -18,7 +18,7 @@ import (
|
||||
|
||||
// GetDatabaseClient 获取日志实例
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:49 下午 2021/3/1
|
||||
func GetDatabaseClient(conf *DBConfig, logConf *LogConfig) (*gorm.DB, error) {
|
||||
@ -49,7 +49,7 @@ func GetDatabaseClient(conf *DBConfig, logConf *LogConfig) (*gorm.DB, error) {
|
||||
|
||||
// buildConnectionDSN 构建建立连接的DSN
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 9:34 下午 2021/3/1
|
||||
func buildConnectionDSN(conf *DBConfig) string {
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Description : 数据定义
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 2021-03-01 9:27 下午
|
||||
package mysql
|
||||
@ -14,7 +14,7 @@ import (
|
||||
|
||||
// DBConfig 数据库连接的配置
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 9:32 下午 2021/3/1
|
||||
type DBConfig struct {
|
||||
@ -30,7 +30,7 @@ type DBConfig struct {
|
||||
|
||||
// LogConfig 日志配置
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:51 下午 2021/3/1
|
||||
type LogConfig struct {
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Description : 异常定义
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 2021-03-01 9:42 下午
|
||||
package mysql
|
||||
@ -11,7 +11,7 @@ import "github.com/pkg/errors"
|
||||
|
||||
// ConnectionOpenError 数据库连接失败
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 9:43 下午 2021/3/1
|
||||
func ConnectionOpenError(err error) error {
|
||||
@ -20,7 +20,7 @@ func ConnectionOpenError(err error) error {
|
||||
|
||||
// CreateDBLogError 打开日志失败
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:53 下午 2021/3/1
|
||||
func CreateDBLogError(err error) error {
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Description : redis 客户端
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 2021-02-27 4:49 下午
|
||||
package redis
|
||||
@ -20,7 +20,7 @@ import (
|
||||
|
||||
// defaultParseError ...
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:59 下午 2021/2/27
|
||||
func defaultParseError(err error) error {
|
||||
@ -44,7 +44,7 @@ func defaultParseError(err error) error {
|
||||
|
||||
// Options 连接选项,百分之百兼容第三方包的选项
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 4:57 下午 2021/2/27
|
||||
type Options struct {
|
||||
@ -63,7 +63,7 @@ type RealClient struct {
|
||||
|
||||
// NewClient 获取redis client实例
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 5:05 下午 2021/2/27
|
||||
func NewClient(config map[string]Options, parseErrorFunc func(err error) error) (ClientInterface, error) {
|
||||
@ -80,7 +80,7 @@ func NewClient(config map[string]Options, parseErrorFunc func(err error) error)
|
||||
|
||||
// Client 包装的redis client
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 4:52 下午 2021/2/27
|
||||
type Client struct {
|
||||
@ -91,7 +91,7 @@ type Client struct {
|
||||
|
||||
// init 初始化redis连接
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 5:31 下午 2021/2/27
|
||||
func (c *Client) init() error {
|
||||
@ -135,7 +135,7 @@ func (c *Client) init() error {
|
||||
|
||||
// getLogger ...
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 7:07 下午 2021/2/27
|
||||
func (c *Client) getLogger(conf *LoggerConfig) (*zap.Logger, error) {
|
||||
@ -152,7 +152,7 @@ func (c *Client) getLogger(conf *LoggerConfig) (*zap.Logger, error) {
|
||||
|
||||
// GetRedisClient 获取redis实例
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 5:16 下午 2021/2/27
|
||||
func (c *Client) GetRedisClient(flag string) (*RealClient, error) {
|
||||
@ -165,7 +165,7 @@ func (c *Client) GetRedisClient(flag string) (*RealClient, error) {
|
||||
|
||||
// log 记录redis请求日志
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 8:52 下午 2021/2/27
|
||||
func (c *Client) log(ctx *Context, realClient *RealClient, cmdResult redisInstance.Cmder, startTime int64, finishTime int64) {
|
||||
@ -183,7 +183,7 @@ func (c *Client) log(ctx *Context, realClient *RealClient, cmdResult redisInstan
|
||||
|
||||
// CommandProxy 执行命令的代理
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 9:41 下午 2021/2/27
|
||||
func (c *Client) CommandProxy(ctx *Context, flag string, cmd string, param ...interface{}) (interface{}, error) {
|
||||
@ -210,7 +210,7 @@ func (c *Client) CommandProxy(ctx *Context, flag string, cmd string, param ...in
|
||||
|
||||
// CommandProxyWithReceiver 执行命令,并解析结果
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:00 下午 2021/2/27
|
||||
func (c *Client) CommandProxyWithReceiver(ctx *Context, flag string, receiver interface{}, cmd string, param ...interface{}) error {
|
||||
@ -231,7 +231,7 @@ func (c *Client) CommandProxyWithReceiver(ctx *Context, flag string, receiver in
|
||||
|
||||
// ClientInterface 定义redis client的接口实现,方便单元测试数据mock
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:49 下午 2021/2/27
|
||||
type ClientInterface interface {
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Description : redis...
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 2021-02-27 8:22 下午
|
||||
package redis
|
||||
@ -30,7 +30,7 @@ const (
|
||||
|
||||
// Context 请求上下文
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 8:25 下午 2021/2/27
|
||||
type Context struct {
|
||||
@ -44,7 +44,7 @@ type Context struct {
|
||||
|
||||
// NewContext 生成一个上下文
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 8:26 下午 2021/2/27
|
||||
func NewContext(flag string, of ...SetContextFunc) *Context {
|
||||
@ -87,7 +87,7 @@ type SetContextFunc func(rc *Context)
|
||||
|
||||
// WithCtx 设置context
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 8:30 下午 2021/2/27
|
||||
func WithCtx(ctx context.Context) SetContextFunc {
|
||||
@ -98,7 +98,7 @@ func WithCtx(ctx context.Context) SetContextFunc {
|
||||
|
||||
// WithGinCtx 设置gin上下文
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 8:34 下午 2021/2/27
|
||||
func WithGinCtx(ginCtx *gin.Context) SetContextFunc {
|
||||
@ -109,7 +109,7 @@ func WithGinCtx(ginCtx *gin.Context) SetContextFunc {
|
||||
|
||||
// WithExtra 设置扩展信息
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 8:36 下午 2021/2/27
|
||||
func WithExtra(extra easymap.EasyMap) SetContextFunc {
|
||||
@ -120,7 +120,7 @@ func WithExtra(extra easymap.EasyMap) SetContextFunc {
|
||||
|
||||
// WithRequestIDField 设置request_id参数名
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 8:41 下午 2021/2/27
|
||||
func WithRequestIDField(requestIDField string) SetContextFunc {
|
||||
@ -131,7 +131,7 @@ func WithRequestIDField(requestIDField string) SetContextFunc {
|
||||
|
||||
// WithRequestID ...
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 8:42 下午 2021/2/27
|
||||
func WithRequestID(requestID string) SetContextFunc {
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Description : redis...
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 2021-02-27 5:13 下午
|
||||
package redis
|
||||
@ -11,7 +11,7 @@ import "github.com/pkg/errors"
|
||||
|
||||
// FlagNotFound flag不存在异常
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 5:15 下午 2021/2/27
|
||||
func FlagNotFound(flag string) error {
|
||||
@ -20,7 +20,7 @@ func FlagNotFound(flag string) error {
|
||||
|
||||
// LoggerInitFail 日志初始化失败
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 7:30 下午 2021/2/27
|
||||
func LoggerInitFail(flag string, err error) error {
|
||||
@ -29,7 +29,7 @@ func LoggerInitFail(flag string, err error) error {
|
||||
|
||||
// EmptyCmd 未设置要执行的命令
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 9:46 下午 2021/2/27
|
||||
func EmptyCmd() error {
|
||||
@ -38,7 +38,7 @@ func EmptyCmd() error {
|
||||
|
||||
// CommandExecuteFail 命令执行失败
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 9:58 下午 2021/2/27
|
||||
func CommandExecuteFail(err error) error {
|
||||
@ -47,7 +47,7 @@ func CommandExecuteFail(err error) error {
|
||||
|
||||
// ReceiverISNIL 数据接收者是空指针
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:05 下午 2021/2/27
|
||||
func ReceiverISNIL() error {
|
||||
@ -56,7 +56,7 @@ func ReceiverISNIL() error {
|
||||
|
||||
// ResultConvertFail 数据结果解析失败
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:07 下午 2021/2/27
|
||||
func ResultConvertFail(err error) error {
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Description : redis...
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 2021-02-27 5:26 下午
|
||||
package redis
|
||||
@ -14,7 +14,7 @@ import (
|
||||
|
||||
// LoggerConfig 日志配置
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 5:26 下午 2021/2/27
|
||||
type LoggerConfig struct {
|
||||
@ -28,7 +28,7 @@ type LoggerConfig struct {
|
||||
|
||||
// LogFieldConfig 日志字段配置
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 9:20 下午 2021/2/27
|
||||
type LogFieldConfig struct {
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Description : redis...
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 2021-02-27 10:14 下午
|
||||
package redis
|
||||
@ -18,7 +18,7 @@ import (
|
||||
|
||||
// TestCommandProxy ...
|
||||
//
|
||||
// Author : go_developer@163.com<张德满>
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:22 下午 2021/2/27
|
||||
func TestCommandProxy(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user