redis

package
v0.0.0-...-8227b98 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package redis ...

Description : redis 客户端

Author : go_developer@163.com<张德满>

Date : 2021-02-27 4:49 下午

Package redis...

Description : redis...

Author : go_developer@163.com<张德满>

Date : 2021-02-27 8:22 下午

Package redis...

Description : redis...

Author : go_developer@163.com<张德满>

Date : 2021-02-27 5:13 下午

Package redis...

Description : redis...

Author : go_developer@163.com<张德满>

Date : 2021-02-27 5:26 下午

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommandExecuteFail

func CommandExecuteFail(err error) error

CommandExecuteFail 命令执行失败

Author : go_developer@163.com<张德满>

Date : 9:58 下午 2021/2/27

func EmptyCmd

func EmptyCmd() error

EmptyCmd 未设置要执行的命令

Author : go_developer@163.com<张德满>

Date : 9:46 下午 2021/2/27

func FlagNotFound

func FlagNotFound(flag string) error

FlagNotFound flag不存在异常

Author : go_developer@163.com<张德满>

Date : 5:15 下午 2021/2/27

func LoggerInitFail

func LoggerInitFail(flag string, err error) error

LoggerInitFail 日志初始化失败

Author : go_developer@163.com<张德满>

Date : 7:30 下午 2021/2/27

func ReceiverISNIL

func ReceiverISNIL() error

ReceiverISNIL 数据接收者是空指针

Author : go_developer@163.com<张德满>

Date : 10:05 下午 2021/2/27

func ResultConvertFail

func ResultConvertFail(err error) error

ResultConvertFail 数据结果解析失败

Author : go_developer@163.com<张德满>

Date : 10:07 下午 2021/2/27

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client 包装的redis client

Author : go_developer@163.com<张德满>

Date : 4:52 下午 2021/2/27

func (*Client) CommandProxy

func (c *Client) CommandProxy(ctx *Context, flag string, cmd string, param ...interface{}) (interface{}, error)

CommandProxy 执行命令的代理

Author : go_developer@163.com<张德满>

Date : 9:41 下午 2021/2/27

func (*Client) CommandProxyWithReceiver

func (c *Client) CommandProxyWithReceiver(ctx *Context, flag string, receiver interface{}, cmd string, param ...interface{}) error

CommandProxyWithReceiver 执行命令,并解析结果

Author : go_developer@163.com<张德满>

Date : 10:00 下午 2021/2/27

func (*Client) GetRedisClient

func (c *Client) GetRedisClient(flag string) (*RealClient, error)

GetRedisClient 获取redis实例

Author : go_developer@163.com<张德满>

Date : 5:16 下午 2021/2/27

type ClientInterface

type ClientInterface interface {
	GetRedisClient(flag string) (*RealClient, error)
	CommandProxy(ctx *Context, flag string, cmd string, param ...interface{}) (interface{}, error)
	CommandProxyWithReceiver(ctx *Context, flag string, receiver interface{}, cmd string, param ...interface{}) error
}

ClientInterface 定义redis client的接口实现,方便单元测试数据mock

Author : go_developer@163.com<张德满>

Date : 10:49 下午 2021/2/27

func NewClient

func NewClient(config map[string]Options, parseErrorFunc func(err error) error) (ClientInterface, error)

NewClient 获取redis client实例

Author : go_developer@163.com<张德满>

Date : 5:05 下午 2021/2/27

type Context

type Context struct {
	Flag           string          // 哪个模块的上下文
	Ctx            context.Context // ctx
	GinCtx         *gin.Context    // http 请求绑定的gin.context
	RequestIDField string          // requestID 字段名
	RequestID      string          // requestID 此字段有值, 直接使用此值,无值, 去GinCtx 中读取 RequestIDField
	Extra          easymap.EasyMap // 扩展信息
}

Context 请求上下文

Author : go_developer@163.com<张德满>

Date : 8:25 下午 2021/2/27

func NewContext

func NewContext(flag string, of ...SetContextFunc) *Context

NewContext 生成一个上下文

Author : go_developer@163.com<张德满>

Date : 8:26 下午 2021/2/27

type LogFieldConfig

type LogFieldConfig struct {
	Message       string
	UsedTimeField string
	CommandField  string
	FlagField     string
}

LogFieldConfig 日志字段配置

Author : go_developer@163.com<张德满>

Date : 9:20 下午 2021/2/27

type LoggerConfig

type LoggerConfig struct {
	LoggerPath    string
	LoggerFile    string
	LoggerLevel   zapcore.Level
	ConsoleOutput bool
	Encoder       zapcore.Encoder
	SplitConfig   *logger.RotateLogConfig
}

LoggerConfig 日志配置

Author : go_developer@163.com<张德满>

Date : 5:26 下午 2021/2/27

type Options

type Options struct {
	Conf              *redisInstance.Options // 第三方包的选项
	Logger            *LoggerConfig          // 日志的配置
	LoggerFieldConfig *LogFieldConfig        // 日志字段的配置
}

Options 连接选项,百分之百兼容第三方包的选项

Author : go_developer@163.com<张德满>

Date : 4:57 下午 2021/2/27

type RealClient

type RealClient struct {
	Flag              string                // redis 标识
	Instance          *redisInstance.Client // redis 实例
	Logger            *zap.Logger           // 日志实例
	LoggerFieldConfig *LogFieldConfig       // 日志字段的配置
}

RealClient 包装好的 redis client

type SetContextFunc

type SetContextFunc func(rc *Context)

SetContextFunc 设置context参数

func WithCtx

func WithCtx(ctx context.Context) SetContextFunc

WithCtx 设置context

Author : go_developer@163.com<张德满>

Date : 8:30 下午 2021/2/27

func WithExtra

func WithExtra(extra easymap.EasyMap) SetContextFunc

WithExtra 设置扩展信息

Author : go_developer@163.com<张德满>

Date : 8:36 下午 2021/2/27

func WithGinCtx

func WithGinCtx(ginCtx *gin.Context) SetContextFunc

WithGinCtx 设置gin上下文

Author : go_developer@163.com<张德满>

Date : 8:34 下午 2021/2/27

func WithRequestID

func WithRequestID(requestID string) SetContextFunc

WithRequestID ...

Author : go_developer@163.com<张德满>

Date : 8:42 下午 2021/2/27

func WithRequestIDField

func WithRequestIDField(requestIDField string) SetContextFunc

WithRequestIDField 设置request_id参数名

Author : go_developer@163.com<张德满>

Date : 8:41 下午 2021/2/27

Jump to

Keyboard shortcuts

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