commit
ce4722cd94
10 changed files with 87 additions and 25 deletions
@ -0,0 +1,6 @@ |
||||
FROM busybox |
||||
|
||||
COPY ./bin/redis-shake /usr/local/app/redis-shake |
||||
COPY ./conf/redis-shake.conf /usr/local/app/redis-shake.conf |
||||
ENV TYPE sync |
||||
CMD /usr/local/app/redis-shake -type=${TYPE} -conf=/usr/local/app/redis-shake.conf |
Binary file not shown.
Binary file not shown.
@ -1,19 +1,49 @@ |
||||
package utils |
||||
|
||||
import( |
||||
logRotate "gopkg.in/natefinch/lumberjack.v2" |
||||
import ( |
||||
"net" |
||||
"fmt" |
||||
"strings" |
||||
|
||||
"pkg/libs/bytesize" |
||||
|
||||
logRotate "gopkg.in/natefinch/lumberjack.v2" |
||||
) |
||||
|
||||
const( |
||||
const ( |
||||
GolangSecurityTime = "2006-01-02T15:04:05Z" |
||||
// GolangSecurityTime = "2006-01-02 15:04:05"
|
||||
ReaderBufferSize = bytesize.MB * 32 |
||||
WriterBufferSize = bytesize.MB * 8 |
||||
) |
||||
|
||||
var( |
||||
var ( |
||||
Version = "$" |
||||
LogRotater *logRotate.Logger |
||||
StartTime string |
||||
) |
||||
) |
||||
|
||||
// read until hit the end of RESP: "\r\n"
|
||||
func ReadRESPEnd(c net.Conn) (string, error) { |
||||
var ret string |
||||
for { |
||||
b := make([]byte, 1) |
||||
if _, err := c.Read(b); err != nil { |
||||
return "", fmt.Errorf("read error[%v], current return[%s]", err, ret) |
||||
} |
||||
|
||||
ret += string(b) |
||||
if strings.HasSuffix(ret, "\r\n") { |
||||
break |
||||
} |
||||
} |
||||
return ret, nil |
||||
} |
||||
|
||||
func RemoveRESPEnd(input string) string { |
||||
length := len(input) |
||||
if length >= 2 { |
||||
return input[: length - 2] |
||||
} |
||||
return input |
||||
} |
Loading…
Reference in new issue