From adb92a63c3723c4b7b7deb86673d43b1f9ed7aa4 Mon Sep 17 00:00:00 2001 From: bryanqiu Date: Fri, 3 Mar 2023 12:21:55 +0800 Subject: [PATCH] add redis --- logging/logging.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/logging/logging.go b/logging/logging.go index ce9e22b..043d981 100644 --- a/logging/logging.go +++ b/logging/logging.go @@ -20,14 +20,16 @@ import ( "fmt" "log" "time" + + "github.com/gomodule/redigo/redis" ) var ( - _ ConnWithTimeout = (*loggingConn)(nil) + _ redis.ConnWithTimeout = (*loggingConn)(nil) ) // NewLoggingConn returns a logging wrapper around a connection. -func NewLoggingConn(conn Conn, logger *log.Logger, prefix string) Conn { +func NewLoggingConn(conn redis.Conn, logger *log.Logger, prefix string) redis.Conn { if prefix != "" { prefix = prefix + "." } @@ -35,7 +37,7 @@ func NewLoggingConn(conn Conn, logger *log.Logger, prefix string) Conn { } // NewLoggingConnFilter returns a logging wrapper around a connection and a filter function. -func NewLoggingConnFilter(conn Conn, logger *log.Logger, prefix string, skip func(cmdName string) bool) Conn { +func NewLoggingConnFilter(conn redis.Conn, logger *log.Logger, prefix string, skip func(cmdName string) bool) redis.Conn { if prefix != "" { prefix = prefix + "." } @@ -43,7 +45,7 @@ func NewLoggingConnFilter(conn Conn, logger *log.Logger, prefix string, skip fun } type loggingConn struct { - Conn + redis.Conn logger *log.Logger prefix string skip func(cmdName string) bool @@ -123,13 +125,13 @@ func (c *loggingConn) Do(commandName string, args ...interface{}) (interface{}, } func (c *loggingConn) DoContext(ctx context.Context, commandName string, args ...interface{}) (interface{}, error) { - reply, err := DoContext(c.Conn, ctx, commandName, args...) + reply, err := redis.DoContext(c.Conn, ctx, commandName, args...) c.print("DoContext", commandName, args, reply, err) return reply, err } func (c *loggingConn) DoWithTimeout(timeout time.Duration, commandName string, args ...interface{}) (interface{}, error) { - reply, err := DoWithTimeout(c.Conn, timeout, commandName, args...) + reply, err := redis.DoWithTimeout(c.Conn, timeout, commandName, args...) c.print("DoWithTimeout", commandName, args, reply, err) return reply, err } @@ -147,13 +149,13 @@ func (c *loggingConn) Receive() (interface{}, error) { } func (c *loggingConn) ReceiveContext(ctx context.Context) (interface{}, error) { - reply, err := ReceiveContext(c.Conn, ctx) + reply, err := redis.ReceiveContext(c.Conn, ctx) c.print("ReceiveContext", "", nil, reply, err) return reply, err } func (c *loggingConn) ReceiveWithTimeout(timeout time.Duration) (interface{}, error) { - reply, err := ReceiveWithTimeout(c.Conn, timeout) + reply, err := redis.ReceiveWithTimeout(c.Conn, timeout) c.print("ReceiveWithTimeout", "", nil, reply, err) return reply, err }